🌐 AI搜索 & 代理 主页
Skip to content

Commit 280d487

Browse files
authored
chore(docs): add head meta description to section index pages for better SEO (#4195)
1 parent efcdba6 commit 280d487

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/plugins/docs-mixin.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* docs-mixin: used by any page under /docs path
33
*/
44
import { makeTOC, scrollTo, offsetTop } from '~/utils'
5-
import { bvDescription } from '~/content'
5+
import { bvDescription, nav } from '~/content'
66

77
const TOC_CACHE = {}
88

@@ -38,6 +38,14 @@ export default {
3838
return [title, section, 'BootstrapVue'].filter(Boolean).join(' | ')
3939
},
4040
headMeta() {
41+
const section = this.$route.name.split('-')[1]
42+
const sectionMeta = section ? nav.find(n => n.base === `${section}/`) : null
43+
const description =
44+
this.meta && this.meta.description
45+
? this.meta.description
46+
: sectionMeta && sectionMeta.description
47+
? sectionMeta.description
48+
: bvDescription
4149
const meta = [
4250
{
4351
hid: 'og:title',
@@ -46,25 +54,17 @@ export default {
4654
content: this.headTitle
4755
}
4856
]
49-
if (this.meta && this.meta.description) {
50-
const desc = this.meta.description
57+
if (description) {
5158
meta.push({
5259
hid: 'description',
5360
name: 'description',
54-
content: desc
61+
content: description
5562
})
5663
meta.push({
5764
hid: 'og:description',
5865
name: 'og:description',
5966
property: 'og:description',
60-
content: desc
61-
})
62-
} else if (bvDescription) {
63-
// TODO: Check if section group has description
64-
meta.push({
65-
hid: 'description',
66-
name: 'description',
67-
content: bvDescription
67+
content: description
6868
})
6969
}
7070
return meta

0 commit comments

Comments
 (0)