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:
Joshua Chen 2022-03-16 19:36:57 +08:00 committed by GitHub
parent 46b1027c4a
commit 8d1c1954c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 509 additions and 240 deletions

View file

@ -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,
});
},