fix canonical url
This commit is contained in:
1 parent
fb69b2710f
commit
50e8530e96
5 files changed
+69
-11
No files matched your search
@@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/zsh
|
|
||||||
|
|
||||||
# current directory is always `.git/..` root
|
|
||||||
# echo $PWD
|
|
||||||
@@ -59,6 +59,65 @@ import '~/assets/remark42'
|
|||||||
post: r,
|
post: r,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
head() {
|
||||||
|
const { title: _title, content, tag, image } = this.post
|
||||||
|
const title = `${_title} - ${THEME.title}`
|
||||||
|
const description = content.substr(0, 140)
|
||||||
|
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
meta: [
|
||||||
|
{
|
||||||
|
hid: 'description',
|
||||||
|
name: 'description',
|
||||||
|
content: description,
|
||||||
|
},
|
||||||
|
...(tag
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
hid: 'keywords',
|
||||||
|
name: 'keywords',
|
||||||
|
content: tag.join(','),
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
{
|
||||||
|
hid: 'og:title',
|
||||||
|
property: 'og:title',
|
||||||
|
content: title,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hid: 'og:description',
|
||||||
|
property: 'og:description',
|
||||||
|
content: description,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hid: 'twitter:title',
|
||||||
|
property: 'twitter:title',
|
||||||
|
content: title,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hid: 'twitter:description',
|
||||||
|
property: 'twitter:description',
|
||||||
|
content: description,
|
||||||
|
},
|
||||||
|
...(image
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
hid: 'og:image',
|
||||||
|
property: 'og:image',
|
||||||
|
content: image,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hid: 'twitter:image',
|
||||||
|
property: 'twitter:image',
|
||||||
|
content: image,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initRemark42()
|
this.initRemark42()
|
||||||
},
|
},
|
||||||
@@ -69,14 +128,14 @@ import '~/assets/remark42'
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class PostPage extends Vue {
|
export default class PostPage extends Vue {
|
||||||
post: {
|
post!: {
|
||||||
date?: string
|
date?: string
|
||||||
title: string
|
title: string
|
||||||
image?: string
|
image?: string
|
||||||
tag?: string[]
|
tag?: string[]
|
||||||
category?: string[]
|
category?: string[]
|
||||||
content: string
|
content: string
|
||||||
} | null = null
|
}
|
||||||
|
|
||||||
theme = THEME
|
theme = THEME
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Plugin } from '@nuxt/types'
|
import { Plugin } from '@nuxt/types'
|
||||||
|
|
||||||
const plugin: Plugin = ({ $axios, error }) => {
|
const plugin: Plugin = ({ $axios, error }) => {
|
||||||
if (typeof location !== 'undefined') {
|
$axios.defaults.baseURL =
|
||||||
$axios.defaults.baseURL = location.origin
|
typeof location !== 'undefined'
|
||||||
}
|
? location.origin
|
||||||
|
: `http://localhost:${process.env.SERVER_PORT}`
|
||||||
|
|
||||||
$axios.interceptors.response.use(
|
$axios.interceptors.response.use(
|
||||||
(r) => {
|
(r) => {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ export class MakeHtml {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
html: this.$('<div>').append($div).html() || '',
|
html: this.$('<div>').append($div).html() || '',
|
||||||
text: $div.text(),
|
text: $div.text().trim(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ export async function runServer() {
|
|||||||
await initDatabase()
|
await initDatabase()
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
app.use(morgan('common'))
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
app.use(morgan('common'))
|
||||||
|
}
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
app.use('/api', router)
|
app.use('/api', router)
|
||||||
|
|||||||
Reference in new issue
Block a user