File tree 7 files changed +84
-45
lines changed
7 files changed +84
-45
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang='ts'>
2
2
import { useData } from ' vitepress'
3
+ import { onMounted , onBeforeUnmount } from ' vue'
4
+ const { page, frontmatter } = useData ()
3
5
4
- const { frontmatter } = useData ()
6
+ let script: HTMLScriptElement
7
+
8
+ onMounted (() => {
9
+ const lastUpdated = new Date (<number > page .value .lastUpdated ).toISOString ()
10
+ const dataJsonLD = {
11
+ " @context" : " https://schema.org" ,
12
+ " @type" : " BlogPosting" ,
13
+ " headline" : frontmatter .value .title ,
14
+ " datePublished" : frontmatter .value .date ,
15
+ " dateModified" : lastUpdated ,
16
+ }
17
+
18
+ script = document .createElement (' script' )
19
+ script .setAttribute (' type' , ' application/ld+json' )
20
+ script .textContent = JSON .stringify (dataJsonLD )
21
+ document .head .appendChild (script )
22
+ })
23
+
24
+ onBeforeUnmount (() => {
25
+ if (script && script .parentElement ) {
26
+ script .parentElement .removeChild (script )
27
+ }
28
+ })
5
29
</script >
6
30
7
31
<template >
Original file line number Diff line number Diff line change @@ -20,5 +20,14 @@ export default {
20
20
app . component ( 'Category' , Category )
21
21
app . component ( 'Tags' , Tags )
22
22
app . component ( 'About' , About )
23
+
24
+ // https://github.com/vuejs/vitepress/issues/3100
25
+ router . onBeforeRouteChange = ( ) => {
26
+ const jsonLdId = 'postJsonLd'
27
+ const jsonLd = document . getElementById ( jsonLdId )
28
+ if ( jsonLd ) {
29
+ jsonLd . parentNode ?. removeChild ( jsonLd )
30
+ }
31
+ }
23
32
}
24
33
}
Original file line number Diff line number Diff line change
1
+ # 2024-04-16
2
+
3
+ ### Features
4
+
5
+ - add JSON-LD for SEO
6
+
1
7
# 2024-03-26
2
8
3
9
### Features
Original file line number Diff line number Diff line change 1
1
![ ] ( https://img.shields.io/github/license/laplacetw/vitepress-theme-trigger )
2
2
![ Node.js >= 18.0.0] ( https://img.shields.io/badge/Node.js-%3E%3D18.0.0-green )
3
- ![ VitePress 1.0.1 ] ( https://img.shields.io/badge/VitePress-1.0.1 -green )
3
+ ![ VitePress 1.1.0 ] ( https://img.shields.io/badge/VitePress-1.1.0 -green )
4
4
5
5
# vitepress-theme-trigger
6
6
Blog theme for [ VitePress] ( https://vitepress.dev ) with [ Tailwind CSS] ( https://tailwindcss.com ) .
Original file line number Diff line number Diff line change 1
1
![ ] ( https://img.shields.io/github/license/laplacetw/vitepress-theme-trigger )
2
2
![ Node.js >= 18.0.0] ( https://img.shields.io/badge/Node.js-%3E%3D18.0.0-green )
3
- ![ VitePress 1.0.1 ] ( https://img.shields.io/badge/VitePress-1.0.1 -green )
3
+ ![ VitePress 1.1.0 ] ( https://img.shields.io/badge/VitePress-1.1.0 -green )
4
4
5
5
# vitepress-theme-trigger
6
6
為建立部落格而生的 [ VitePress] ( https://vitepress.dev ) + [ Tailwind CSS] ( https://tailwindcss.com ) 主題
Original file line number Diff line number Diff line change 19
19
},
20
20
"devDependencies" : {
21
21
"@heroicons/vue" : " ^2.0.18" ,
22
- "autoprefixer" : " ^10.4.15 " ,
22
+ "autoprefixer" : " ^10.4.16 " ,
23
23
"markdown-it-footnote" : " ^4.0.0" ,
24
24
"markdown-it-mathjax3" : " ^4.3.2" ,
25
25
"postcss" : " 8.4.35" ,
26
26
"tailwindcss" : " ^3.3.3" ,
27
- "typescript" : " ^5.1.6 " ,
28
- "vitepress" : " 1.0.1 " ,
27
+ "typescript" : " ^5.2.2 " ,
28
+ "vitepress" : " 1.1.0 " ,
29
29
"vue" : " ^3.3.4"
30
30
}
31
31
}
You can’t perform that action at this time.
0 commit comments