From 90ffc514c9e5eebd36f185273c67bc55d1ef9ff2 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 19 Oct 2019 12:16:44 -0700 Subject: [PATCH 1/2] feat(v1): allow specifying meta desc in front matter --- docs/api-doc-markdown.md | 2 ++ docs/getting-started-installation.md | 1 + packages/docusaurus-1.x/lib/core/DocsLayout.js | 2 +- packages/docusaurus-1.x/lib/server/readMetadata.js | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/api-doc-markdown.md b/docs/api-doc-markdown.md index 5e363f7ddd4f..049d8f0cfca7 100644 --- a/docs/api-doc-markdown.md +++ b/docs/api-doc-markdown.md @@ -15,6 +15,8 @@ Documents use the following markdown header fields that are enclosed by a line ` `title`: The title of your document. If this field is not present, the document's `title` will default to its `id`. +`description`: The description of your document which will become the `` and `` in ``. If this field is not present, it will default to the first line of the contents. + `hide_title`: Whether to hide the title at the top of the doc. `sidebar_label`: The text shown in the document sidebar and in the next/previous button for this document. If this field is not present, the document's `sidebar_label` will default to its `title`. diff --git a/docs/getting-started-installation.md b/docs/getting-started-installation.md index 18edd5587dd4..8d6aedac5eb1 100644 --- a/docs/getting-started-installation.md +++ b/docs/getting-started-installation.md @@ -1,6 +1,7 @@ --- id: installation title: Installation +description: Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly! --- Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly. diff --git a/packages/docusaurus-1.x/lib/core/DocsLayout.js b/packages/docusaurus-1.x/lib/core/DocsLayout.js index 04e0b54e64dc..0f99ff4f0b3b 100644 --- a/packages/docusaurus-1.x/lib/core/DocsLayout.js +++ b/packages/docusaurus-1.x/lib/core/DocsLayout.js @@ -88,7 +88,7 @@ class DocsLayout extends React.Component { separateOnPageNav: hasOnPageNav, })} title={title} - description={content.trim().split('\n')[0]} + description={metadata.description || content.trim().split('\n')[0]} language={metadata.language} version={metadata.version} metadata={metadata}> diff --git a/packages/docusaurus-1.x/lib/server/readMetadata.js b/packages/docusaurus-1.x/lib/server/readMetadata.js index 20d0409dfda2..70ded9b2ba37 100644 --- a/packages/docusaurus-1.x/lib/server/readMetadata.js +++ b/packages/docusaurus-1.x/lib/server/readMetadata.js @@ -36,6 +36,7 @@ const SupportedHeaderFields = new Set([ 'hide_title', 'layout', 'custom_edit_url', + 'description', ]); let allSidebars; From 85bcf444787dce2cf0766210d41d220536a50f59 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 20 Oct 2019 11:11:40 -0700 Subject: [PATCH 2/2] misc(v2): sync with v1 --- docs/api-doc-markdown.md | 14 +++++--------- website/docs/markdown-features.mdx | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/api-doc-markdown.md b/docs/api-doc-markdown.md index 049d8f0cfca7..f1408a455dd3 100644 --- a/docs/api-doc-markdown.md +++ b/docs/api-doc-markdown.md @@ -11,15 +11,11 @@ Docusaurus uses [GitHub Flavored Markdown (GFM)](https://guides.github.com/featu Documents use the following markdown header fields that are enclosed by a line `---` on either side: -`id`: A unique document id. If this field is not present, the document's `id` will default to its file name (without the extension). - -`title`: The title of your document. If this field is not present, the document's `title` will default to its `id`. - -`description`: The description of your document which will become the `` and `` in ``. If this field is not present, it will default to the first line of the contents. - -`hide_title`: Whether to hide the title at the top of the doc. - -`sidebar_label`: The text shown in the document sidebar and in the next/previous button for this document. If this field is not present, the document's `sidebar_label` will default to its `title`. +- `id`: A unique document id. If this field is not present, the document's `id` will default to its file name (without the extension). +- `title`: The title of your document. If this field is not present, the document's `title` will default to its `id`. +- `hide_title`: Whether to hide the title at the top of the doc. +- `description`: The description of your document which will become the `` and `` in ``, used by search engines. If this field is not present, it will default to the first line of the contents. +- `sidebar_label`: The text shown in the document sidebar and in the next/previous button for this document. If this field is not present, the document's `sidebar_label` will default to its `title`. For example: diff --git a/website/docs/markdown-features.mdx b/website/docs/markdown-features.mdx index ff2a8faa86f6..e2136f2d1522 100644 --- a/website/docs/markdown-features.mdx +++ b/website/docs/markdown-features.mdx @@ -101,8 +101,8 @@ Documents use the following markdown header fields that are enclosed by a line ` - `hide_title`: Whether to hide the title at the top of the doc. By default it is `false`. - `sidebar_label`: The text shown in the document sidebar and in the next/previous button for this document. If this field is not present, the document's `sidebar_label` will default to its `title`. - `custom_edit_url`: The URL for editing this document. If this field is not present, the document's edit URL will fall back to `editUrl` from options fields passed to `docusaurus-plugin-content-docs`. -- `description`: Description meta tag for the document page, for search engines. If this field is not present, it will default to the first line of the contents. - `keywords`: Keywords meta tag for the document page, for search engines. +- `description`: The description of your document, which will become the `` and `` in ``, used by search engines. If this field is not present, it will default to the first line of the contents. - `image`: Cover or thumbnail image that will be used when displaying the link to your post. Example: