mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
refactor(theme): use JSON-LD instead of microdata for blog structured data (#9669)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com> Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
parent
8abd1899a6
commit
60d9346965
23 changed files with 348 additions and 68 deletions
|
@ -42,6 +42,7 @@ import type {
|
|||
BlogTags,
|
||||
BlogContent,
|
||||
BlogPaginated,
|
||||
BlogMetadata,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export default async function pluginContentBlog(
|
||||
|
@ -182,6 +183,7 @@ export default async function pluginContentBlog(
|
|||
blogArchiveComponent,
|
||||
routeBasePath,
|
||||
archiveBasePath,
|
||||
blogTitle,
|
||||
} = options;
|
||||
|
||||
const {addRoute, createData} = actions;
|
||||
|
@ -257,6 +259,15 @@ export default async function pluginContentBlog(
|
|||
),
|
||||
);
|
||||
|
||||
const blogMetadata: BlogMetadata = {
|
||||
blogBasePath: normalizeUrl([baseUrl, routeBasePath]),
|
||||
blogTitle,
|
||||
};
|
||||
const blogMetadataPath = await createData(
|
||||
`blogMetadata-${pluginId}.json`,
|
||||
JSON.stringify(blogMetadata, null, 2),
|
||||
);
|
||||
|
||||
// Create routes for blog entries.
|
||||
await Promise.all(
|
||||
blogPosts.map(async (blogPost) => {
|
||||
|
@ -276,6 +287,9 @@ export default async function pluginContentBlog(
|
|||
sidebar: aliasedSource(sidebarProp),
|
||||
content: metadata.source,
|
||||
},
|
||||
context: {
|
||||
blogMetadata: aliasedSource(blogMetadataPath),
|
||||
},
|
||||
});
|
||||
|
||||
blogItemsToMetadata[id] = metadata;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue