-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
with help from jdsteinbach/eleventy-plugin-toc#35
- Loading branch information
Showing
4 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
diff --git a/node_modules/eleventy-plugin-toc/.eleventy.js b/node_modules/eleventy-plugin-toc/.eleventy.js | ||
index 6a926b8..f87651d 100644 | ||
--- a/node_modules/eleventy-plugin-toc/.eleventy.js | ||
+++ b/node_modules/eleventy-plugin-toc/.eleventy.js | ||
@@ -4,7 +4,7 @@ const parseOptions = require('./src/ParseOptions') | ||
module.exports = (eleventyConfig, globalOpts) => { | ||
globalOpts = globalOpts || {} | ||
eleventyConfig.namespace(globalOpts, () => { | ||
- eleventyConfig.addFilter('toc', (content, localOpts) => { | ||
+ eleventyConfig.addFilter('toc', function (content, localOpts) { | ||
return buildTOC(content, parseOptions(localOpts, globalOpts)) | ||
}) | ||
}) | ||
diff --git a/node_modules/eleventy-plugin-toc/src/BuildTOC.js b/node_modules/eleventy-plugin-toc/src/BuildTOC.js | ||
index 50ced4a..00e3e60 100644 | ||
--- a/node_modules/eleventy-plugin-toc/src/BuildTOC.js | ||
+++ b/node_modules/eleventy-plugin-toc/src/BuildTOC.js | ||
@@ -29,11 +29,12 @@ const BuildTOC = (text, opts) => { | ||
|
||
const label = wrapperLabel ? `aria-label="${wrapperLabel}"` : '' | ||
|
||
- return wrapper | ||
- ? `<${wrapper} class="${wrapperClass}" ${label}> | ||
- ${BuildList(headings, ul, flat)} | ||
- </${wrapper}>` | ||
- : BuildList(headings, ul, flat) | ||
+ const content = BuildList(headings, ul, flat); | ||
+ return ( | ||
+ typeof wrapper === 'function' ? wrapper(content, label) | ||
+ : wrapper ? `<${wrapper} class="${wrapperClass}" ${label}>${content}</${wrapper}>` | ||
+ : content | ||
+ ); | ||
} | ||
|
||
module.exports = BuildTOC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters