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

Commit 7a3291f

Browse files
chore(docs): add canonical url to head section (#5198)
* chore(docs): add canonical url to head section * Update default.js * Update default.js * Update themes.vue * Move common variables to `constants.js` Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
1 parent e9d54e6 commit 7a3291f

File tree

6 files changed

+48
-10
lines changed

6 files changed

+48
-10
lines changed

docs/components/header.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
</style>
176176

177177
<script>
178+
import { BASE_URL, BASE_URL_DEV, NETLIFY_URL } from '~/constants'
178179
import { version } from '~/content'
179180
180181
export default {
@@ -187,13 +188,13 @@ export default {
187188
},
188189
computed: {
189190
prodURL() {
190-
return 'https://bootstrap-vue.org/'
191+
return BASE_URL
191192
},
192193
devURL() {
193194
if (this.isNetlify) {
194-
return 'https://bootstrap-vue.netlify.app/'
195+
return NETLIFY_URL
195196
}
196-
return 'https://dev.bootstrap-vue.org/'
197+
return BASE_URL_DEV
197198
},
198199
isNetlify() {
199200
return Boolean(process.env.NETLIFY)

docs/constants.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const BASE_URL = 'https://bootstrap-vue.org'
2+
export const BASE_URL_DEV = 'https://dev.bootstrap-vue.org'
3+
export const NETLIFY_URL = 'https://bootstrap-vue.netlify.app'
4+
5+
export const GA_TRACKING_ID = 'UA-89526435-1'
6+
7+
export const TWITTER_HANDLE = '@BootstrapVue'

docs/layouts/default.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
import { BASE_URL } from '~/constants'
12
import Footer from '~/components/footer'
23
import Header from '~/components/header'
34

45
export default {
56
name: 'BVDefaultLayout',
6-
functional: true,
7-
render: h => [h(Header), h('nuxt'), h(Footer)]
7+
render(h) {
8+
return h('div', [h(Header), h('nuxt'), h(Footer)])
9+
},
10+
head() {
11+
// Add canonical URL so all site variations are
12+
// indexed to the same primary URL
13+
return {
14+
link: [
15+
{
16+
hid: 'canonical',
17+
rel: 'canonical',
18+
href: `${BASE_URL}${this.$route.path}`
19+
}
20+
]
21+
}
22+
}
823
}

docs/layouts/docs.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BASE_URL } from '~/constants'
12
import BVBreadcrumbs from '~/components/breadcrumbs'
23
import BVFeedback from '~/components/feedback'
34
import BVFooter from '~/components/footer'
@@ -73,5 +74,18 @@ export default {
7374
const $footer = h(BVFooter, { props: { isDocs: true } })
7475

7576
return h('div', [$header, $container, $footer])
77+
},
78+
head() {
79+
// Add canonical URL so all site variations are
80+
// indexed to the same primary URL
81+
return {
82+
link: [
83+
{
84+
hid: 'canonical',
85+
rel: 'canonical',
86+
href: `${BASE_URL}${this.$route.path}`
87+
}
88+
]
89+
}
7690
}
7791
}

docs/nuxt.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const fs = require('fs')
22
const path = require('path')
33
const marked = require('marked')
44
const hljs = require('highlight.js/lib/highlight.js')
5+
const { BASE_URL, GA_TRACKING_ID, TWITTER_HANDLE } = require('./constants')
56

67
// Import only the languages we need from "highlight.js"
78
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'))
@@ -247,11 +248,11 @@ module.exports = {
247248
},
248249
meta: {
249250
// `ogHost` is required for `og:image` to be populated
250-
ogHost: 'https://bootstrap-vue.org',
251+
ogHost: BASE_URL,
251252
ogImage: true,
252253
twitterCard: 'summary',
253-
twitterSite: '@BootstrapVue',
254-
twitterCreator: '@BootstrapVue'
254+
twitterSite: TWITTER_HANDLE,
255+
twitterCreator: TWITTER_HANDLE
255256
}
256257
},
257258

@@ -271,7 +272,7 @@ module.exports = {
271272
modules: ['@nuxtjs/pwa'],
272273

273274
'google-analytics': {
274-
id: 'UA-89526435-1',
275+
id: GA_TRACKING_ID,
275276
autoTracking: {
276277
exception: true
277278
}

docs/pages/themes.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
documentaton for licensing information.
7676
</li>
7777
<li>
78-
BootstrapVue does not guaantee that all coustom components provided by a theme are
78+
BootstrapVue does not guarantee that all coustom components provided by a theme are
7979
WIA-ARIA compliant. Refer to the provider documentation for details.
8080
</li>
8181
<li>

0 commit comments

Comments
 (0)