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

[BUG]hugo文章中文子目录无法正常跳转 #1209

Closed
hzp2333 opened this issue Mar 20, 2024 · 9 comments
Closed

[BUG]hugo文章中文子目录无法正常跳转 #1209

hzp2333 opened this issue Mar 20, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@hzp2333
Copy link

hzp2333 commented Mar 20, 2024

Describe the bug 描述你遇到的错误

hugo自带的目录系统可以在文章页面生成目录,点击不同的子标题会跳转到对应部分。
不知道为什么?我的博客中文页面无法实现目录跳转,但是英文页面可以正常跳转。
同时,当我在本地预览(localhost:1313)时,英文和中文的文章目录跳转都是正常的。
9773c9cdf18cb7e866628c0f8ad3f35

Expected behavior 期待的行为

是什么因素导致本地和正式上传后的情况不同呢111?
如何修正中文目录的情况呢?
十分感谢您的回答!

Screenshots 屏幕截图

No response

Build Environment 构建环境

No response

Preview Environment 预览环境

Windows 11 +loveit主题+hugo扩展版
使用的hugo默认的目录,没有额外设置什么

Additional Information 补充信息

网站地址:https://blog.huaxiangshan.com/

@hzp2333 hzp2333 added the bug Something isn't working label Mar 20, 2024
@HEIGE-PCloud
Copy link
Owner

似乎中文 id + music shortcode 同时出现就会有这个问题,好神奇。。。

---
title: "Music Tests"
date: 2021-04-16T14:47:54+01:00
lastmod: 2021-04-16T14:47:54+01:00
draft: true
description: "Music Tests"
categories: [Tests]
authors: [PCloud]
hiddenFromHomePage: true
hiddenFromSearch: true
---


{{< music url="/music/Wavelength.mp3" name=Wavelength artist=oldmanyoung cover="/images/Wavelength.webp" >}}


## 中文

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Molestie ac feugiat sed lectus. Enim eu turpis egestas pretium aenean pharetra. Sed risus pretium quam vulputate dignissim. Feugiat in fermentum posuere urna nec. Odio ut enim blandit volutpat maecenas volutpat blandit aliquam. Euismod quis viverra nibh cras. Feugiat nisl pretium fusce id velit ut tortor pretium. Purus ut faucibus pulvinar elementum. Luctus venenatis lectus magna fringilla urna porttitor. Nibh tortor id aliquet lectus proin nibh nisl condimentum id. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Venenatis cras sed felis eget velit aliquet. Est placerat in egestas erat imperdiet sed euismod nisi porta. Duis at consectetur lorem donec massa sapien faucibus. Nec feugiat in fermentum posuere urna nec tincidunt praesent semper. Ornare aenean euismod elementum nisi quis eleifend quam adipiscing vitae. Risus quis varius quam quisque id diam. Dolor morbi non arcu risus. Ornare quam viverra orci sagittis eu volutpat odio.


## title 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Molestie ac feugiat sed lectus. Enim eu turpis egestas pretium aenean pharetra. Sed risus pretium quam vulputate dignissim. Feugiat in fermentum posuere urna nec. Odio ut enim blandit volutpat maecenas volutpat blandit aliquam. Euismod quis viverra nibh cras. Feugiat nisl pretium fusce id velit ut tortor pretium. Purus ut faucibus pulvinar elementum. Luctus venenatis lectus magna fringilla urna porttitor. Nibh tortor id aliquet lectus proin nibh nisl condimentum id. Malesuada fames ac turpis egestas maecenas pharetra convallis posuere. Venenatis cras sed felis eget velit aliquet. Est placerat in egestas erat imperdiet sed euismod nisi porta. Duis at consectetur lorem donec massa sapien faucibus. Nec feugiat in fermentum posuere urna nec tincidunt praesent semper. Ornare aenean euismod elementum nisi quis eleifend quam adipiscing vitae. Risus quis varius quam quisque id diam. Dolor morbi non arcu risus. Ornare quam viverra orci sagittis eu volutpat odio.

@HEIGE-PCloud
Copy link
Owner

Ok, APlayer's bug

DIYgod/APlayer#412

@HEIGE-PCloud
Copy link
Owner

Ok, it's actually smoothscroll's issue, which is one of APlayer's dependencies.

alicelieutier/smoothScroll#24

@hzp2333
Copy link
Author

hzp2333 commented Mar 20, 2024

Ok, APlayer's bug

DIYgod/APlayer#412

抱歉,是我的问题。
原因是doit为保证网页打开速度实行懒加载,现场加载图片。
是因为我图片太多了来不及加载卡住了。
如果没有图片的博客中文文章就没有问题。
再次感谢博主对doit的维护!

@HEIGE-PCloud
Copy link
Owner

HEIGE-PCloud commented Mar 20, 2024

https://github.com/alicelieutier/smoothScroll/blob/master/smoothscroll.js#L100

This is where it went wrong. The location.hash for id="中文" will be '#%E4%B8%AD%E6%96%87', and then when it tries getElementById using the hash instead of the raw text nothing comes up, so it just returns instead of scrolling to the right place.

@HEIGE-PCloud
Copy link
Owner

HEIGE-PCloud commented Mar 20, 2024

As CSS smooth scroll is available on all major platforms https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior
I think the best way to fix this is to submit a PR to APlayer switching to native smooth scrolling.

It should also fix the issue where sometimes you see the native smooth scrolling fighting with the library.

@hzp2333
Copy link
Author

hzp2333 commented Mar 21, 2024

As CSS smooth scroll is available on all major platforms https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior I think the best way to fix this is to submit a PR to APlayer switching to native smooth scrolling.

It should also fix the issue where sometimes you see the native smooth scrolling fighting with the library. 由于CSS平滑滚动在所有主要平台上都可用https://developer . Mozilla . org/en-US/docs/Web/CSS/scroll-behavior 我认为解决这个问题的最好方法是将PR提交给播放器,切换到原生平滑滚动。 它还应该修复有时您会看到原生平滑滚动与库冲突的问题。

感谢回复!请问有更具体的修复步骤吗?刚刚接触hugo有点不太明白您提供的这个方法

@hzp2333
Copy link
Author

hzp2333 commented Mar 21, 2024

已解决,参考blog:https://blog.wangriyu.wang/2018/06-Aplayer.html
博文里有修改好了点APlayer.min.js文件,替换后就行
https://src.wangriyu.wang/lib/Aplayer/APlayer.min.js

@HEIGE-PCloud HEIGE-PCloud closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
@CXwudi
Copy link
Contributor

CXwudi commented Apr 10, 2024

As CSS smooth scroll is available on all major platforms https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior I think the best way to fix this is to submit a PR to APlayer switching to native smooth scrolling.

It should also fix the issue where sometimes you see the native smooth scrolling fighting with the library.

Someone has already submitted a PR at DIYgod/APlayer#777. It's just that we don't know if it can get merged one day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants