Skip to content

feat(v2): include frontmatter in loadedContent doc metadatas - #4495

Merged
slorber merged 7 commits into
meta:masterfrom
kaytwo:feat/frontmatter-in-globals
Mar 26, 2021
Merged

slorber merged 7 commits into
meta:masterfrom
kaytwo:feat/frontmatter-in-globals

Conversation

@kaytwo

@kaytwo kaytwo commented Mar 23, 2021

Copy link
Copy Markdown
Contributor

Motivation

Fixes #4492

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Added a new test using the new config option. All previous tests still pass.

Related PRs

None right now, will add if this PR is accepted.

@kaytwo
kaytwo requested review from lex111 and slorber as code owners March 23, 2021 05:47
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 23, 2021
@netlify

netlify Bot commented Mar 23, 2021 •

Copy link
Copy Markdown

@netlify

netlify Bot commented Mar 23, 2021 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Mar 23, 2021 •

Copy link
Copy Markdown

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 83
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4495--docusaurus-2.netlify.app/

@kaytwo
kaytwo force-pushed the feat/frontmatter-in-globals branch from 647f8a3 to 3bc5541 Compare March 23, 2021 07:12
@slorber

slorber commented Mar 24, 2021

Copy link
Copy Markdown
Collaborator

going to close this for now as I don't think it's what we should do, cf #4492

@slorber slorber closed this Mar 24, 2021
@slorber slorber reopened this Mar 24, 2021
@slorber

slorber commented Mar 24, 2021

Copy link
Copy Markdown
Collaborator

oh actually this makes sense, it's just a "wording" issue.

We want frontmatter in loadedContent (ie available in plugin memory), but we don't want frontmatter in globalData

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can add this, just need to remove the option and remove usage of global data.

It won't solve your sidebar problem directly but at least make the frontmatter available in loadedContent()

)
: undefined,
sidebar_label: sidebarLabel,
frontMatter: options.includeFrontMatterInGlobals ? frontMatter : undefined,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we want frontMatter here in all cases

id: doc.unversionedId,
path: doc.permalink,
sidebar: doc.sidebar,
...(doc.frontMatter && {frontMatter: doc.frontMatter}),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we don't want frontmatter here, as it increases the size of all the site's pages

versions: {},
editCurrentVersion: false,
editLocalizedFiles: false,
includeFrontMatterInGlobals: false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove option?

editUrl: Joi.alternatives().try(URISchema, Joi.function()),
editCurrentVersion: Joi.boolean().default(DEFAULT_OPTIONS.editCurrentVersion),
editLocalizedFiles: Joi.boolean().default(DEFAULT_OPTIONS.editLocalizedFiles),
includeFrontMatterInGlobals: Joi.boolean().default(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove

id: string;
path: string;
sidebar: string | undefined;
frontMatter?: FrontMatter;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

that seems wrong to me

// eslint-disable-next-line camelcase
sidebar_label?: string;
editUrl?: string | null;
frontMatter?: FrontMatter;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no ?

@slorber slorber changed the title feat: include frontmatter in globals feat(v2): include frontmatter in loadedContent doc metadatas Mar 26, 2021

@slorber slorber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM 👍

@slorber
slorber merged commit b10ed6c into meta:master Mar 26, 2021
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Mar 26, 2021
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
* feat: include frontmatter in globals

* feat: include frontmatter in globals (options schema test)

* feat(v2): document frontmatter in document metadata

* feat(v2): frontmatter in metadata, tests updated

* Update packages/docusaurus-plugin-content-docs/src/types.ts

* Update packages/docusaurus-plugin-content-docs/src/types.ts

Co-authored-by: Sébastien Lorber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: enable option to propagate arbitrary frontmatter data in globals

3 participants