diff --git a/.env.example b/.env.example index 39835169..4655d8dd 100644 --- a/.env.example +++ b/.env.example @@ -21,3 +21,4 @@ TELEGRAM_HOST=telegram.dog STATIC_PROXY="" GOOGLE_SEARCH_SITE="" TAGS="" +COMMENTS="" \ No newline at end of file diff --git a/README.md b/README.md index 9c8d7131..23faf50c 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,9 @@ GOOGLE_SEARCH_SITE=memo.miantiao.me ## Enable tags page, separate tags with commas TAGS=tag1,tag2,tag3 + +## Show comments +COMMENTS=true ``` ## 🙋🏻 FAQs diff --git a/README.zh-cn.md b/README.zh-cn.md index ffb3895f..ecef902e 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -121,6 +121,9 @@ GOOGLE_SEARCH_SITE=memo.miantiao.me ## 启用标签页, 标签使用英文逗号分割 TAGS=标签A,标签B,标签C + +## 展示评论 +COMMENTS=true ``` ## 🙋🏻 常问问题 diff --git a/src/components/item.astro b/src/components/item.astro index e1d6bf72..4f722bc8 100644 --- a/src/components/item.astro +++ b/src/components/item.astro @@ -9,7 +9,10 @@ const timezone = getEnv(import.meta.env, Astro, 'TIMEZONE') locale && dayjs.locale(locale) const { SITE_URL } = Astro.locals -const { post } = Astro.props +const { post, isItem } = Astro.props + +const channel = getEnv(import.meta.env, Astro, 'CHANNEL') +const COMMENTS = getEnv(import.meta.env, Astro, 'COMMENTS') const datetime = dayjs(post.datetime).tz(timezone) const timeago = datetime.isBefore(dayjs().subtract(1, 'w')) ? datetime.format('HH:mm · ll · ddd') : datetime.fromNow() @@ -37,4 +40,20 @@ const timeago = datetime.isBefore(dayjs().subtract(1, 'w')) ? datetime.format('H ) } + + { + COMMENTS && isItem && ( +