-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Option to capitalize slugs #19
Comments
Hey! This project is intentionally simple. So that everyone uses the same slugs. It follows GitHub. So that what you write in markdown will work here. And in VS Code. In as many places. The goal is to not add other options. It would go against the goal of everyone using the same slugs. The alternative, writing your own plugin, is fine! We recommend learning about ASTs, and this is a good example how to learn about them. |
This comment has been minimized.
This comment has been minimized.
Thanks for your explanation. I really like the idea of creating slugs similar to how GitHub does it, and I want to use this in my projects. I am building an Astro blog, and I need to make sure it supports some links from an older blogging system. In that older system, some of the links are like Also, I'm wondering if there's a way to choose which heading levels get slugs/IDs. For example, I only want IDs for H2 headings and not for H3 headings. Is there a way to do that? |
I recommend changing the content. See the source: https://github.com/rehypejs/rehype-slug/blob/main/lib/index.js.
|
I appreciate your input. I will try to gradually transition to the new slug structure. For now, I'm using JavaScript within my Astro pages to convert incoming legacy slugs (capitalized in my case) into the new format. Example: <script>
(() => {
const matchTS = /TS\d+/g;
const hash = window.location.hash;
const matches = hash.match(matchTS);
if (matches) {
window.location.hash = hash.replace('TS', 'ts');
}
})();
</script> |
Initial checklist
Problem
Currently the only option provided by the plugin is a
prefix
. It would be nice to add further options so slugs can be written in capital letters. It would be also cool if a transformer could be defined to modify the generated slugs yourself.Solution
Adding a "capitalize" option or adding a callback where developers can defined their own slug customizations.
Alternatives
Only by writing your own slug plugin.
The text was updated successfully, but these errors were encountered: