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

Add template blocks support to Markdown files #2892

Closed
ngustavo opened this issue Apr 4, 2023 · 3 comments
Closed

Add template blocks support to Markdown files #2892

ngustavo opened this issue Apr 4, 2023 · 3 comments
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.

Comments

@ngustavo
Copy link

ngustavo commented Apr 4, 2023

Is your feature request related to a problem? Please describe.

I've struggled so many times with creating an end-user-friendly setup with content blocks inside index.md that I think this could be someone else's issue too.

Describe the solution you'd like

Use template blocks in Markdown files, e.g. Pug, Nunjucks, Liquid block syntax

I suggest using MDC-like syntax:

# Blocks!
::motd
Hello World!
::

layout.njk

{{ content | safe }}
<p class="motd">
  {% block motd %} N/A {% endblock %}
</p>

output

<h1>Blocks!</h1>
<p class="motd">Hello World!</p>

Describe alternatives you've considered

Using front matter data passed to layouts by cascading. This is not optimal due to lack of syntax highlighting for markdown. These variables are intended for simple strings, not code-like data.

Additional context

No response

@pdehaan
Copy link
Contributor

pdehaan commented Apr 4, 2023

I haven't tried this in a while, but .md files are preprocessed by a template engine (default is LiquidJS). Per https://www.11ty.dev/docs/languages/markdown/

"INFO: Markdown files are by default pre-processed as Liquid templates. You can change this default in your configuration file (or disable it altogether). To change this for a single template and not globally, read Changing a Template’s Rendering Engine."

So couldn't your .md files use Liquid blocks (or switch the template engine to Nunjucks if you prefer Nunjucks blocks). Although I think the caveat is that using blocks usually means you have to use {% layout %} tags instead of relying on Eleventy's layouts.

@zachleat
Copy link
Member

zachleat commented Apr 19, 2023

Also—this seems related: #2502

@zachleat zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Jul 11, 2024
@zachleat
Copy link
Member

By default this repo closes enhancement request issues and places them in a queue for folks to upvote. We do this to avoid a large build-up of open issues. We got this idea from the lodash project.

Don’t forget to upvote the first comment with 👍 to register your vote! You can view the current enhancement backlog.

@zachleat zachleat closed this as not planned Won't fix, can't repro, duplicate, stale Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.
Projects
None yet
Development

No branches or pull requests

3 participants