EvanNotFound / hexo-theme-redefine

Simplicity in Speed, Purity in Design. Redefine Your Hexo Journey.
https://redefine.ohevan.com
GNU General Public License v3.0
1.38k stars 112 forks source link

[BUG] Waline的serverURL没有被成功应用 #193

Closed Astrapencil closed 11 months ago

Astrapencil commented 1 year ago

提交前检查单

Bug 描述

Waline发消息时提示我

Fail to Fetch

复现方法

添加Waline的serverURL时,已经添加了

  comment: 
    # Whether to enable comment 
    enable: true 
    # Comment system 
    system: waline
    # System configuration 
    config: 
      # Waline comment system. See https://waline.js.org/ 
      waline: 
        serverUrl: https://vercel.astralun.top
        lang: zh-CN

且该域名已经绑定vercel,可以正常访问

但在执行了hexo clean+hexo g后,我在页面中尝试发出测试消息时,提示

Fail to Fetch

在我查找问题的时候,发现开发人员工具中有这样一条报错

网页在向一个错误的示例网站请求

于是我去查找public文件夹,在对应文件夹下找到了对应index.html文件,VSC搜索serverurl字段,发现在Waline文档提供的JS中(我看不懂),应该修改的serverURL的值是https://example.example.com

示例

<div class="comment-container">
    <div class="comments-container">
        <div id="comment-anchor">
        </div>
    <div class="comment-area-title">
    <i class="fa-solid fa-comments">
    </i>
    &nbsp;评论</div>
    <div id="waline">
    </div>
    <script type="module" data-pjax>import{init}from"https://evan.beee.top/js/waline.mjs";function loadWaline(){init({el:"#waline",serverURL:"https://example.example.com",lang:"zh-CN",dark:'body[class~="dark-mode"]',requiredMeta:["nick","mail"]})}{const e=setTimeout(()=>{loadWaline(),clearTimeout(e)},1e3)}
    </script>
</div>

直接修改值为自己的serverURL,再在本地直接用浏览器打开,在CSS全都无法应用的情况下直接在Edge中打开,则可以正常发送。

电脑:

config.redefine.yml全文

# BASIC INFORMATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
info:
  # Site title
  title: ****
  # Author name
  author: *
  # Site URL
  url: https://astralun.top
# BASIC INFORMATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# IMAGE CONFIGURATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
defaults:
  # Favicon
  favicon: https://pic.imgdb.cn/item/64c37**********7cc3bae4d.png # /images/redefine-favicon.svg
  # Site logo
  logo: https://pic.imgdb.cn/item/64c37cbc1d**********ae4d.png
  # Site avatar
  avatar: https://pic.imgdb.cn/item/64c37**********7cc261ac0.jpg
# IMAGE CONFIGURATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# COLORS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
colors:
  #Primary color
  primary: "#91fa8c" # "#A31F34"
  # Secondary color (beta)
  secondary: 
# COLORS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# SITE CUSTOMIZATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
global:
  # Custom fonts
  fonts:
    # Chinese fonts
    chinese: 
      enable: false # Whether to enable custom chinese font
      family:  # Font family
      url:  # Font URL to CSS file
    # English fonts
    english: 
      enable: true # Whether to enable custom chinese font
      family: TN-Roman # Font family
      url: /css/fonts.css # Font URL to CSS file
  # Content max width
  content_max_width: 1000px
  # Sidebar width
  sidebar_width: 210px
  # Effects on mouse hover
  hover:
    shadow: true # shadow effect
    scale: true # scale effect
  # Scroll progress
  scroll_progress:
    bar: true # progress bar
    percentage: false # percentage
  # Website counter (powered by https://busuanzi.ibruce.info/)
  busuanzi_counter:
    enable: true # enable website counter or not
    site_pv: true # site page view
    site_uv: true # site unique visitor
    post_pv: true # post page view
  # Whether to enable PJAX
  pjax: true
  # Whether to enable open graph
  open_graph: true
  # Google Analytics
  google_analytics:
    enable: false # Whether to enable Google Analytics
    id:  # Google Analytics Measurement ID
# SITE CUSTOMIZATION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# FONTAWESOME >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
fontawesome: # Pro v6.2.1
  # Thin version
  thin: false
  # Light version
  light: false
  # Duotone version
  duotone: false
  # Sharp Solid version
  sharp_solid: false
# FONTAWESOME <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# HOME BANNER >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
home_banner:
  # Whether to enable home banner
  enable: true
  # style of home banner
  style: fixed # static or fixed
  # Home banner image
  image: 
    light: https://pic.imgdb.cn/item/64c36**********7cc172f83.jpg # /images/wallhaven-wqery6-light.webp # light mode
    dark: https://pic.imgdb.cn/item/64c36**********7cc172f83.jpg # /images/wallhaven-wqery6-dark.webp # dark mode
  # Home banner title
  title: *****
  # Home banner subtitle
  subtitle:
    text: ["轻轻地,放慢脚步"] # subtitle text, array
    hitokoto:  # 一言配置
      enable: false # Whether to enable hitokoto
      api: https://v1.hitokoto.cn # API URL, can add types, see https://developer.hitokoto.cn/sentence/#%E5%8F%A5%E5%AD%90%E7%B1%BB%E5%9E%8B-%E5%8F%82%E6%95%B0
    typing_speed: 100 # Typing speed (ms)
    backing_speed: 80 # Backing speed (ms)
    starting_delay: 500 # Start delay (ms)
    backing_delay: 1500 # Backing delay (ms)
    loop: false # Whether to loop
    smart_backspace: true # Whether to smart backspace
  # Color of home banner text
  text_color: 
    light: "#fff" # light mode
    dark: "#d1d1b6" # dark mode
  # Specific style of the text
  text_style: 
    # Title font size
    title_size: 2.8rem
    # Subtitle font size
    subtitle_size: 1.5rem
    # Line height between title and subtitle
    line_height: 1.2
  # Home banner custom font
  custom_font: 
    # Whether to enable custom font
    enable: false
    # Font family
    family: 
    # URL to font CSS file
    url:
  # Home banner social links
  social_links:
    # Whether to enable
    enable: false
    # Social links
    links:
      github:  # your GitHub URL
      instagram: # your Instagram URL
      zhihu:  # your ZhiHu URL
      twitter:  # your twitter URL
      email:  # your email
      # ...... # you can add more
# HOME BANNER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# NAVIGATION BAR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
navbar:
  # Auto hide navbar
  auto_hide: true
  # Navbar background color
  color:
    left: "#098215" #left side 
    right: "#0ed096"  #right side
    transparency: 35 #percent (10-99)
  # Navbar links
  links:
    文章: 
      path: /archives 
      icon: fa-regular fa-archive # can be empty
    标签: 
      path: /tag 
      icon: fa-regular fa-tag # can be empty
    分类: 
      path: /category 
      icon: fa-regular fa-folder # can be empty
    # Status: 
    #   path: https://status.evanluo.top/
    #   icon: fa-regular fa-chart-bar
    # About: 
    #   icon: fa-regular fa-user
    #   submenus:
    #     Me: /about
    #     Github: https://github.com/EvanNotFound/hexo-theme-redefine
    #     Blog: https://ohevan.com
    #     Friends: /friends
    # Links: 
    #   icon: fa-regular fa-link
    #   submenus:
    #     Link1: /link1
    #     Link2: /link2
    #     Link3: /link3
    # ...... # you can add more
  # Navbar search (local search). Requires hexo-generator-searchdb (npm i hexo-generator-searchdb). See https://github.com/theme-next/hexo-generator-searchdb
  search:
    # Whether to enable
    enable: true
    # Preload search data when the page loads
    preload: true
# NAVIGATION BAR <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# HOME PAGE ARTICLE SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
home:
  # Sidebar settings
  sidebar:
    enable: true # Whether to enable sidebar
    position: left # Sidebar position. left, right
    first_item: info # First item in sidebar. menu, info
    announcement: ******** # Announcement text
    links:
      # Archives: 
      #   path: /archives 
      #   icon: fa-regular fa-archive # can be empty
      # Tags: 
      #   path: /tags 
      #   icon: fa-regular fa-tags # can be empty
      # Categories: 
      #   path: /categories 
      #   icon: fa-regular fa-folder # can be empty
      # ...... # you can add more
  # Article date format
  article_date_format: YYYY-MM-DD HH:mm:ss # auto, relative, YYYY-MM-DD, YYYY-MM-DD HH:mm:ss etc.
  # Article categories visibility
  categories:
    enable: true  # Whether to enable
    limit: 3 # Max number of categories to display
  # Article tags visibility
  tags:
    enable: true  # Whether to enable
    limit: 3  # Max number of tags to display
# HOME PAGE ARTICLE SETTINGS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# ARTICLE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
articles:
  # Set the styles of the article
  style:
    font_size: 16px # Font size
    line_height: 1.5 # Line height
    image_border_radius: 6px # image border radius
    image_alignment: center # image alignment. left, center
    image_caption: false # Whether to display image caption
    link_icon: false # Whether to display link icon
  # Word count. Requires hexo-wordcount (npm install hexo-wordcount). See https://github.com/willin/hexo-wordcount
  word_count:
    enable: true # Whether to enable
    count: true # Whether to display word count
    min2read: false # Whether to display reading time
  # Author label
  author_label: 
    enable: true # Whether to enable
    auto: false # Whether to automatically add author label, e.g. Lv1, Lv2, Lv3...
    list: []
  # Code block settings
  code_block:
    copy: true # Whether to enable code block copy button
    style: mac # mac | simple
    font: # Custom font
      enable: false # Whether to enable
      family: # Font family
      url: # Font URL to CSS file
  # Table of contents settings
  toc:
    enable: true # Whether to enable TOC
    max_depth: 3 # TOC depth
    number: false # Whether to add number to TOC automatically
    expand: true # Whether to expand TOC
    init_open: false # Open toc by default
  # Whether to enable copyright notice
  copyright: true
  # Whether to enable lazyload for images
  lazyload: true
  #########!!!!!!!!!!!!!!!!!!!!!!!!!!!########## Article recommendation. Requires nodejieba (npm install nodejieba). Transplanted from hexo-theme-volantis.
  recommendation: 
     # Whether to enable article recommendation 
     enable: false 
     # Article recommendation title 
     title: 推荐阅读 
     # Max number of articles to display 
     limit: 3 
     # Max number of articles to display mobile 
     mobile_limit: 2 
     # Placeholder image 
     placeholder: /images/wallhaven-wqery6-light.webp 
     # Skip directory 
     skip_dirs: [] 
 # ARTICLE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# COMMENT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start 
  comment: 
    # Whether to enable comment 
    enable: true 
    # Comment system 
    system: waline
    # System configuration 
    config: 
      # Waline comment system. See https://waline.js.org/ 
      waline: 
        serverUrl: https://vercel.astralun.top
        lang: zh-CN # Waline language. e.g. zh-CN, en-US. See https://waline.js.org/guide/client/i18n.html 
      # Gitalk comment system. See https://github.com/gitalk/gitalk 
      gitalk: 
        clientID: # GitHub Application Client ID 
        clientSecret: # GitHub Application Client Secret 
        repo: # GitHub repository 
        owner: # GitHub repository owner 
      # Twikoo comment system. See https://twikoo.js.org/ 
      twikoo: 
        version: 1.6.10 # Twikoo version, do not modify if you dont know what it is 
        server_url: # Twikoo server URL.
        region: # Twikoo region. can be empty 
      # Giscus comment system. See https://giscus.app/ 
      giscus: 
        repo: # Github repository name e.g. EvanNotFound/hexo-theme-redefine 
        repo_id: # Github repository id 
        category: # Github discussion category 
        category_id: # Github discussion category id 
        mapping: pathname # Which value to use as the unique identifier for the page. e.g. pathname, url, title, og:title. DO NOT USE og:title WITH PJAX ENABLED since pjax will not update og:title when the page changes 
        strict: 0 # Whether to enable strict mode. e.g. 0, 1 
        reactions_enabled: 1 # Whether to enable reactions. e.g. 0, 1 
        emit_metadata: 0 # Whether to emit metadata. e.g. 0, 1 
        lang: en # Giscus language. e.g. en, zh-CN, zh-TW 
        input_position: bottom # Place the comment box above/below the comments. e.g. top, bottom 
        loading: lazy # Load the comments lazily 

  # COMMENT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end 

# FOOTER >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
footer:
  # Show website running time
  runtime: true # show website running time or not
  # Icon in footer, write fontawesome icon code here
  icon: '<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 0.5s; color: #f54545"></i>'
  # The start time of the website, format: YYYY/MM/DD HH:mm:ss
  start: 2023/5/16 00:00:00
  # Footer message
  customize: 前面没有路了……那就还是,轻轻地,悄悄地,原路返回吧
  # ICP record number. See https://beian.miit.gov.cn/
  icp:
    enable: false # Whether to enable
    number: # ICP record number
    url: # ICP record url
# FOOTER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# INJECT here>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
inject:
  # Whether to enable inject
  enable: false
  # Inject custom head html code
  head: 
    -
    -
  # Inject custom footer html code
  footer:
    -
    -
# INJECT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# PLUGINS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
plugins:
  # RSS feed. Requires hexo-generator-feed (npm i hexo-generator-feed). See https://github.com/hexojs/hexo-generator-feed
  feed:
    enable: false # Whether to enable
  # Aplayer. See https://github.com/DIYgod/APlayer
  aplayer:
    enable: true # Whether to enable
    type: fixed # fixed, mini
    audios:
      # - name: # audio name
      #   artist: # audio artist
      #   url: # audio url
      #   cover: # audio cover url
      # .... you can add more audios here
  # Mermaid JS. Requires hexo-filter-mermaid-diagrams (npm i hexo-filter-mermaid-diagrams). See https://mermaid.js.org/
  mermaid:
    enable: false # enable mermaid or not
    version: "9.3.0" # default v9.3.0
# PLUGINS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# PAGE TEMPLATES >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start
page_templates:
  # Friend Links page column number
  friends_column: 2
  # Tags page style
  tags_style: blur # blur, cloud
# PAGE TEMPLATES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end

# CDN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start 
  cdn: 
    # Whether to enable CDN 
    enable: true 
    # CDN Provider 
    provider: elemecdn # elemecdn, jsdelivr, unpkg, aliyun, custom 
    # Custom CDN URL 
    # format example: https://cdn.custom.com/hexo-theme-redefine/${version}/source/${path} 
    # The ${path} must be in the source folder of the theme 
    custom_url:  
# CDN <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end 

谢谢!

Astrapencil commented 1 year ago

在我手动(只)修改JS中的URL后,运行Hexo d,网页的评论可以正常运行。

扩展情况 我只额外添加了hexo-fliter-mathjaxhexo-blog-encrypt扩展,但是没有文章添加mathjax: true属性(开了会报在node_modules目录下有关handler的错,应该不关主题的事,索性关掉;关掉就不报错了),只有一篇文章使用了加密。

但是public目录下所有由_post目录下文章转换来的index.html都出现了该问题……好在我现在只有四篇文章,手动改完先deploy上去了。

如果需要网页源码的话,可以直接去我博客copy。

以上,如果有帮助的话,谢谢!

EvanNotFound commented 1 year ago

你好,我访问你的博客进行评论是没问题的。是你的网络问题

Screenshot 2023-07-29 at 8 28 01 PM
Astrapencil commented 1 year ago

啊,您误解了我的意思,那是我改过的

在生成的index.html中的这个<div>标签中(上面给出过,VSC在文章的index.html检索“serverURL”就找得到)

<div class="comment-container">
    <div class="comments-container">
        <div id="comment-anchor">
        </div>
    <div class="comment-area-title">
    <i class="fa-solid fa-comments">
    </i>
    &nbsp;评论</div>
    <div id="waline">
    </div>
    <script type="module" data-pjax>import{init}from"https://evan.beee.top/js/waline.mjs";function loadWaline(){init({el:"#waline",serverURL:"https://example.example.com",lang:"zh-CN",dark:'body[class~="dark-mode"]',requiredMeta:["nick","mail"]})}{const e=setTimeout(()=>{loadWaline(),clearTimeout(e)},1e3)}
    </script>
</div>

上面这段代码就是hexo gindex.html里原来的样子

我只不过手动把

“function loadWaline(){init({el:"#waline",serverURL:"https://example.example.com",lang:"zh-CN"”

中的https://example.example.com

改为了我的Vercel服务绑定的域名

https://vercel.astralun.top

然后直接Deploy

Deploy前不改这一步是没有办法评论的

现在我的博客能正常评论是因为我自己修改过了index.html

Astrapencil commented 1 year ago

我自己也进行了评论是否可用的对照实验

Astrapencil commented 1 year ago

您好您好!

我新生成了两篇博文

Image

并没有修改他们,直接Deploy了 https://astralun.top/2023/05/14/hello-world/ https://astralun.top/2023/06/17/Hexo%E5%BB%BA%E7%AB%99%E8%B8%A9%E5%9D%91%E6%97%A5%E5%BF%97/

可以麻烦老师上去看看,这两篇文章的评论确实是用不了

谢谢老师

EvanNotFound commented 11 months ago

本问题无发复现,如有问题请 Reopen