-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
Excerpt not rendering markdown tags #1380
Comments
Doing a little bit of digging because I'm curious. Looks like this is where we generate the excerpt: eleventy/src/TemplateContent.js Line 98 in 79d0960
|
The excerpts indeed come as raw markdown. But that's not a problem! Just create a markdown rendering filter and pass the value through it. That filter will become handy in other places later... In
The excerpt separator is default,
The // .eleventy.js
const markdownIt = require("markdown-it");
// ...
eleventyConfig.addFilter("md", function (content = "") {
return markdownIt({ html: true }).render(content);
}); Here's my excerpt with links: I've been thinking about this; in theory, getting raw markdown gives more freedom to process the excerpt before displaying it. For example, imagine if this was corporate blog and you were asked to add different tracking tags on URL's on excerpts, so that analytics team could separate internal links in articles from same-URL links in excerpts... That could be done tweaking this I don't know, it could be an issue or it could be just that we need some more documentation instructions how to create and use |
The filter @revelt mentions solve the problem in an elegant way and with minimum complexity. And it's true, it gives more flexibility. |
Awesome! That filter looks awesome. I'm going to close this issue since there's an elegant way to solve the problem! |
Description
I'm getting an excerpt that contains raw markdown when I use custom front matter parsing from the docs: https://www.11ty.dev/docs/data-frontmatter-customize/.
To Reproduce
.eleventy.js
[test](example.com)
in the excerpt.post.data.my_custom_excerpt
.Expected behavior
I expect the link to render as a link
Actual behavior
It renders the raw markdown.
Screenshots
This is the markdown:
Environment:
Additional context
There are workarounds to this issue such as creating custom shortcodes, but would love to use the frontmatter excerpt..
Another, consideration is to render the markdown and then strip the tags. Stripping the tags is seen in frameworks such as Hugo (via
plainify
- https://gohugo.io/functions/plainify/). And can provide a more uniform excerpt. Totally my opinion though! Feel free to ignore if it won't provide value!The text was updated successfully, but these errors were encountered: