Skip to content

安装katex渲染器后,文章图片路径解析从绝对路径变为文章相对路径 #1250

Description

@vistar-terry

请确认

  • [ √ 1.9.9 ] 是当前最新的 Release 版本
  • [ √ ] 本地 hexo clean && hexo s,并且清除浏览器缓存,仍可复现
  • [ √ ] 已经排除是其他 Hexo 插件影响

Bug 描述

使用katex解析公式,安装相应渲染器后,文章图片路径解析从绝对路径变为文章相对路径,例如:
安装前:http://localhost:4000/img/article/202008/20200330183554388.jpg
安装后:http://localhost:4000/2020/08/01/article_title/img/article/202008/20200330183554388.jpg
导致文章中的图片无法显示,浏览器: Chrome 148.0.7778.178 (Official Build) (64-bit)

版本号:

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "7.3.0"
  },
  "dependencies": {
    "@traptitech/markdown-it-katex": "^3.6.0",
    "hexo": "^7.0.0",
    "hexo-deployer-git": "^4.0.0",
    "hexo-generator-archive": "^2.0.0",
    "hexo-generator-category": "^2.0.0",
    "hexo-generator-index": "^3.0.0",
    "hexo-generator-tag": "^2.0.0",
    "hexo-renderer-ejs": "^2.0.0",
    "hexo-renderer-markdown-it": "^6.1.0",
    "hexo-renderer-stylus": "^3.0.0",
    "hexo-server": "^3.0.0",
    "hexo-theme-fluid": "^1.9.9",
    "hexo-theme-landscape": "^1.0.0"
  }
}

katex配置:
_config.yml

markdown:
  plugins:
    - "@traptitech/markdown-it-katex"
  render:
    html: true          
    linkify: true     
katex:
  css: https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css

_config.fluid.yml

math:
    enable: true
    specific: true
    engine: katex

复现步骤

该 Bug 复现步骤如下:

  1. 开始使用 mathjax
  2. 按照 https://hexo.fluid-dev.com/docs/guide/#latex-%E6%95%B0%E5%AD%A6%E5%85%AC%E5%BC%8F 的步骤切换到 katex
  3. 然后依次执行 hexo clean -> hexo g -> hexo s
  4. 打开文章页,公式可正确渲染,但图片无法显示,路径如上所述

复现的页面地址:
https://www.vistary.cn/2020/08/01/PointNet++%20%E6%96%87%E7%8C%AE%E7%BF%BB%E8%AF%91%E9%98%85%E8%AF%BB%E5%8F%8A%E6%8B%93%E5%B1%95%E9%98%85%E8%AF%BB/

https://vistar-terry.github.io/2020/08/01/PointNet++%20%E6%96%87%E7%8C%AE%E7%BF%BB%E8%AF%91%E9%98%85%E8%AF%BB%E5%8F%8A%E6%8B%93%E5%B1%95%E9%98%85%E8%AF%BB/

截图

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugUnexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions