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

请问slug是什么? #72

Open
luoying2002 opened this issue Dec 15, 2024 · 2 comments
Open

请问slug是什么? #72

luoying2002 opened this issue Dec 15, 2024 · 2 comments

Comments

@luoying2002
Copy link

No description provided.

@D-Sketon
Copy link
Owner

具体生成代码在这里https://github.com/hexojs/hexo-util/blob/master/lib/slugize.ts
简单来说就是把文章的标题中的特殊字符 \s~!@#$%^&*()\-_+=[]{}|\;:"'<>,.?/ 全换成分隔符 -,合并连续分隔符并去除首尾分隔符

@luoying2002
Copy link
Author

感谢,我做了进一步的处理,类似微信公众号文章把URL上的标题映射到了随机英文字符串上,就是标题如果是中文,URL会很长不好看,我把它映射成了英文字符串,比如我这篇:https://luoying.netlify.app/2024/12/14/skrzswes/,(纯粹为了URL好看哈哈),这时你这个slug就是这一串英文字符“skrzswes”(我试了一下成功了),我感觉好看一点哈哈

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

2 participants