如何从单个Markdown渲染两个文件 [英] How to render two files from a single markdown

查看:52
本文介绍了如何从单个Markdown渲染两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组markdown文件,我想在构建页面时使用两个不同的布局文件来渲染两个不同的文件集:

I have a collection of markdown files and I would like to render in two different set of files using two different layout files when building the page:

–网站的html文件 – xml文件

– html files for the website – xml files

是否可以这样做?降价文件似乎只能解析一次.有什么建议?非常感谢

Is it possible to do this? It seems that a markdown file can be only parsed once. Any suggestions? Many thanks

推荐答案

您将需要两个页面来指向markdown发布文件,而不是拥有一个指向布局文件的markdown文件.

Instead of having a markdown file that points to a layout file, you're going to need two pages that point to the markdown post file.

有多种方法可以指向发布文件.我喜欢使用where过滤器:

There are a number of ways to point to a post file. I like to use a where filter:

{% assign post = site.posts | where:"url", include.url | first %}

现在您有一个post,假设您有要放入该帖子的fileOne.html.这是您的处理方式:

Now that you have a post, let's say you have fileOne.html that you want to put that post into. Here's how you'd approach that:

---
layout:main
---

<h1>Some html here</h1>

{% assign post = site.posts | where:"url", include.url | first %}
{{ post.content }}

然后,您可以在另一个名为fileTwo.html的文件中执行完全相同的操作.

Then you could do the exact same thing in another file named fileTwo.html.

这篇关于如何从单个Markdown渲染两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆