vitepress-plugin-comment-with-giscus
Advanced tools
Comparing version 1.1.14 to 1.1.15
@@ -13,2 +13,4 @@ import { AvailableLanguage } from '@giscus/vue'; | ||
lang?: AvailableLanguage; | ||
locales?: Record<string, string>; | ||
homePageShowComment?: boolean; | ||
}; | ||
@@ -15,0 +17,0 @@ /** |
@@ -22,4 +22,16 @@ import giscus from '@giscus/vue'; | ||
repo: 'xxx/xxx', | ||
repoId: '' | ||
repoId: '', | ||
homePageShowComment: false | ||
}; | ||
// console.log('locales --> ', props.locales); | ||
// Set the default language | ||
// 设置默认语言 | ||
if (props.locales) { | ||
const element = document.querySelector('html'); | ||
const lang = element.getAttribute('lang'); | ||
// console.log('lang --> ', lang); | ||
if (lang && props.locales[lang]) { | ||
props.lang = props.locales[lang]; | ||
} | ||
} | ||
const lightTheme = props.lightTheme || 'light'; | ||
@@ -45,5 +57,5 @@ const darkTheme = props.darkTheme || 'transparent_dark'; | ||
} | ||
// If it is the homepage, do not add it | ||
// 如果是首页,则不添加 | ||
if (!location.pathname || location.pathname === '/') { | ||
// Whether to display comments on the homepage | ||
// 首页是否显示评论 | ||
if (!props.homePageShowComment && (!location.pathname || location.pathname === '/')) { | ||
return; | ||
@@ -50,0 +62,0 @@ } |
@@ -14,3 +14,5 @@ import giscus, { AvailableLanguage } from '@giscus/vue'; | ||
darkTheme?: string, | ||
lang?: AvailableLanguage | ||
lang?: AvailableLanguage, | ||
locales?: Record<string, string>, | ||
homePageShowComment?: boolean | ||
} | ||
@@ -37,4 +39,19 @@ | ||
repo: 'xxx/xxx', | ||
repoId: '' | ||
repoId: '', | ||
homePageShowComment: false | ||
}; | ||
// console.log('locales --> ', props.locales); | ||
// Set the default language | ||
// 设置默认语言 | ||
if (props.locales) { | ||
const element: HTMLElement | Node | null = document.querySelector('html'); | ||
const lang = (element as HTMLElement).getAttribute('lang'); | ||
// console.log('lang --> ', lang); | ||
if (lang && props.locales[lang]) { | ||
props.lang = props.locales[lang]; | ||
} | ||
} | ||
const lightTheme = props.lightTheme || 'light'; | ||
@@ -59,5 +76,5 @@ const darkTheme = props.darkTheme || 'transparent_dark'; | ||
} | ||
// If it is the homepage, do not add it | ||
// 如果是首页,则不添加 | ||
if (!location.pathname || location.pathname === '/') { | ||
// Whether to display comments on the homepage | ||
// 首页是否显示评论 | ||
if (!props.homePageShowComment &&(!location.pathname || location.pathname === '/')) { | ||
return; | ||
@@ -64,0 +81,0 @@ } |
{ | ||
"name": "vitepress-plugin-comment-with-giscus", | ||
"version": "1.1.14", | ||
"version": "1.1.15", | ||
"description": "vitepress comment plugin based on giscus", | ||
@@ -9,3 +9,4 @@ "type": "module", | ||
"scripts": { | ||
"run": "vitepress dev docs" | ||
"run": "vitepress dev docs", | ||
"build": "vitepress build docs" | ||
}, | ||
@@ -12,0 +13,0 @@ "files": [ |
@@ -50,2 +50,10 @@ # vitepress-plugin-comment-with-giscus | ||
lang: 'en', // default: `zh-CN` | ||
// i18n setting (Note: This configuration will override the default language set by lang) | ||
// Configured as an object with key-value pairs inside: | ||
// [your i18n configuration name]: [corresponds to the language pack name in Giscus] | ||
locales: { | ||
'zh-Hans': 'zh-CN', | ||
'en-US': 'en' | ||
}, | ||
homePageShowComment: false, // Whether to display the comment area on the homepage, the default is false | ||
lightTheme: 'light', // default: `light` | ||
@@ -91,6 +99,10 @@ darkTheme: 'transparent_dark', // default: `transparent_dark` | ||
<details> | ||
<details open> | ||
<summary>change log</summary> | ||
<ul> | ||
<li> | ||
<p>v1.1.15</p> | ||
<p>new i18n setting</p> | ||
</li> | ||
<li> | ||
<p>v1.1.10</p> | ||
@@ -97,0 +109,0 @@ <p>Now customizable day/night themes</p> |
15879
282
120