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

Allow slugger to be passed in #14

Closed
tremby opened this issue Nov 3, 2020 · 2 comments
Closed

Allow slugger to be passed in #14

tremby opened this issue Nov 3, 2020 · 2 comments
Labels
👀 no/external This makes more sense somewhere else

Comments

@tremby
Copy link

tremby commented Nov 3, 2020

Subject of the feature

It'd be helpful to be able to pass the slugger instance in as configuration.

Problem

In the context of a page with multiple chunks of markdown, it's possible for the same slug to be generated more than once on the same page.

Expected behavior

If I anticipate that I'd like to be able to pass in an instance that the plugin would use to generate slugs rather than minting its own one. That way I can be in charge of resetting it when I decide it's necessary, and I can use the same slugger for multiple markdown renderings.

Alternatives

I suppose I could set a different clobberPrefix for each markdown field, but I'd rather not.

@tremby tremby added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Nov 3, 2020
@wooorm
Copy link
Member

wooorm commented Nov 3, 2020

Setting prefixes for different sections is a pretty smart idea imo.

This is a tiny plugin: 21 sloc. The complexity for users to maintain their own slug instances, and to code needed to supporting that here, maybe it’s just better to create your own version?

@tremby
Copy link
Author

tremby commented Nov 3, 2020

I agree in principle but I don't like the idea for my particular use case. The markdown in my case isn't from untrusted users, it's from a CMS, and it's a page-builder sort of thing. I want the slugs for headings to be as clean as possible, and I don't even know the section names ahead of time.

Good point about the small size of the plugin. Very reasonable idea to make my own.

@tremby tremby closed this as completed Nov 3, 2020
@ChristianMurphy ChristianMurphy added 👀 no/external This makes more sense somewhere else and removed 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else
Development

No branches or pull requests

3 participants