我需要能够在使用分页从全局数据返回的内容中使用自定义简码。
为了说明我正在尝试做的事情,请考虑以下数据源:
./site/data/article.js
module.exports = () => {
return [
{
"title": "Page 1",
"description": "Description for page 1",
"permalink": "/sample/page1",
"content": `## Sample Page 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam dignissim.
{% jumpto %}
Cras faucibus at mauris
varius imperdiet. `
},
{
"title": "Page 2",
"description": "Description for page 2",
"permalink": "/sample/page2",
"content": `## Sample Page 2
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam dignissim.
{% jumpto %}
Cras faucibus at mauris
varius imperdiet. `
},
]
}
** 注意 ** 注意{% jumpto %}
上面代码中的使用
这是文章数据的模板...
./site/articles.njk
---
pagination:
data: articles
size: 1
alias: article
addAllPagesToCollections: true
layout: article
permalink: "{{ article.permalink }}/"
templateEngineOverride: md, njk
eleventyComputed:
title: "{{ article.title }}"
description: "{{ article.description }}"
---
{{ article.content }}
渲染时,它不会处理{% jumpto %}
从article.content
.
有没有办法将它注入article.content
到模板中,以便将其视为模板代码?