Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不能正常加载glyph-correction系列字体 #287

Closed
jianse opened this issue Dec 25, 2020 · 3 comments
Closed

不能正常加载glyph-correction系列字体 #287

jianse opened this issue Dec 25, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@jianse
Copy link
Contributor

jianse commented Dec 25, 2020

问题描述

当把config.toml中的baseURL设置为非根目录时(例如http://example.com/blog)不能够正常加载glyph-correction系列字体

示例

克隆这个仓科
https://github.com/jianse/meme_bug_showcase
然后

hugo server

访问本地服务器查看开发者工具

@reuixiy
Copy link
Owner

reuixiy commented Dec 26, 2020

因为 glyph-correction 的路径是绝对路径:

src: url('/fonts/glyph-correction.woff2') format('woff2'),
url('/fonts/glyph-correction.woff') format('woff'),
url('/fonts/glyph-correction.ttf') format('truetype'),
url('/fonts/glyph-correction.eot') format('embedded-opentype');

可以定制成相对路径试试,https://github.com/reuixiy/io-oi.me/blob/master/assets/scss/base/_glyph-correction.scss

@jianse
Copy link
Contributor Author

jianse commented Dec 26, 2020

这个问题是跟配置文件中的baseURL相关的,可以这样修改主题
https://github.com/jianse/hugo-theme-meme/blob/master/assets/scss/base/_glyph-correction.scss
可以免去用户覆盖该文件

@reuixiy
Copy link
Owner

reuixiy commented Dec 26, 2020

还有一种 case 是 defaultContentLanguageInSubdirtrue

defaultContentLanguageInSubdir = false

这时候,比如默认的语言为 zh,Hugo 会将根路径 / 变成 /zh/,不知道你的这段修改能不能 cover 这种 case

方便帮忙测试一下吗?如果成功,也许你可以提一个 PR,我们可以将之合并进来

@reuixiy reuixiy added enhancement New feature or request and removed question labels Dec 26, 2020
jianse added a commit to jianse/hugo-theme-meme that referenced this issue Dec 28, 2020
jianse added a commit to jianse/hugo-theme-meme that referenced this issue Dec 28, 2020
@reuixiy reuixiy closed this as completed in 28bcb78 Jan 4, 2021
ulmefors pushed a commit to ulmefors/hugo-theme-meme that referenced this issue Jan 22, 2024
…euixiy#291)

fixes reuixiy#287

* style: ajust code style and trim last "/" character of baseRelURL

...to avoid generating wrong URL "//fonts/..." when baseURL is set to
site's root directory.

Co-authored-by: reuixiy <reuixiy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants