Skip to content
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(docs, blog): add support for tags.yml, predefined list of tags #10137

Open
wants to merge 131 commits into
base: main
Choose a base branch
from

Conversation

OzakIOne
Copy link
Collaborator

@OzakIOne OzakIOne commented May 14, 2024

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

User request to have a predefined list of tags in a file which you can only choose from

  • add unit test
    • check if everything is tested correctly
  • do the same for blog plugin
  • add documentation
  • cleanup todos

Behavior :
undefined: search tags.yml by convention. Feature disabled if file does not exist
null/false (default): feature disabled even if tags.yml exists
tagFile.yml: search for tagFile.yml and throw if file does not exist

We check for duplicated tags permalink route and throw in case of duplication

onInlineTags tags behavior
ignore false | null | undefined do nothing
ignore string validate file but ignore check
ignore undefined but file exists validate file but ignore check
log false | null | undefined do nothing
log string process data and log
log undefined but file exists process data and log
warning false | null | undefined do nothing
warning string process data and warn
warning undefined but file exists process data and warn (default options)
throw false | null | undefined do nothing
throw string process data and throw
throw undefined but file exists process data and throw

Test Plan

yarn jest -t
ensureUniquePermalinks
normalizeTags
normalize tags
normalizeFrontMatterTags
processFileTagsPath
Dogfood

Test links

Guides:

API refs:

Tags pages blog:

Tags pages docs:

Related issues/PRs

fix #5913
#5975

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 14, 2024
Copy link

github-actions bot commented May 14, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 56 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 66 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 68 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 63 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 68 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 76 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

netlify bot commented May 14, 2024

[V2]

Name Link
🔨 Latest commit 42723f8
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6659aaf90612ea000970548f
😎 Deploy Preview https://deploy-preview-10137--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need :

  export type VersionMetadata = ContentPaths & {
    tagsFile: TagsFile | null;

    tagsPath: string;
  }

We probably need to modify/rename this method

type TagsFile = Record<string, Tag>

export function normalizeFrontMatterTags(
  /** Base path to append the tag permalinks to. */
  tagsPath: string,
  /** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
  frontMatterTags: FrontMatterTag[] | undefined = [],
  tagsFile: TagsFile
): Tag[]

packages/docusaurus-plugin-content-docs/src/options.ts Outdated Show resolved Hide resolved
packages/docusaurus-plugin-content-docs/src/options.ts Outdated Show resolved Hide resolved
packages/docusaurus-plugin-content-docs/src/tags.ts Outdated Show resolved Hide resolved
packages/docusaurus-plugin-content-docs/src/docs.ts Outdated Show resolved Hide resolved
packages/docusaurus-plugin-content-docs/src/docs.ts Outdated Show resolved Hide resolved
website/docusaurus.config.ts Outdated Show resolved Hide resolved
Copy link

github-actions bot commented May 17, 2024

Size Change: +614 B (+0.04%)

Total Size: 1.72 MB

Filename Size Change
website/.docusaurus/docusaurus.config.mjs 27.1 kB +155 B (+0.58%)
website/.docusaurus/registry.js 276 kB +108 B (+0.04%)
website/.docusaurus/routes.js 180 kB +72 B (+0.04%)
website/.docusaurus/routesChunkNames.json 120 kB +36 B (+0.03%)
website/build/assets/js/main.********.js 855 kB +243 B (+0.03%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/codeTranslations.json 2 B
website/.docusaurus/globalData.json 107 kB
website/.docusaurus/i18n.json 930 B
website/.docusaurus/site-metadata.json 2.17 kB
website/build/assets/css/styles.********.css 112 kB
website/build/index.html 38.1 kB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Predefined tag lists per plugin/preset
3 participants