From 3da8f601093fcf2590eeafb44cd7da2e7b17bc90 Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 9 Aug 2024 15:54:01 +0200 Subject: [PATCH] Add s/plural to option name for consistency: onUntruncatedBlogPosts --- .../src/__tests__/options.test.ts | 29 ++++++++++--------- .../src/blogUtils.ts | 10 +++---- .../src/index.ts | 2 +- .../src/options.ts | 6 ++-- .../src/plugin-content-blog.d.ts | 3 +- website/_dogfooding/dogfooding.config.ts | 2 +- .../docs/api/plugins/plugin-content-blog.mdx | 2 +- website/docusaurus.config.ts | 2 +- 8 files changed, 29 insertions(+), 27 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/options.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/options.test.ts index 5698476859d8..b2de2306f6f9 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/options.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/options.test.ts @@ -375,43 +375,44 @@ describe('validateOptions', () => { }); }); - describe('onUntruncatedBlogPost', () => { - it('accepts onUntruncatedBlogPost - undefined', () => { + describe('onUntruncatedBlogPosts', () => { + it('accepts onUntruncatedBlogPosts - undefined', () => { expect( - testValidate({onUntruncatedBlogPost: undefined}).onUntruncatedBlogPost, + testValidate({onUntruncatedBlogPosts: undefined}) + .onUntruncatedBlogPosts, ).toBe('warn'); }); - it('accepts onUntruncatedBlogPost - "throw"', () => { + it('accepts onUntruncatedBlogPosts - "throw"', () => { expect( - testValidate({onUntruncatedBlogPost: 'throw'}).onUntruncatedBlogPost, + testValidate({onUntruncatedBlogPosts: 'throw'}).onUntruncatedBlogPosts, ).toBe('throw'); }); - it('rejects onUntruncatedBlogPost - "trace"', () => { + it('rejects onUntruncatedBlogPosts - "trace"', () => { expect(() => // @ts-expect-error: test - testValidate({onUntruncatedBlogPost: 'trace'}), + testValidate({onUntruncatedBlogPosts: 'trace'}), ).toThrowErrorMatchingInlineSnapshot( - `""onUntruncatedBlogPost" must be one of [ignore, log, warn, throw]"`, + `""onUntruncatedBlogPosts" must be one of [ignore, log, warn, throw]"`, ); }); - it('rejects onUntruncatedBlogPost - null', () => { + it('rejects onUntruncatedBlogPosts - null', () => { expect(() => // @ts-expect-error: test - testValidate({onUntruncatedBlogPost: 42}), + testValidate({onUntruncatedBlogPosts: 42}), ).toThrowErrorMatchingInlineSnapshot( - `""onUntruncatedBlogPost" must be one of [ignore, log, warn, throw]"`, + `""onUntruncatedBlogPosts" must be one of [ignore, log, warn, throw]"`, ); }); - it('rejects onUntruncatedBlogPost - 42', () => { + it('rejects onUntruncatedBlogPosts - 42', () => { expect(() => // @ts-expect-error: test - testValidate({onUntruncatedBlogPost: 42}), + testValidate({onUntruncatedBlogPosts: 42}), ).toThrowErrorMatchingInlineSnapshot( - `""onUntruncatedBlogPost" must be one of [ignore, log, warn, throw]"`, + `""onUntruncatedBlogPosts" must be one of [ignore, log, warn, throw]"`, ); }); }); diff --git a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts index 3e26e44128b0..65ffe5887fcd 100644 --- a/packages/docusaurus-plugin-content-blog/src/blogUtils.ts +++ b/packages/docusaurus-plugin-content-blog/src/blogUtils.ts @@ -50,21 +50,21 @@ export function truncate(fileString: string, truncateMarker: RegExp): string { export function reportUntruncatedBlogPosts({ blogPosts, - onUntruncatedBlogPost, + onUntruncatedBlogPosts, }: { blogPosts: BlogPost[]; - onUntruncatedBlogPost: PluginOptions['onUntruncatedBlogPost']; + onUntruncatedBlogPosts: PluginOptions['onUntruncatedBlogPosts']; }): void { const untruncatedBlogPosts = blogPosts.filter( (p) => !p.metadata.hasTruncateMarker, ); - if (onUntruncatedBlogPost !== 'ignore' && untruncatedBlogPosts.length > 0) { + if (onUntruncatedBlogPosts !== 'ignore' && untruncatedBlogPosts.length > 0) { const message = `Docusaurus found untruncated blog posts: ${untruncatedBlogPosts .map((p) => aliasedSitePathToRelativePath(p.metadata.source)) .join('\n- ')} -You can turn off this settings by setting onUntruncatedBlogPost to 'ignore' in your docusaurus config file`; - logger.report(onUntruncatedBlogPost)(message); +You can turn off this settings by setting onUntruncatedBlogPosts to 'ignore' in your docusaurus config file`; + logger.report(onUntruncatedBlogPosts)(message); } } diff --git a/packages/docusaurus-plugin-content-blog/src/index.ts b/packages/docusaurus-plugin-content-blog/src/index.ts index b930facb57df..7ae3b5a54c79 100644 --- a/packages/docusaurus-plugin-content-blog/src/index.ts +++ b/packages/docusaurus-plugin-content-blog/src/index.ts @@ -192,7 +192,7 @@ export default async function pluginContentBlog( }); reportUntruncatedBlogPosts({ blogPosts, - onUntruncatedBlogPost: options.onUntruncatedBlogPost, + onUntruncatedBlogPosts: options.onUntruncatedBlogPosts, }); const listedBlogPosts = blogPosts.filter(shouldBeListed); diff --git a/packages/docusaurus-plugin-content-blog/src/options.ts b/packages/docusaurus-plugin-content-blog/src/options.ts index 9bf48f5fa00a..11e912b68170 100644 --- a/packages/docusaurus-plugin-content-blog/src/options.ts +++ b/packages/docusaurus-plugin-content-blog/src/options.ts @@ -72,7 +72,7 @@ export const DEFAULT_OPTIONS: PluginOptions = { tags: undefined, authorsBasePath: 'authors', onInlineAuthors: 'warn', - onUntruncatedBlogPost: 'warn', + onUntruncatedBlogPosts: 'warn', }; export const XSLTBuiltInPaths = { @@ -241,9 +241,9 @@ const PluginOptionSchema = Joi.object({ onInlineAuthors: Joi.string() .equal('ignore', 'log', 'warn', 'throw') .default(DEFAULT_OPTIONS.onInlineAuthors), - onUntruncatedBlogPost: Joi.string() + onUntruncatedBlogPosts: Joi.string() .equal('ignore', 'log', 'warn', 'throw') - .default(DEFAULT_OPTIONS.onUntruncatedBlogPost), + .default(DEFAULT_OPTIONS.onUntruncatedBlogPosts), }).default(DEFAULT_OPTIONS); export function validateOptions({ diff --git a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts index fd7622f072c9..578688a4595b 100644 --- a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts +++ b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts @@ -521,7 +521,8 @@ declare module '@docusaurus/plugin-content-blog' { authorsBasePath: string; /** The behavior of Docusaurus when it finds inline authors. */ onInlineAuthors: 'ignore' | 'log' | 'warn' | 'throw'; - onUntruncatedBlogPost: 'ignore' | 'log' | 'warn' | 'throw'; + /** The behavior of Docusaurus when it finds untruncated blog posts. */ + onUntruncatedBlogPosts: 'ignore' | 'log' | 'warn' | 'throw'; }; export type UserFeedXSLTOptions = diff --git a/website/_dogfooding/dogfooding.config.ts b/website/_dogfooding/dogfooding.config.ts index d1731f2851a6..94b142cae275 100644 --- a/website/_dogfooding/dogfooding.config.ts +++ b/website/_dogfooding/dogfooding.config.ts @@ -99,7 +99,7 @@ export const dogfoodingPluginInstances: PluginConfig[] = [ : defaultReadingTime({content, options: {wordsPerMinute: 5}}), onInlineTags: 'warn', onInlineAuthors: 'ignore', - onUntruncatedBlogPost: 'ignore', + onUntruncatedBlogPosts: 'ignore', tags: 'tags.yml', } satisfies BlogOptions, ], diff --git a/website/docs/api/plugins/plugin-content-blog.mdx b/website/docs/api/plugins/plugin-content-blog.mdx index 10f0fb69f64d..50a268c2fda9 100644 --- a/website/docs/api/plugins/plugin-content-blog.mdx +++ b/website/docs/api/plugins/plugin-content-blog.mdx @@ -85,7 +85,7 @@ Accepted fields: | `showLastUpdateTime` | `boolean` | `false` | Whether to display the last date the blog post was updated. This requires access to git history during the build, so will not work correctly with shallow clones (a common default for CI systems). With GitHub `actions/checkout`, use`fetch-depth: 0`. | | `tags` | `string \| false \| null \| undefined` | `tags.yml` | Path to the YAML tags file listing pre-defined tags. Relative to the blog content directory. | | `onInlineTags` | `'ignore' \| 'log' \| 'warn' \| 'throw'` | `warn` | The plugin behavior when blog posts contain inline tags (not appearing in the list of pre-defined tags, usually `tags.yml`). | -| `onUntruncatedBlogPost` | `'ignore' \| 'log' \| 'warn' \| 'throw'` | `warn` | The plugin behavior when blog posts do not contain a truncate marker. | +| `onUntruncatedBlogPosts` | `'ignore' \| 'log' \| 'warn' \| 'throw'` | `warn` | The plugin behavior when blog posts do not contain a truncate marker. | ```mdx-code-block diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index f5ee6cf703bf..f4f41427031d 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -475,7 +475,6 @@ export default async function createConfigAsync() { blog: { // routeBasePath: '/', path: 'blog', - onUntruncatedBlogPost: 'throw', showLastUpdateAuthor: true, showLastUpdateTime: true, editUrl: ({locale, blogDirPath, blogPath}) => { @@ -497,6 +496,7 @@ export default async function createConfigAsync() { blogDescription: 'Read blog posts about Docusaurus from the team', blogSidebarCount: 'ALL', blogSidebarTitle: 'All our posts', + onUntruncatedBlogPosts: 'throw', onInlineTags: process.env.DOCUSAURUS_CURRENT_LOCALE !== defaultLocale ? 'warn'