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

tags或者categories包含&或者空格或者特殊字符的问题 #316

Open
2 tasks done
ted423 opened this issue Sep 24, 2021 · 13 comments
Open
2 tasks done

tags或者categories包含&或者空格或者特殊字符的问题 #316

ted423 opened this issue Sep 24, 2021 · 13 comments
Assignees

Comments

@ted423
Copy link

ted423 commented Sep 24, 2021

「描述遇到的问题」或「发现的 bug」(Describe the problem or bug you encounter)

你是否已经阅读过以下内容,并确认你的行为是正确的,在 [ ] 中填入 x 选中(Ensure that you had consulted followings and confirm the validity of your operation, fill x in [ ] to select)

如何复现(To Reproduce)

屏幕截图 2021-09-24 150812
屏幕截图 2021-09-24 150917

数据保存应该用的空格(不太清楚Hexo本身是不是默认是都转成了-),但是查找时应该把空格转换成了'-'才去查。所以造成查不到东西,个人是期望能使用特殊字符和空格的,这样看起来能美观一些。
存在问题或 bug 的已部署上线的页面地址(A deployed page link that with bug or problem)
https://ted423.github.io/categories/Issue/
https://ted423.github.io/tags/Windows-10/
https://ted423.github.io/tags/Download-File-hosting-service/
如果可能是与 markdown 内容相关的问题或 bug,请粘贴对应的 markdown 内容(If the problem or bug that may be related to markdown, paste it here)

打开控制台,填写控制台中打印的主题的版本,如果脚本出错可直接提供控制台截图(Open the console and report the version of hexo-theme-archer. You can paste the screenshot on console directly if there is error with script)
🎯 hexo-theme-archer ⬇️
main.js:13 🏷 Version: 1.6.3
main.js:14 📅 Version date: 202107
main.js:15 📦 https://github.com/fi3ework/hexo-theme-archer
信息 (please complete the following information):

  • 操作系统(OS): [e.g. iOS]
  • 浏览器(Browser) [e.g. chrome, safari]
  • 浏览器版本(Version)[e.g. 22][可选]

其他信息(Additional context)

@ted423
Copy link
Author

ted423 commented Sep 24, 2021

后一个图里面是postsArr
好像是在这里定义的?
https://github.com/fi3ework/hexo-theme-archer/blob/7bc7eea42da1e893c668addb49b10e489df72c6e/src/js/tag.js

@ted423
Copy link
Author

ted423 commented Sep 24, 2021

忘了,中括号小括号应该是‘)’,']'默认会被删,然后'.'也会变成'-'
https://ted423.github.io/tags/%E7%BB%84%E7%AD%96%E7%95%A5-gpedit-msc/

这让我想起了测试工程师的笑话

@LolipopJ
Copy link
Collaborator

我想问题应该出在 src\js\tag.js 中:在处理侧边栏索引时,使用了 Tag 和 Cate 中的 slug 属性,此属性会格式化特殊字符变成 -。而如果改成使用 name 属性,那么将原封不动展示您设置的内容。

这里有一段前辈写的注释:

// if this.metaName is 'categories', tagOrCatetory['slug'] will be used as key in this.indexMap
// else if this.metaName is 'tag', tagOrCatetory['name'] will be used as key in this.indexMap
// check the array postsArr and you'll know why. (actually you can just use 'slug' in both case)

不大懂,事实上两者都使用 name 的话,就可以实现特殊字符的展示了。

但也许会出现严重的问题;总之我先将修改后的代码放到 dev 分支上。

@LolipopJ
Copy link
Collaborator

小插曲

查了查提交记录,某次我将:

const key = this.metaName === 'categories' ? 'slug' : 'name'

改成了:

const key = 'slug'

……总之现在应该没问题了,对 tag 和 cate 的处理应该是一样的了。

@LolipopJ LolipopJ self-assigned this Sep 24, 2021
@ted423
Copy link
Author

ted423 commented Sep 26, 2021

我想问题应该出在 src\js\tag.js 中:在处理侧边栏索引时,使用了 Tag 和 Cate 中的 slug 属性,此属性会格式化特殊字符变成 -。而如果改成使用 name 属性,那么将原封不动展示您设置的内容。

这里有一段前辈写的注释:

// if this.metaName is 'categories', tagOrCatetory['slug'] will be used as key in this.indexMap
// else if this.metaName is 'tag', tagOrCatetory['name'] will be used as key in this.indexMap
// check the array postsArr and you'll know why. (actually you can just use 'slug' in both case)

不大懂,事实上两者都使用 name 的话,就可以实现特殊字符的展示了。

但也许会出现严重的问题;总之我先将修改后的代码放到 dev 分支上。

postsArr里tag保存的应该是'Winddows Update'
就是查询的时候应该是用'Winddows-Update'去匹配,导致匹配不到,点了tag 'Winddows Update'以后不会显示对应的文章,categories因为显示名也会带-所以我没怎么用特殊符号。我是想能显示特殊符号,并且点tag的时候能正常显示

@ted423
Copy link
Author

ted423 commented Sep 26, 2021

试了下,可以了,幸苦

@ted423
Copy link
Author

ted423 commented May 23, 2023

更新了下,好像又出问题了,这回是含"["或者"("点击后不会在左侧列表显示包含的文章

@ted423 ted423 reopened this May 23, 2023
@ted423
Copy link
Author

ted423 commented May 23, 2023

符号"|"也会

@ted423
Copy link
Author

ted423 commented May 23, 2023

之前的版本是 Version date: 202107

@ted423
Copy link
Author

ted423 commented May 23, 2023

控制台报错是
tag.js:54 Please ensure set tags: trueandcategories: trueof the hexo-content-json config value @ tag.js:54

@ted423
Copy link
Author

ted423 commented Aug 12, 2023

"name":"迪士尼[Disney]","slug":"迪士尼-Disney"

看了下 content.json 里是这样

@ted423
Copy link
Author

ted423 commented Aug 12, 2023

image
应该是tags.js的问题

Stark-X pushed a commit to Stark-X/hexo-theme-archer that referenced this issue Apr 1, 2024
@LolipopJ
Copy link
Collaborator

控制台报错是 tag.js:54 Please ensure set tags: trueandcategories: trueof the hexo-content-json config value @ tag.js:54

应该是 Hexo 博客根目录(执行 hexo generate 等命令的目录)没有安装 Hexo 插件 hexo-generator-json-content 导致的。

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

No branches or pull requests

2 participants