Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback to default description #125

Merged
merged 3 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not using computed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, You're right it should be computed

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