From 547979a59f1ab60da3829afe95f4e0b585d46ffd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= <slorber@users.noreply.github.com>
Date: Mon, 12 Aug 2024 15:59:03 +0200
Subject: [PATCH] fix(create-docusaurus): Improve init templates blog setup +
 fix warnings (#10392)

---
 .../classic-typescript/docusaurus.config.ts          |  4 ++++
 .../templates/classic/docusaurus.config.js           |  4 ++++
 .../shared/blog/2019-05-28-first-blog-post.md        | 12 ++++++------
 .../shared/blog/2019-05-29-long-blog-post.md         |  4 ++--
 .../shared/blog/2021-08-01-mdx-blog-post.mdx         |  8 ++++++--
 .../shared/blog/2021-08-26-welcome/index.md          |  4 ++++
 .../templates/shared/blog/authors.yml                | 10 ++++------
 .../create-docusaurus/templates/shared/blog/tags.yml |  3 +++
 .../docusaurus-plugin-content-blog/src/options.ts    |  2 +-
 project-words.txt                                    |  1 +
 10 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/packages/create-docusaurus/templates/classic-typescript/docusaurus.config.ts b/packages/create-docusaurus/templates/classic-typescript/docusaurus.config.ts
index ae7cbf502e05..5e655d287429 100644
--- a/packages/create-docusaurus/templates/classic-typescript/docusaurus.config.ts
+++ b/packages/create-docusaurus/templates/classic-typescript/docusaurus.config.ts
@@ -50,6 +50,10 @@ const config: Config = {
           // Remove this to remove the "edit this page" links.
           editUrl:
             'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
+          // Useful options to enforce blogging best practices
+          onInlineTags: 'warn',
+          onInlineAuthors: 'warn',
+          onUntruncatedBlogPosts: 'warn',
         },
         theme: {
           customCss: './src/css/custom.css',
diff --git a/packages/create-docusaurus/templates/classic/docusaurus.config.js b/packages/create-docusaurus/templates/classic/docusaurus.config.js
index d3b51858f497..f9fb1f3d02d4 100644
--- a/packages/create-docusaurus/templates/classic/docusaurus.config.js
+++ b/packages/create-docusaurus/templates/classic/docusaurus.config.js
@@ -56,6 +56,10 @@ const config = {
           // Remove this to remove the "edit this page" links.
           editUrl:
             'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
+          // Useful options to enforce blogging best practices
+          onInlineTags: 'warn',
+          onInlineAuthors: 'warn',
+          onUntruncatedBlogPosts: 'warn',
         },
         theme: {
           customCss: './src/css/custom.css',
diff --git a/packages/create-docusaurus/templates/shared/blog/2019-05-28-first-blog-post.md b/packages/create-docusaurus/templates/shared/blog/2019-05-28-first-blog-post.md
index 02f3f81bd27b..d3032efb35cf 100644
--- a/packages/create-docusaurus/templates/shared/blog/2019-05-28-first-blog-post.md
+++ b/packages/create-docusaurus/templates/shared/blog/2019-05-28-first-blog-post.md
@@ -1,12 +1,12 @@
 ---
 slug: first-blog-post
 title: First Blog Post
-authors:
-  name: Gao Wei
-  title: Docusaurus Core Team
-  url: https://github.com/wgao19
-  image_url: https://github.com/wgao19.png
+authors: [slorber, yangshun]
 tags: [hola, docusaurus]
 ---
 
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
+Lorem ipsum dolor sit amet...
+
+<!-- truncate -->
+
+...consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
diff --git a/packages/create-docusaurus/templates/shared/blog/2019-05-29-long-blog-post.md b/packages/create-docusaurus/templates/shared/blog/2019-05-29-long-blog-post.md
index 26ffb1b1f653..eb4435de591c 100644
--- a/packages/create-docusaurus/templates/shared/blog/2019-05-29-long-blog-post.md
+++ b/packages/create-docusaurus/templates/shared/blog/2019-05-29-long-blog-post.md
@@ -1,7 +1,7 @@
 ---
 slug: long-blog-post
 title: Long Blog Post
-authors: endi
+authors: yangshun
 tags: [hello, docusaurus]
 ---
 
@@ -9,7 +9,7 @@ This is the summary of a very long blog post,
 
 Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view.
 
-<!--truncate-->
+<!-- truncate -->
 
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
 
diff --git a/packages/create-docusaurus/templates/shared/blog/2021-08-01-mdx-blog-post.mdx b/packages/create-docusaurus/templates/shared/blog/2021-08-01-mdx-blog-post.mdx
index c04ebe323ee3..0c4b4a48b988 100644
--- a/packages/create-docusaurus/templates/shared/blog/2021-08-01-mdx-blog-post.mdx
+++ b/packages/create-docusaurus/templates/shared/blog/2021-08-01-mdx-blog-post.mdx
@@ -11,10 +11,14 @@ Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/mar
 
 Use the power of React to create interactive blog posts.
 
+:::
+
+{/* truncate */}
+
+For example, use JSX to create an interactive button:
+
 ```js
 <button onClick={() => alert('button clicked!')}>Click me!</button>
 ```
 
 <button onClick={() => alert('button clicked!')}>Click me!</button>
-
-:::
diff --git a/packages/create-docusaurus/templates/shared/blog/2021-08-26-welcome/index.md b/packages/create-docusaurus/templates/shared/blog/2021-08-26-welcome/index.md
index 9455168f1701..349ea075f5bb 100644
--- a/packages/create-docusaurus/templates/shared/blog/2021-08-26-welcome/index.md
+++ b/packages/create-docusaurus/templates/shared/blog/2021-08-26-welcome/index.md
@@ -7,6 +7,10 @@ tags: [facebook, hello, docusaurus]
 
 [Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).
 
+Here are a few tips you might find useful.
+
+<!-- truncate -->
+
 Simply add Markdown files (or folders) to the `blog` directory.
 
 Regular blog authors can be added to `authors.yml`.
diff --git a/packages/create-docusaurus/templates/shared/blog/authors.yml b/packages/create-docusaurus/templates/shared/blog/authors.yml
index 39734f65b9cf..8bfa5c7c4b53 100644
--- a/packages/create-docusaurus/templates/shared/blog/authors.yml
+++ b/packages/create-docusaurus/templates/shared/blog/authors.yml
@@ -1,14 +1,9 @@
-endi:
-  name: Endilie Yacop Sucipto
-  title: Maintainer of Docusaurus
-  url: https://github.com/endiliey
-  image_url: https://github.com/endiliey.png
-
 yangshun:
   name: Yangshun Tay
   title: Front End Engineer @ Facebook
   url: https://github.com/yangshun
   image_url: https://github.com/yangshun.png
+  page: true
   socials:
     x: yangshunz
     github: yangshun
@@ -18,6 +13,9 @@ slorber:
   title: Docusaurus maintainer
   url: https://sebastienlorber.com
   image_url: https://github.com/slorber.png
+  page:
+    # customize the url of the author page at /blog/authors/<permalink>
+    permalink: '/all-sebastien-lorber-articles'
   socials:
     x: sebastienlorber
     linkedin: sebastienlorber
diff --git a/packages/create-docusaurus/templates/shared/blog/tags.yml b/packages/create-docusaurus/templates/shared/blog/tags.yml
index f71dd739318b..bfaa778fbdb0 100644
--- a/packages/create-docusaurus/templates/shared/blog/tags.yml
+++ b/packages/create-docusaurus/templates/shared/blog/tags.yml
@@ -2,14 +2,17 @@ facebook:
   label: Facebook
   permalink: /facebook
   description: Facebook tag description
+
 hello:
   label: Hello
   permalink: /hello
   description: Hello tag description
+
 docusaurus:
   label: Docusaurus
   permalink: /docusaurus
   description: Docusaurus tag description
+
 hola:
   label: Hola
   permalink: /hola
diff --git a/packages/docusaurus-plugin-content-blog/src/options.ts b/packages/docusaurus-plugin-content-blog/src/options.ts
index 11e912b68170..20981aaa87c5 100644
--- a/packages/docusaurus-plugin-content-blog/src/options.ts
+++ b/packages/docusaurus-plugin-content-blog/src/options.ts
@@ -68,9 +68,9 @@ export const DEFAULT_OPTIONS: PluginOptions = {
   showLastUpdateTime: false,
   showLastUpdateAuthor: false,
   processBlogPosts: async () => undefined,
-  onInlineTags: 'warn',
   tags: undefined,
   authorsBasePath: 'authors',
+  onInlineTags: 'warn',
   onInlineAuthors: 'warn',
   onUntruncatedBlogPosts: 'warn',
 };
diff --git a/project-words.txt b/project-words.txt
index d8bda0b3bef1..b6f404864278 100644
--- a/project-words.txt
+++ b/project-words.txt
@@ -168,6 +168,7 @@ linkify
 Linkify
 Localizable
 lockb
+lorber
 Lorber
 Lorber's
 lqip