1- import { h , watch } from 'vue'
1+ import { h , watch , toRefs } from 'vue'
2+ import { useData , useRoute } from 'vitepress' ;
23import DefaultTheme from 'vitepress/theme'
3- import Comment from './Comment.vue'
44import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
5+ import giscusTalk from 'vitepress-plugin-comment-with-giscus' ;
56import googleAnalytics from 'vitepress-plugin-google-analytics'
67
7- import { useData , useRoute , useRouter } from 'vitepress' ;
8-
98import './style.css'
109import "vitepress-markdown-timeline/dist/theme/index.css" ;
1110
@@ -20,37 +19,35 @@ export default {
2019 } )
2120 } ,
2221 Layout ( ) {
23- const { isDark } = useData ( ) ;
24- const route = useRoute ( ) ;
25- const router = useRouter ( ) ;
26-
27- if ( process . env . NODE_ENV === 'production' ) {
28- watch ( route , ( path ) => {
29- const el = document . querySelector ( 'giscus-widget' ) ;
30- if ( el ) {
31- el . update ( ) ;
32- }
33-
34- if ( window . gtag ) {
35- gtag ( 'send' , 'pageview' , path ) ;
36- }
37- } , { immediate : true } ) ;
38-
39- watch ( isDark , ( dark ) => {
40- const el = document . querySelector ( 'giscus-widget' ) ;
41- if ( el ) {
42- el . theme = dark ? 'transparent_dark' : 'light' ;
43- }
44- } ) ;
45-
46- return h ( DefaultTheme . Layout , null , {
47- 'doc-footer-before' : ( ) => h ( Comment , { theme : isDark . value ? 'transparent_dark' : 'light' } )
48- } )
49- }
50-
5122 return h ( DefaultTheme . Layout , null , {
52- 'doc-footer-before' : ( ) => h ( 'p' , { style : 'text-align: center; font-size: 0.625rem;' } , [ '댓글 출력 위치. (docs:dev 환경에서는 댓글을 출력하지 않음)' ] )
5323 } ) ;
24+ } ,
25+ setup ( ) {
26+ // Get frontmatter and route
27+ const { frontmatter } = toRefs ( useData ( ) ) ;
28+ const route = useRoute ( ) ;
29+
30+ // Obtain configuration from: https://giscus.app/
31+ giscusTalk ( {
32+ repo : 'g5guide/g5guide.github.io' ,
33+ repoId : 'R_kgDOJ55vGA' ,
34+ category : 'Comments' , // default: `General`
35+ categoryId : 'DIC_kwDOJ55vGM4CX0n5' ,
36+ mapping : 'pathname' , // default: `pathname`
37+ inputPosition : 'top' , // default: `top`
38+ lang : 'ko' , // default: `zh-CN`
39+ lightTheme : 'light' , // default: `light`
40+ darkTheme : 'transparent_dark' , // default: `transparent_dark`
41+ // ...
42+ } , {
43+ frontmatter, route
44+ } ,
45+ // Whether to activate the comment area on all pages.
46+ // The default is true, which means enabled, this parameter can be ignored;
47+ // If it is false, it means it is not enabled.
48+ // You can use `comment: true` preface to enable it separately on the page.
49+ true
50+ ) ;
5451 }
5552}
5653
0 commit comments