Markdown Slot
First, let’s review the relationship between layout components and Markdown files:
Markdown files are providers of metadata (Page content, Configuration, etc.), while layout components consume them. We can use to define some metadata for common data types, but frontmatter
is hard to do something about Markdown / HTML, a complex metadata that involves differences before and after compilation.
You can define a named Markdown slot through the following Markdown syntax:
Use the Content
component to use the slot in the layout component:
<Content slot-key="name"/>
TIP
By default, the slot-free part of a Markdown file becomes the default content of a Markdown slot, which you can access directly using the Content
component:
Suppose your layout component is as follows:
If the Markdown content of a page is like this:
<div class="container">
<header>
<div class="content header">
<h1>Here might be a page title</h1>
</div>
</header>
<main>
<div class="content default">
<ul>
<li>A Paragraph</li>
<li>Another Paragraph</li>
</ul>
</div>
</main>
<footer>
<div class="content footer">
<p>Here's some contact info</p>
</div>
</footer>
</div>
Note that:
- Please ensure the uniqueness of the slot defined.