mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
refactor(content-blog): clean up type definitions; in-code documentation (#6922)
* refactor(content-blog): clean up type definitions; in-code documentation * add doc
This commit is contained in:
parent
46b1027c4a
commit
8d1c1954c1
16 changed files with 509 additions and 240 deletions
|
@ -26,13 +26,9 @@ import type {
|
|||
BlogTag,
|
||||
BlogTags,
|
||||
BlogContent,
|
||||
BlogItemsToMetadata,
|
||||
TagsModule,
|
||||
BlogPaginated,
|
||||
BlogContentPaths,
|
||||
BlogMarkdownLoaderOptions,
|
||||
MetaData,
|
||||
TagModule,
|
||||
} from './types';
|
||||
import {PluginOptionSchema} from './pluginOptionSchema';
|
||||
import type {
|
||||
|
@ -52,7 +48,9 @@ import {createBlogFeedFiles} from './feed';
|
|||
import type {
|
||||
PluginOptions,
|
||||
BlogPostFrontMatter,
|
||||
BlogPostMetadata,
|
||||
Assets,
|
||||
TagModule,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export default async function pluginContentBlog(
|
||||
|
@ -214,7 +212,7 @@ export default async function pluginContentBlog(
|
|||
blogTagsListPath,
|
||||
} = blogContents;
|
||||
|
||||
const blogItemsToMetadata: BlogItemsToMetadata = {};
|
||||
const blogItemsToMetadata: Record<string, BlogPostMetadata> = {};
|
||||
|
||||
const sidebarBlogPosts =
|
||||
options.blogSidebarCount === 'ALL'
|
||||
|
@ -325,11 +323,10 @@ export default async function pluginContentBlog(
|
|||
return;
|
||||
}
|
||||
|
||||
const tagsModule: TagsModule = Object.fromEntries(
|
||||
Object.entries(blogTags).map(([tagKey, tag]) => {
|
||||
const tagsModule: Record<string, TagModule> = Object.fromEntries(
|
||||
Object.entries(blogTags).map(([, tag]) => {
|
||||
const tagModule: TagModule = {
|
||||
allTagsPath: blogTagsListPath,
|
||||
slug: tagKey,
|
||||
name: tag.name,
|
||||
count: tag.items.length,
|
||||
permalink: tag.permalink,
|
||||
|
@ -479,7 +476,7 @@ export default async function pluginContentBlog(
|
|||
metadata,
|
||||
}: {
|
||||
frontMatter: BlogPostFrontMatter;
|
||||
metadata: MetaData;
|
||||
metadata: BlogPostMetadata;
|
||||
}): Assets => ({
|
||||
image: frontMatter.image,
|
||||
authorsImageUrls: metadata.authors.map(
|
||||
|
@ -512,6 +509,7 @@ export default async function pluginContentBlog(
|
|||
options,
|
||||
outDir,
|
||||
siteConfig,
|
||||
locale: currentLocale,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue