-
Notifications
You must be signed in to change notification settings - Fork 19
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 wrapper to take a function #35
Comments
@bennypowers I echo your appreciation for this plugin. I wonder if you could say a bit more about how one might use the changes that you made. I am a JavaScript newbie, but I am certainly looking for finer control of the wrapper classes, and I think you're solving my problem (?). I am hoping to use this plugin to generate HTML that looks like the following, with specific classes for not only the
@bennypowers can I use your comment plus some new JS function (from selector to the appropriate class-string) to do this? Thank you for any tips. |
What you can do is copy the contents of that snippet to a file called "scripts": "npx patch-package" |
Thank you @bennypowers that is very helpful. I am still a bit confused about how to pass values from my site to the updated TOC plugin (probably because I am new to JavaScript). Would you mind sharing a small example? With the current TOC plugin, my site adds it like so, which I think needs to change after
|
I think that with my patch you could do this: eleventyConfig.addPlugin(pluginTOC, {
tags: ['h1', 'h2'],
wrapper(content, label) {
return `<nav id="bd-toc-nav" class="page-toc" aria-label="Site navigation">
${content.replaceAll('<ul>', '<ul class="visible nav section-nav flex-column">').replaceAll('<li>', '<li class="toc-h2 nav-item toc-entry">')}
</nav>`
},
wrapperClass: 'visible nav section-nav flex-column',
ul: true
}); If you wanted to get more complicated, you consider parsing the |
Thank you @bennypowers I got my TOC to work. Yeah! I had to name the file
I confess I am still hazy on when exactly my scripts get executed. It seems like I need to run
|
with help from jdsteinbach/eleventy-plugin-toc#35
Just wanted to confirm that it works! (Despite my confusion about script execution.) Thanks again for this patch. |
with help from jdsteinbach/eleventy-plugin-toc#35
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.Users may need finer control over the wrapping element. In this patch, I allow
wrapper
to be a binary function takingcontent
andlabel
, which returns HTML. the wrapping element must applyaria-label="${label}"
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: