nhoizey / eleventy-plugin-link_to

A Nunjucks tag to link to another internal content in Eleventy with its slug.
MIT License
3 stars 0 forks source link

How to use with markdown? #3

Open heatherbooker opened 3 years ago

heatherbooker commented 3 years ago

Hi, I see the readme says this works in markdown, how does the syntax work?

I'm trying something like:

[Click me]({% link_to "other-post-title" %})

And getting an eleventy build error:

tag link_to was not found

Thanks for this plugin!

lilatomic commented 3 years ago

The plugin registers a nunjucks tag, but markdown files are pretemplated by default with liquid (see here). I was able to get this plugin working by changing the pretemplating engine in .eleventy.js:

- markdownTemplateEngine: "liquid",
+ markdownTemplateEngine: "njk",

liquid and nunjucks are pretty similar. I found that the include directive worked slightly differently, needing the name of the include to be quoted or I got Error: template names must be a string: NaN. It also expands double curly braces in the included files.

nhoizey commented 2 years ago

@heatherbooker sorry for the very late answer. 😔

As @lilatomic said, this plugin requires using Nunjucks as the template engine for Markdown. I just added this in the README.