diff --git a/.git-hooks/precommit.sh b/.git-hooks/precommit.sh deleted file mode 100644 index a6b495d..0000000 --- a/.git-hooks/precommit.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/zsh - -# current directory is always `.git/..` root -# echo $PWD diff --git a/packages/nuxt/pages/post/_.vue b/packages/nuxt/pages/post/_.vue index 3ecf94f..0bb8aa6 100644 --- a/packages/nuxt/pages/post/_.vue +++ b/packages/nuxt/pages/post/_.vue @@ -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 diff --git a/packages/nuxt/plugins/axios-fix.ts b/packages/nuxt/plugins/axios-fix.ts index b5d85c1..9169656 100644 --- a/packages/nuxt/plugins/axios-fix.ts +++ b/packages/nuxt/plugins/axios-fix.ts @@ -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) => { diff --git a/packages/nuxt/scripts/make-html.ts b/packages/nuxt/scripts/make-html.ts index 4ae0515..cc9f2ab 100644 --- a/packages/nuxt/scripts/make-html.ts +++ b/packages/nuxt/scripts/make-html.ts @@ -108,7 +108,7 @@ export class MakeHtml { return { html: this.$('