Replies: 2 comments 1 reply
-
You should be able to do this without a module simply by using the existing Razor subsystem. In the frontmatter for each markdown file, define the SamplePage.md ---
Title: Sample Page
xref: sample
layout: _SampleLayout
---
Hello World! _SampleLayout.cshtml @{
// If you have a _MasterLayout.cshtml file in the root which gives you your overall site layout, specify that here:
Layout = "_MasterLayout";
}
@* You can have whatever layout you like here. This is representative of the layout used for each markdown file. *@
<div class="row">
<div class="col">
<partial name="_tableOfContents" />
</div>
<div class="col">
@RenderBody()
</div>
<div class="col">
<partial name="_sidebar" />
</div> Index.cshtml @{
DocumentList<IDocument> children = OutputPages.GetChildrenOf(Document);
}
<div class="document-list">
@foreach (IDocument document in children)
{
@(await document.GetContentStringAsync());
} Getting the content string may not be exactly right, but it should be fairly close to what you're looking for. Hopefully this can at least set you on the right track. |
Beta Was this translation helpful? Give feedback.
-
I would pose the question this way: How to use Markdown files to render partial Razor layouts with content and then use some logic (e.g. pipelines) to combine those intermediate partial outputs to one single page? |
Beta Was this translation helpful? Give feedback.
-
I am trying to use Statiq to combine multiple *.md input files to a single page HTML file as sections one after another. Something like this came to my mind at first:
This works. However I would like to have every child to be rendered using a custom layout declared in the FrontMatter header section of the every Markdown file. How to use the fully rendered output (Markdown -> HTML -> Razor Template) to render every child element in the sample above?
Have been experimenting with a custom pipeline as well (taking the Archive pipeline as a basis) but it got really messy. I managed to combine the documents, but I could not get the post-process rendering working properly with some crucial bits missing from the code:
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions