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

Footnote support #167

Open
AndrewHaglund opened this issue Jan 6, 2024 · 1 comment
Open

Footnote support #167

AndrewHaglund opened this issue Jan 6, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@AndrewHaglund
Copy link

It’d be awesome if markdown-it/footnote was supported by default in this project. I’m new to Eleventy (and web development in general) so it took me a while to figure out where to put it in my project to get it configured correctly.

@zachleat zachleat added the enhancement New feature or request label Sep 11, 2024
@AndrewHaglund
Copy link
Author

AndrewHaglund commented Oct 2, 2024

I think I just needed to add this to in my eleventy.config.js:

const markdownItFootnote = require("markdown-it-footnote");

Then in my modules.exports function (in eleventy.config.js):

eleventyConfig.amendLibrary("md", mdLib => {
	// footnotes
	const md = markdownIt({
		html: true,
		linkify: true,
	  })
	mdLib.use(require('markdown-it-footnote'));

	// hides brackets for footnotes
	mdLib.renderer.rules.footnote_caption = (tokens, idx) => {
		let n = Number(tokens[idx].meta.id + 1).toString();
	  
		if (tokens[idx].meta.subId > 0) {
		  n += ":" + tokens[idx].meta.subId;
		}
		return n;
	  };
});

Example on in one of my recent blog posts. My source code.

Goal: make a linkable footnote with [^1] and then at the bottom of the document [^1]: footnote text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants