From 233decea735d035890c66ead83a12ff19fb4a834 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 19 Oct 2019 12:16:44 -0700 Subject: [PATCH] feat(v1): allow specifying meta desc in front matter --- docs/getting-started-installation.md | 1 + packages/docusaurus-1.x/lib/core/DocsLayout.js | 2 +- packages/docusaurus-1.x/lib/server/readMetadata.js | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/getting-started-installation.md b/docs/getting-started-installation.md index 18edd5587dd4f..8d6aedac5eb15 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 04e0b54e64dc1..0f99ff4f0b3b7 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 20d0409dfda2f..28badc878f225 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; @@ -175,7 +176,9 @@ function processMetadata(file, refDir) { versionPart = 'next/'; } - metadata.permalink = `${docsPart}${langPart}${versionPart}${metadata.id}.html`; + metadata.permalink = `${docsPart}${langPart}${versionPart}${ + metadata.id + }.html`; // change ids previous, next metadata.localized_id = metadata.id;