Skip to content

Commit

Permalink
fix: fallback to default description (nuxt-modules#125)
Browse files Browse the repository at this point in the history
* fix: fallback to default description

* chore: remove tagline

* cleanup
  • Loading branch information
farnabaz authored Mar 4, 2021
1 parent 83657a6 commit bc48f34
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
1 change: 0 additions & 1 deletion docs/content/1.get-started/2.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). |
Expand Down
1 change: 0 additions & 1 deletion docs/content/settings.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions docs/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export default {
]
}
},
head () {
return {
title: 'Docus - Documentation generator based on Nuxt and Tailwind.'
}
},
mounted () {
this.setupCopyInstall()
},
Expand Down
2 changes: 1 addition & 1 deletion theme/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions theme/pages/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]
}
},
Expand All @@ -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 }
]
}
}
}
</script>
1 change: 1 addition & 0 deletions theme/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const DEFAULT_THEME_COLORS = {

const DEFAULT_SETTINGS = {
title: 'Docus',
description: '',
layout: 'docs',
url: '',
github: {
Expand Down

0 comments on commit bc48f34

Please sign in to comment.