hexo icon indicating copy to clipboard operation
hexo copied to clipboard

helper function <%- css(path, ...) %> not working fine with relative_url

Open bill-xia opened this issue 3 years ago • 0 comments

Check List

Please check followings before submitting a new issue.

  • [x] I have already read Docs page & Troubleshooting page
  • [x] I have already searched existing issues and they are not help to me
  • [x] I examined error or warning messages and it's difficult to solve
  • [x] Using the latest version of Hexo (run hexo version to check)
  • [x] Node.js is higher than minimum required version

Expected behavior

relative_url: true is configured in _config.yml.

<%- css('/css/style.css') %> in public/archives/page/2/index.html should generate:

<link rel="stylesheet" href="../../../css/style.css">

Actual behavior

It actually generates:

<link rel="stylesheet" href="../../../../css/style.css">

Sometimes (in another theme) it only generates one ../, I think it may be a cache problem. I'm not sure it's not a problem outside hexo.

How to reproduce?

  • init a site, using default theme landscape is OK.
  • put 20 articles into source/ directory
  • edit site configuration file _config.yml:
per_page: 10
pagination_dir: page

relative_link: true
  • hexo g
  • catch public/archives/page/02/index.html

The <link> tag of /css/style.css can be with a wrong relative path.

Is the problem still there under "Safe mode"?

Under safe mode, these pages cannot be generated, so I can't be sure.

Environment & Settings

Node.js & npm version(node -v && npm -v)

v16.13.1
8.3.2

Your site _config.yml (Optional)

Your theme _config.yml (Optional)

Hexo and Plugin version(npm ls --depth 0)

[email protected] /Users/wilson/Developer/proj/hexo-theme
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "6.0.0"
  },
  "dependencies": {
    "hexo": "^6.0.0",
    "hexo-deployer-git": "^3.0.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^3.0.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-sitemap": "^2.1.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-markdown-them": "^1.0.1",
    "hexo-renderer-stylus": "^2.0.0",
    "hexo-server": "^2.0.0",
    "hexo-theme-landscape": "^0.0.3",
    "katex": "^0.13.18",
    "markdown-them": "^1.0.13"
  }
}

Others

bill-xia avatar Feb 05 '22 17:02 bill-xia