fix canonical url

This commit is contained in:
polv committed 2020-12-17 18:51:26 +07:00
1 parent fb69b2710f
commit 50e8530e96
5 files changed
+69 -11

No files matched your search

+61 -2
View File
@@ -59,6 +59,65 @@ import '~/assets/remark42'
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() {
this.initRemark42()
},
@@ -69,14 +128,14 @@ import '~/assets/remark42'
},
})
export default class PostPage extends Vue {
post: {
post!: {
date?: string
title: string
image?: string
tag?: string[]
category?: string[]
content: string
} | null = null
}
theme = THEME
+4 -3
View File
@@ -1,9 +1,10 @@
import { Plugin } from '@nuxt/types'
const plugin: Plugin = ({ $axios, error }) => {
if (typeof location !== 'undefined') {
$axios.defaults.baseURL = location.origin
}
$axios.defaults.baseURL =
typeof location !== 'undefined'
? location.origin
: `http://localhost:${process.env.SERVER_PORT}`
$axios.interceptors.response.use(
(r) => {
+1 -1
View File
@@ -108,7 +108,7 @@ export class MakeHtml {
return {
html: this.$('<div>').append($div).html() || '',
text: $div.text(),
text: $div.text().trim(),
}
}
+3 -1
View File
@@ -14,7 +14,9 @@ export async function runServer() {
await initDatabase()
const app = express()
app.use(morgan('common'))
if (process.env.NODE_ENV === 'development') {
app.use(morgan('common'))
}
const router = express.Router()
app.use('/api', router)