From bc48f34e75547cc821ca1b441e0524da8807524f Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Thu, 4 Mar 2021 15:10:22 +0330 Subject: [PATCH] fix: fallback to default description (#125) * fix: fallback to default description * chore: remove tagline * cleanup --- docs/content/1.get-started/2.configuration.md | 1 - docs/content/settings.json | 1 - docs/pages/index.vue | 5 +++++ theme/module.js | 2 +- theme/pages/_.vue | 18 +++++++++++++++--- theme/utils/settings.js | 1 + 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/content/1.get-started/2.configuration.md b/docs/content/1.get-started/2.configuration.md index f1c4ba9cc..8fd69b9fc 100644 --- a/docs/content/1.get-started/2.configuration.md +++ b/docs/content/1.get-started/2.configuration.md @@ -31,7 +31,6 @@ The theme design is based on a `primary` color to make it easy to override, you | Key | Type | Description | |---------|------|-------------| | `title` | `String` | Documentation title | -| `tagline` | `String` | The tagline represents a short description of your documentation. | | `description` | `String` | Brief summary about documentation, added for search engine optimization and social sharing | | `url` | `String` | Url of your deployed documentation. | | `logo` | `String` `Object` | Logo of the project, can be an `Object` to set a logo per [color mode](https://github.com/nuxt-community/color-mode-module). | diff --git a/docs/content/settings.json b/docs/content/settings.json index 0e0a70a34..8b3b6b310 100644 --- a/docs/content/settings.json +++ b/docs/content/settings.json @@ -1,6 +1,5 @@ { "title": "Docus", - "tagline": "Documentation generator based on Nuxt and Tailwind.", "description": "Write in markdown, use Vue components, add style with TailwindCSS and enjoy the power of Nuxt.", "url": "https://docus.dev", "twitter": "nuxt_js", diff --git a/docs/pages/index.vue b/docs/pages/index.vue index e76e26bf7..b286b4453 100644 --- a/docs/pages/index.vue +++ b/docs/pages/index.vue @@ -91,6 +91,11 @@ export default { ] } }, + head () { + return { + title: 'Docus - Documentation generator based on Nuxt and Tailwind.' + } + }, mounted () { this.setupCopyInstall() }, diff --git a/theme/module.js b/theme/module.js index 00940f168..83f715422 100644 --- a/theme/module.js +++ b/theme/module.js @@ -28,7 +28,7 @@ export default function docusModule () { }) // default title and description for pages - options.meta.name = `${settings.title} - ${settings.tagline}` + options.meta.name = settings.title options.meta.description = settings.description if (settings.colors && settings.colors.primary) { options.meta.theme_color = settings.colors.primary diff --git a/theme/pages/_.vue b/theme/pages/_.vue index 6d025b2d9..56963f90e 100644 --- a/theme/pages/_.vue +++ b/theme/pages/_.vue @@ -61,13 +61,11 @@ export default { return { title: this.document.title, meta: [ - { hid: 'description', name: 'description', content: this.document.description }, // Open Graph { hid: 'og:title', property: 'og:title', content: this.document.title }, - { hid: 'og:description', property: 'og:description', content: this.document.description }, // Twitter Card { hid: 'twitter:title', name: 'twitter:title', content: this.document.title }, - { hid: 'twitter:description', name: 'twitter:description', content: this.document.description } + ...this.descriptionMeta() ] } }, @@ -90,6 +88,20 @@ export default { block.appendChild(component.$el) } }, 100) + }, + methods: { + descriptionMeta () { + if (!this.document.description) { + return [] + } + return [ + { hid: 'description', name: 'description', content: this.document.description }, + // Open Graph + { hid: 'og:description', property: 'og:description', content: this.document.description }, + // Twitter Card + { hid: 'twitter:description', name: 'twitter:description', content: this.document.description } + ] + } } } diff --git a/theme/utils/settings.js b/theme/utils/settings.js index 2a1fe0767..3a53ff03d 100644 --- a/theme/utils/settings.js +++ b/theme/utils/settings.js @@ -8,6 +8,7 @@ const DEFAULT_THEME_COLORS = { const DEFAULT_SETTINGS = { title: 'Docus', + description: '', layout: 'docs', url: '', github: {