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

hexo文章目录只显示一级标题 #76

Open
fumx1314 opened this issue Dec 31, 2024 · 15 comments
Open

hexo文章目录只显示一级标题 #76

fumx1314 opened this issue Dec 31, 2024 · 15 comments

Comments

@fumx1314
Copy link

大佬,我是纯小白,我想问一下为什么我在hexo上的博客文章目录只能显示一级标题啊(用typora写的)
image

比如这个只出现了一级标题目录

@fumx1314
Copy link
Author

image
但在typora中目录是分级的

@fumx1314
Copy link
Author

image

@R3c0ger
Copy link

R3c0ger commented Dec 31, 2024

似乎 Hexo 不太能支持在文章中出现 # 开头的一级标题,文章内容中似乎最低只能出现二级标题;博客中的目录也是最高为二级标题,点到哪个标题,就会展开呈现更高层级的标题,而一级标题只会居中放置。

我个人的写法是:一级标题有且只有一个,当作文章标题,生成静态文件之前,将原文档拷贝到 source 中,用 python 和正则将一级标题那一行去掉,移动到 front-matter 中的 title 字段里去。

@D-Sketon
Copy link
Owner

D-Sketon commented Dec 31, 2024

While using multiple <h1> elements on one page is allowed by the HTML standard (as long as they are not nested), this is not considered a best practice. A page should generally have a single <h1> element that describes the content of the page (similar to the document's <title> element).

其实不仅仅是hexo,根据mdn的规范,任何页面就应该只有一个h1

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

image
改成了二级标题但就显示了一个子标题

@D-Sketon
Copy link
Owner

D-Sketon commented Jan 1, 2025

是否小标题是以数字开头的?如果是的话那这是一个bug,会在下个版本修复

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

没有数字

@D-Sketon
Copy link
Owner

D-Sketon commented Jan 1, 2025

能否提供md文件供测试?

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

mysql.md

@D-Sketon
Copy link
Owner

D-Sketon commented Jan 1, 2025

经过测试,是因为小标题有数字造成错误,会在下版本修复
{C14B85C4-4867-4BDF-910E-78CDEBD0F66F}
另,
{6467996E-93E1-4D37-87BF-7A8CDACED31B}
目录的错位由于此处标题跳级造成
{8DF1F112-8583-4FA7-B6BC-5D33FC9E54E0}

@D-Sketon
Copy link
Owner

D-Sketon commented Jan 1, 2025

如果非常紧急可以参考222c246 自行修改源码临时解决

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

ok了,感谢大佬

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

image
大佬,我按那个修改了源代码,然后现在好像不能点击目录不能跳转了而且也不显示子目录
mysql.md

@D-Sketon
Copy link
Owner

D-Sketon commented Jan 1, 2025

  1. 我这里本地修改源码后已无法复现,请尝试 hexo clean 清除缓存后再尝试
  2. 如果还是有问题请截图f12的报错信息供排查

@fumx1314
Copy link
Author

fumx1314 commented Jan 1, 2025

好的谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants