diff --git a/components/Artalk.js b/components/Artalk.js
index e44edaab..c7ac5441 100644
--- a/components/Artalk.js
+++ b/components/Artalk.js
@@ -20,18 +20,32 @@ const Artalk = ({ siteInfo }) => {
const initArtalk = async () => {
await loadExternalResource(artalkCss, 'css')
- window?.Artalk?.init({
- server: artalkServer, // 后端地址
- el: '#artalk', // 容器元素
+ const artalk = window?.Artalk?.init({
+ server: artalkServer,
+ el: '#artalk',
locale: artalkLocale,
- // pageKey: '/post/1', // 固定链接 (留空自动获取)
- // pageTitle: '关于引入 Artalk 的这档子事', // 页面标题 (留空自动获取)
- site: site // 你的站点名
+ site: site,
+ darkMode: document.documentElement.classList.contains('dark')
})
+
+ const observer = new MutationObserver((mutations) => {
+ mutations.forEach((mutation) => {
+ if (mutation.attributeName === 'class') {
+ const isDark = document.documentElement.classList.contains('dark')
+ artalk?.setDarkMode(isDark)
+ }
+ })
+ })
+
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ['class']
+ })
+
+ return () => observer.disconnect()
}
- return (
-
- )
+
+ return
}
export default Artalk
diff --git a/lib/notion/getNotionConfig.js b/lib/notion/getNotionConfig.js
index 9a8c5072..029c7b96 100644
--- a/lib/notion/getNotionConfig.js
+++ b/lib/notion/getNotionConfig.js
@@ -157,18 +157,24 @@ export async function getConfigMapFromConfigPage(allPages) {
// 只导入生效的配置
if (config.enable) {
// console.log('[Notion配置]', config.key, config.value)
- notionConfig[config.key] = config.value || null
+ notionConfig[config.key] =
+ parseTextToJson(config.value) || config.value || null
// 配置不能是undefined,至少是null
}
}
}
- // 最后检查Notion_Config页面的INLINE_CONFIG,是否是一个js对象
- const combine = Object.assign(
- {},
- deepClone(notionConfig),
- parseConfig(notionConfig?.INLINE_CONFIG)
- )
+ let combine = notionConfig
+ try {
+ // 将INLINE_CONFIG合并,@see https://docs.tangly1024.com/article/notion-next-inline-config
+ combine = Object.assign(
+ {},
+ deepClone(notionConfig),
+ notionConfig?.INLINE_CONFIG
+ )
+ } catch (err) {
+ console.warn('解析 INLINE_CONFIG 配置时出错,请检查JSON格式', err)
+ }
return combine
}
@@ -187,7 +193,23 @@ export function parseConfig(configString) {
const config = eval('(' + configString + ')')
return config
} catch (evalError) {
- console.error('解析 eval(INLINE_CONFIG) 配置时出错:', evalError)
+ console.warn(
+ '解析 eval(INLINE_CONFIG) 配置时出错,请检查JSON格式',
+ evalError
+ )
return {}
}
}
+
+/**
+ * 解析文本为JSON
+ * @param text
+ * @returns {any|null}
+ */
+export function parseTextToJson(text) {
+ try {
+ return JSON.parse(text)
+ } catch (error) {
+ return null
+ }
+}
diff --git a/themes/heo/components/AnalyticsCard.js b/themes/heo/components/AnalyticsCard.js
index 835f4900..a6c17e88 100644
--- a/themes/heo/components/AnalyticsCard.js
+++ b/themes/heo/components/AnalyticsCard.js
@@ -11,31 +11,35 @@ export function AnalyticsCard(props) {
const today = new Date()
const diffTime = today.getTime() - targetDate.getTime() // 获取两个日期之间的毫秒数差值
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) // 将毫秒数差值转换为天数差值
+ const postCountTitle = siteConfig('HEO_POST_COUNT_TITLE', null, CONFIG)
+ const siteTimeTitle = siteConfig('HEO_SITE_TIME_TITLE', null, CONFIG)
+ const siteVisitTitle = siteConfig('HEO_SITE_VISIT_TITLE', null, CONFIG)
+ const siteVisitorTitle = siteConfig('HEO_SITE_VISITOR_TITLE', null, CONFIG)
const { postCount } = props
return <>
-
文章数:
+
{postCountTitle}
{postCount}
-
建站天数:
+
{siteTimeTitle}
{diffDays} 天
-
访问量:
+
{siteVisitTitle}
-
访客数:
+
{siteVisitorTitle}
diff --git a/themes/heo/config.js b/themes/heo/config.js
index bd0353c3..4a037982 100644
--- a/themes/heo/config.js
+++ b/themes/heo/config.js
@@ -122,6 +122,12 @@ const CONFIG = {
HEO_SOCIAL_CARD_TITLE_3: '点击加入社群',
HEO_SOCIAL_CARD_URL: 'https://docs.tangly1024.com/article/how-to-question',
+ // 底部统计面板文案
+ HEO_POST_COUNT_TITLE: '文章数:',
+ HEO_SITE_TIME_TITLE: '建站天数:',
+ HEO_SITE_VISIT_TITLE: '访问量:',
+ HEO_SITE_VISITOR_TITLE: '访客数:',
+
// ***** 以下配置无效,只是预留开发 ****
// 菜单配置
HEO_MENU_INDEX: true, // 显示首页
diff --git a/themes/starter/components/About.js b/themes/starter/components/About.js
index db1192e9..794349d3 100644
--- a/themes/starter/components/About.js
+++ b/themes/starter/components/About.js
@@ -1,6 +1,7 @@
/* eslint-disable @next/next/no-img-element */
/* eslint-disable react/no-unescaped-entities */
import { siteConfig } from '@/lib/config'
+import Link from 'next/link'
/**
* 首页的关于模块
@@ -27,11 +28,11 @@ export const About = () => {
__html: siteConfig('STARTER_ABOUT_TEXT')
}}>
-
{siteConfig('STARTER_ABOUT_BUTTON_TEXT')}
-
+
diff --git a/themes/starter/components/CTA.js b/themes/starter/components/CTA.js
index a0797a76..643a0d48 100644
--- a/themes/starter/components/CTA.js
+++ b/themes/starter/components/CTA.js
@@ -1,4 +1,5 @@
import { siteConfig } from '@/lib/config'
+import Link from 'next/link'
/**
* CTA,用于创建一个呼吁用户行动的部分(Call To Action,简称 CTA)。
@@ -29,11 +30,11 @@ export const CTA = () => {
{siteConfig('STARTER_CTA_BUTTON') && (
<>
-
{siteConfig('STARTER_CTA_BUTTON_TEXT')}
-
+
>
)}
diff --git a/themes/starter/components/Features.js b/themes/starter/components/Features.js
index ed2e63a3..bc869049 100644
--- a/themes/starter/components/Features.js
+++ b/themes/starter/components/Features.js
@@ -3,6 +3,7 @@ import { SVGDesign } from './svg/SVGDesign'
import { SVGEssential } from './svg/SVGEssential'
import { SVGGifts } from './svg/SVGGifts'
import { SVGTemplate } from './svg/SVGTemplate'
+import Link from 'next/link'
/**
* 产品特性相关,将显示在首页中
* @returns
@@ -41,11 +42,11 @@ export const Features = () => {
{siteConfig('STARTER_FEATURE_1_TEXT_1')}
-
{siteConfig('STARTER_FEATURE_1_BUTTON_TEXT')}
-
+
diff --git a/themes/starter/components/Footer.js b/themes/starter/components/Footer.js
index ab145c0b..efcc24cb 100644
--- a/themes/starter/components/Footer.js
+++ b/themes/starter/components/Footer.js
@@ -2,6 +2,7 @@ import { siteConfig } from '@/lib/config'
import SocialButton from '@/themes/fukasawa/components/SocialButton'
import { Logo } from './Logo'
import { SVGFooterCircleBG } from './svg/SVGFooterCircleBG'
+import Link from 'next/link'
/* eslint-disable @next/next/no-img-element */
export const Footer = props => {
@@ -48,11 +49,11 @@ export const Footer = props => {
{item?.LINK_GROUP?.map((l, i) => {
return (
-
{l.TITLE}
-
+
)
})}
@@ -72,7 +73,7 @@ export const Footer = props => {
@@ -104,27 +105,27 @@ export const Footer = props => {
diff --git a/themes/starter/components/Header.js b/themes/starter/components/Header.js
index 7eccdc15..0875062e 100644
--- a/themes/starter/components/Header.js
+++ b/themes/starter/components/Header.js
@@ -75,12 +75,12 @@ export const Header = props => {
{siteConfig('STARTER_NAV_BUTTON_1_TEXT')}
{siteConfig('STARTER_NAV_BUTTON_2_TEXT')}
@@ -94,16 +94,16 @@ export const Header = props => {
)}
{!enableClerk && (
)}
diff --git a/themes/starter/components/Hero.js b/themes/starter/components/Hero.js
index 9223a534..42f124ac 100644
--- a/themes/starter/components/Hero.js
+++ b/themes/starter/components/Hero.js
@@ -2,6 +2,7 @@
import LazyImage from '@/components/LazyImage'
import { siteConfig } from '@/lib/config'
import CONFIG from '../config'
+import Link from 'next/link'
/**
* 英雄大图区块
@@ -32,16 +33,16 @@ export const Hero = props => {
diff --git a/themes/starter/components/Pricing.js b/themes/starter/components/Pricing.js
index 5728f703..2519612d 100644
--- a/themes/starter/components/Pricing.js
+++ b/themes/starter/components/Pricing.js
@@ -1,4 +1,5 @@
import { siteConfig } from '@/lib/config'
+import Link from 'next/link'
/**
* 价格板块
@@ -65,11 +66,11 @@ export const Pricing = () => {
})}
-
{siteConfig('STARTER_PRICING_1_BUTTON_TEXT')}
-
+
@@ -117,11 +118,11 @@ export const Pricing = () => {
})}
-
{siteConfig('STARTER_PRICING_2_BUTTON_TEXT')}
-
+
@@ -161,11 +162,11 @@ export const Pricing = () => {
})}
-
{siteConfig('STARTER_PRICING_3_BUTTON_TEXT')}
-
+