XPoet / hexo-theme-keep

:rainbow: A simple and light theme for Hexo. It makes you more focused on writing.
https://xpoet.cn
GNU Affero General Public License v3.0
1.35k stars 183 forks source link

主题颜色自动切回白昼模式 | The mode changes to light automatically #339

Closed carrieeex closed 4 months ago

carrieeex commented 4 months ago

Issue Checklist | Issue 检查清单

Expected behavior | 预期行为

如果在网站选择黑夜模式,那就一直维持,直到换回白昼模式。反之亦然。

The mode should not change until the user changes it.

Actual behavior | 实际行为

Steps to reproduce the behavior | 重现步骤

  1. First step ... (第一步 ...) 点开任意页面,比如:https://carrieeex.github.io/2022/02/20/hello-world/
  2. Second step ... (第二步 ...) 切换成黑夜模式
  3. Third step ... (第三步 ...) 随便点到另一个页面,比如主页,他就自动切回白昼模式了

Node.js and NPM Information | Node.js 和 NPM 信息

v22.4.0
10.8.1

Hexo Configuration | Hexo 配置

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Jiali's Archive
subtitle: A Collection of My World
description: Explore Jiali's travel blogs, handpan passion, and website collections.
keywords: [acoustics, handpan, travel, blog]
author: Jiali Cheng
language:
- en
- zh-CN
timezone: Europe/Stockholm #''

# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: https://carrieeex.github.io/
permalink: :year/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: false # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: true
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false
prismjs:
  enable: false
  preprocess: true
  line_number: true
  tab_replace: ''

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## updated_option supports 'mtime', 'date', 'empty'
updated_option: 'mtime'

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: keep

# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
  type: ''

# Feed Atom
# npm install hexo-generator-feed
feed:
  type: atom
  path: atom.xml
  limit: 20

mathjax:
  tags: none               # or 'ams' or 'all'
  single_dollars: true     # enable single dollar signs as in-line math delimiters
  cjk_width: 0.9           # relative CJK char width
  normal_width: 0.6        # relative normal (monospace) width
  append_css: true         # add CSS to every page
  every_page: false        # if true, every page will be rendered by mathjax regardless the `mathjax` setting in Front-matter of each article

Keep Configuration | Keep 配置

## ======================================================================================
## Hexo Theme Keep
## Documents: https://keep-docs.xpoet.cn
## Repository: https://github.com/XPoet/hexo-theme-keep
## ======================================================================================

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/base_info.html
# ---------------------------------------------------------------------------------------
base_info:
  # Theme primary color
  primary_color: "#0066cc"

  # Blog website title
  title: Jiali's Archive

  # Blog website author name
  author: Jiali Cheng

  # Author avatar, You can use local image path or image link
  avatar: /images/asian-svgrepo-com.svg

  # Website LOGO, You can use local image path or image link
  logo: /images/cardiogram-pulse-svgrepo-com.svg

  # Website favicon, You can use local image path or image link
  favicon: /images/heart-pulse.svg

  # Light / Dark
  mode: light # Option values: light | dark

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/menu.html
# ---------------------------------------------------------------------------------------
# If you want to enable a new navigation menu, you need to create a corresponding page
# e.g. to enable categories, you need to execute `hexo new page categories`
# Use `||` to set icon for navigation menu, e.g. `home: / || fa-solid fa-home`
menu:
  home: /                        || fa-solid fa-home
  archives: /archives            || fa-solid fa-box-archive
  tags: /tags                    || fa-solid fa-tags
  categories: /categories        || fa-solid fa-layer-group
  # links: /links               # || fa-solid fa-link
  # photos: /photos             # || fa-solid fa-image
  # tools: /tools               # || fa-solid fa-tools
  about: /about                  || fa-solid fa-user-graduate
  中文: https://carrieeex.github.io/zh-CN      || fa-solid fa-language # 中文站点
  # ......

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/first_screen.html
# ---------------------------------------------------------------------------------------
first_screen:
  enable: true  # Option values: true | false

  # First screen background image in light mode, You can use local image path or image link
  background_img: /images/Beijing_day.jpeg

  # First screen background image in dark mode, You can use local image path or image link
  background_img_dark: /images/mtl_night.JPG

  # First screen description
  # You can use the "||" to begin a newline, maximum is two lines.
  description: 我的小世界 || Explore Jiali's travel blogs, handpan passion, and website collections.

  # If enable hitokoto, first screen description is different every time when you enter the website
  hitokoto: false      # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/social_contact.html
# ---------------------------------------------------------------------------------------
social_contact:
  enable: true      # Option values: true | false
  links:
    # Fill in your social platform links here, e.g. `github: https://github.com/XPoet`
    # If you want to click open the picture, you need to add a prefix `img | `,
    # at the same time change your link to the image link.
    # e.g. `weixin: img | ./images/qrcode.png`
    github: https://github.com/carrieeex         # GitHub
    weixin:          # WeChat
    qq:              # QQ
    weibo:           # WeiBo
    zhihu:           # ZhiHu
    twitter:         # Twitter
    x:               # X
    facebook:        # Facebook
    email:  malto:carriecheng000@outlook.com         # Email

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/scroll.html
# ---------------------------------------------------------------------------------------
scroll:
  # Show progress bar in top when page scroll
  progress_bar: true  # Option values: true | false

  # Show percent when page scroll
  percent: true       # Option values: true | false

  # Hide header in top when page scroll
  hide_header: true    # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/home.html
# ---------------------------------------------------------------------------------------
home:
  # Website announcement in home page
  announcement: “If I am not for myself, who will be for me? And being only for myself, what am 'I'? And if not now, when?”

  # Show category in home page post block
  category: true           # Option values: true | false

  # Show tags in home page post block
  tag: true                # Option values: true | false

  # Set the datetime type of home page post block
  post_datetime: created    # Option values: updated | created

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/post.html
# ---------------------------------------------------------------------------------------
post:
  # Author badge in the post
  author_badge:
    enable: true         # Option values: true | false

    # If true, show Lv1, Lv2, Lv3 ...
    # If false, show custom badge
    level_badge: true    # Option values: true | false

    # Custom badge array, You can be fill one or more item
    custom_badge: ["One", "Two", "Three"]

  # Post word count
  # Depend on Hexo Plugin: hexo-wordcount (`npm install hexo-wordcount`)
  # See: https://github.com/willin/hexo-wordcount
  word_count:
    wordcount: true     # Word count, one post. Option values: true | false
    min2read: true      # Time to read, one post. Option values: true | false

  # Post datetime
  datetime_format: "YYYY-MM-DD HH:mm:ss"  # Datetime format. e.g. "YYYY-MM-DD HH:mm:ss"

  # Post copyright info
  copyright_info: true  # Option values: true | false

  # Post share
  share: true           # Option values: true | false

  # Reward author
  reward:
    enable: true        # Option values: true | false
    img_link: /images/reward_all.png           # Image link for the payment QR code
    text: 请我喝杯茶吧~ Buy me a drink?          # Custom reward text, Can be null

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/code_block.html
# ---------------------------------------------------------------------------------------
code_block:
  # Toolbar include: "code copy", "code block collapse" and "code language"
  tools:
    enable: true            # Option values: true | false
    style: default           # Option values: default | mac
  highlight_theme: default   # Option values: default | obsidian

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/toc.html
# ---------------------------------------------------------------------------------------
toc:
  enable: true      # Option values: true | false

  # Automatically add list number to toc
  number: false      # Option values: true | false

  # If true, all level of TOC in a post will be displayed, rather than the activated part of it.
  expand_all: true  # Option values: true | false

  # If true, auto open TOC every time when you enter post page
  init_open: true    # Option values: true | false

  # TOC layout on post page
  layout: right      # Option values: left | right

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/website_count.html
# ---------------------------------------------------------------------------------------
website_count:
  # busuanzi
  # See: http://ibruce.info/2015/04/04/busuanzi/
  busuanzi_count:
    enable: true     # Option values: true | false
    site_uv: true    # Option values: true | false
    site_pv: true    # Option values: true | false
    page_pv: true    # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/local_search.html
# Depend on Hexo Plugin: hexo-generator-searchdb (`npm install hexo-generator-searchdb`)
# See: https://github.com/theme-next/hexo-generator-searchdb
# ---------------------------------------------------------------------------------------
local_search:
  enable: true   # Option values: true | false
  preload: true  # Preload the search data when the page loads. Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/comment.html
# ---------------------------------------------------------------------------------------
comment:
  enable: true   # Option values: true | false
  use: twikoo     # Option values: valine | gitalk | twikoo | waline | giscus | artalk | disqus

  # Valine
  # See: https://github.com/xCss/Valine
  #      https://valine.js.org
  valine:
    appid: 1eqDwMsoQ0Pk7rWk8WZ9wzLj-MdYXbMMI          # Your leancloud application appid
    appkey: YB2oQwHgThr84gupBHB01D5h          # Your leancloud application appkey
    server_urls:     # Your Server URL
    placeholder: 给我的文章加点评论吧~ Feel free to leave any comments :)    # Input box placeholder

  # Gitalk
  # See: https://github.com/gitalk/gitalk
  #      https://gitalk.github.io
  gitalk:
    github_id:        # GitHub repo owner
    github_admins:    # GitHub Admins (in Array type), optional
    repository:       # Repository name to store issues
    client_id:        # GitHub Application Client ID
    client_secret:    # GitHub Application Client Secret
    proxy:            # GitHub oauth request reverse proxy for CORS

  # Twikoo
  # See: https://github.com/imaegoo/twikoo
  #      https://twikoo.js.org
  twikoo:
    env_id: https://twikoo-netlify-try.netlify.app/.netlify/functions/twikoo         # Environment ID
    region:          # Environment region, Can be null
    version: 1.6.36  # Twikoo version, default use v1.6.36
    lang: en

  # Waline
  # See: https://github.com/walinejs/waline
  #      https://waline.js.org/guide/get-started.html
  waline:
    server_url: https://waline-test-taupe.vercel.app/        # Server URL
    reaction: false     # Post reactions, Option values: true | false
    version: 3.2.6      # Waline version, default use v3
    options:
      lang: en

  # Giscus
  # See: https://github.com/giscus/giscus
  #      https://giscus.app
  # Please generate your configuration items in https://giscus.app
  giscus:
    repo:
    repo_id:
    category: Announcements    # Recommend use Announcements
    category_id:
    reactions_enabled: false   # Option values: true | false

  # Artalk
  # See: https://github.com/ArtalkJS/Artalk
  #      https://artalk.js.org
  artalk:
    server:                    # Server URL

  # Disqus
  # See: https://disqus.com/
  disqus:
    shortname:                 # Disqus Shortname

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/rss.html
# Depend on Hexo Plugin: hexo-generator-feed (`npm install hexo-generator-feed`)
# See: https://github.com/hexojs/hexo-generator-feed
# ---------------------------------------------------------------------------------------
rss:
  enable: true  # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/lazyload.html
# ---------------------------------------------------------------------------------------
lazyload:
  enable: true  # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/cdn.html
# ---------------------------------------------------------------------------------------
cdn:
  enable: false       # Option values: true | false
  provider: cdnjs     # Option values: cdnjs | jsdelivr | unpkg

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/pjax.html
# ---------------------------------------------------------------------------------------
pjax:
  enable: true  # Option values: true | false

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/footer.html
# ---------------------------------------------------------------------------------------
footer:
  since: 2022           # The starting year of your website, Can be null
  word_count: false     # Option values: true | false

  site_deploy:
    enable: false        # Option values: true | false
    provider: github     # Option values: github | vercel | netlify | cloudflare | gitee | aliyun | tencent_cloud | upyun
    url:                 # Your deployment provider url, Can be null

  record:
    enable: false        # Option values: true | false
    list:
      - code:            # record code of your website
        link:            # record link of your website, Can be null
      # e.g.
      # - code: ICP 001
      # - link: https://beian.miit.gov.cn

# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/inject.html
# ---------------------------------------------------------------------------------------
inject:
  enable: true  # Option values: true | false
  css:
    - /css/timeline.css
    - /css/announcement.css
      # e.g.
      # - /css/custom-1.css
      # - /css/custom-2.css
    # - ...
  js:
    - 
      # e.g.
      # - /js/custom-1.js
      # - /js/custom-2.js
    # - ...

Other Information | 其它信息

safari & chrome, Mac OS.

carrieeex commented 4 months ago

其他:另外我在keep.yml的评论-twikoo里想加上选项lang换语言。请问能不能在主题的源代码(twikoo.ejs?)里面加上这个选项哇?谢谢!(我要不要开过一个issue?)

XPoet commented 4 months ago

因为你在 Keep 主题的配置文件里面,增加了 mode: light,第一次进入博客或者切换页面都会回到初始设置的 mode

XPoet commented 4 months ago

其他:另外我在keep.yml的评论-twikoo里想加上选项lang换语言。请问能不能在主题的源代码(twikoo.ejs?)里面加上这个选项哇?谢谢!(我要不要开过一个issue?)

twikoo 评论插件的 language 继承于 hexo 配置文件中的 language,无需额外设置。

carrieeex commented 4 months ago

其他:另外我在keep.yml的评论-twikoo里想加上选项lang换语言。请问能不能在主题的源代码(twikoo.ejs?)里面加上这个选项哇?谢谢!(我要不要开过一个issue?)

twikoo 评论插件的 language 继承于 hexo 配置文件中的 language,无需额外设置。

但是我英文网站的评论还是中文的。。。我不知道为什么😢

Screenshot 2024-07-09 at 4 03 54 AM
carrieeex commented 4 months ago

因为你在 Keep 主题的配置文件里面,增加了 mode: light,第一次进入博客或者切换页面都会回到初始设置的 mode

噢噢原来如此。好的。我会错意了😄 我以为这个只适用于第一次进入博客。可以在文档那里加一个说明吗?谢谢😊

XPoet commented 4 months ago

该 Issue 反馈的问题已完善,文档已更新,请使用最新版本 v4.2.0