-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: doc tags (same as blog tags) #3646
Conversation
- Addition of plugin-content-docs - Addition of DocTagsListPage in `docusaurus-theme-classic` ! Error exists for this commit towards the theme aspect and help required. Commit towards facebook#3434
Hi @isaac-philip! Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✔️ [V2] 🔨 Explore the source changes: 58367bb 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/611d4abc00054300074b5878 😎 Browse the preview: https://deploy-preview-3646--docusaurus-2.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've commited various changes to your branch to help you get started.
My code is not production ready nor tested, but it's mostly to help you figure things out and create a nice PR.
I only handled the creation of the tas list page, you can proceed to create one specific page per tag in the same way.
Note each version has a:
- set of docs
- a tag list
- a page per tag linking to the docs having it in the same version
Let me know if you need more help
Also, don't forget to sign the FB CLA.
const tagsProp = mapValues(loadedVersion.tags, (tagValue) => ({ | ||
name: tagValue.name, | ||
permalink: tagValue.permalink, | ||
count: tagValue.docIds.length, | ||
})); | ||
const tagsPropPath = await createData( | ||
`${docuHash(`tags-list-${loadedVersion.versionName}-prop`)}.json`, | ||
JSON.stringify(tagsProp, null, 2), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is how you create a component prop as json object (should rather be moved to props.ts and have an explicit type)
|
||
async function createTagPage(tag: VersionTag) { | ||
// TODO | ||
console.log(`todo createTagPage for tag=${tag.name}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: do something similar to create one page per tag
website/docs/introduction.md
Outdated
@@ -3,6 +3,7 @@ id: introduction | |||
title: Introduction | |||
description: Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly. | |||
slug: / | |||
tags: [test-tag, myOtherTag] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an example
export type LoadedVersion = VersionMetadata & { | ||
versionPath: string; | ||
mainDocId: string; | ||
docs: DocMetadata[]; | ||
tags: VersionTags; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tags are per version, it's not just a global set of tags for all the docs of the site, there is one set of tag per version
packages/docusaurus-theme-classic/src/theme/DocTagsListPage/index.tsx
Outdated
Show resolved
Hide resolved
So finally was able to get a deploy preview to work (after fixing the bootstrap theme). Note:
As you can see, each version should have its set of tags. "current" version has 2 tags, but alpha 66 do not have any tag. This is because only docs of "current" version have been tagged |
Hey @slorber , thanks for this. |
great let me know if you need help to complete it |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
- individual doc tag page added to show docs for that specific tag
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-3646--docusaurus-2.netlify.app/ |
still WIP but nearing a review, next steps is to,
|
Done with the two top items,
|
Hello @slorber , require some guidance here please. for now have the page as this that means the {
"name": "myothertag",
"permalink": "/docs/tags/my-other-tag",
"docIds": [
"deployment",
"introduction"
],
"allTagsPath": "/docs/tags"
} that is more info in the <div className="margin-vert--xl">
{items.map(({content: BlogPostContent}) => (
<BlogPostItem
key={BlogPostContent.metadata.permalink}
frontMatter={BlogPostContent.frontMatter}
metadata={BlogPostContent.metadata}
truncated>
<BlogPostContent />
</BlogPostItem>
))}
</div> Please guide, I checked but the DocContent item props etc I cannot figure out from where to utilize it? |
@nam-hle can you suggest please? |
Not sure what you need. Please explain more about your situation, perhaps because of my limited knowledge about the codebase. |
# Conflicts: # packages/docusaurus-plugin-content-docs/src/docs.ts # packages/docusaurus-plugin-content-docs/src/index.ts # packages/docusaurus-plugin-content-docs/src/types.ts # packages/docusaurus-plugin-content-docs/src/versions.ts # website/docusaurus.config.js
Thanks @isaac-philip, I've completed your PR and made some useful cleanups/refactors to avoid code duplication and swizzle theme comps more easily. Unless someone has any comment I'll merge it tomorrow. |
thanks @slorber !! 😇 |
Note: PR completed by @slorber
Breaking changes
/blog/tags/<myTag>
(let me know if you have an use-case for unprefixing them, we can restore that behavior if really needed)Motivation
Implement doc tags, similar to existing blog tags
tags
frontmatterHave you read the Contributing Guidelines on pull requests?
yes
Test Plan
test + dogfood/peview