0

I'm building a plugin to generate site-wide menus; the data for these menus comes from scanning the rendered DOM for *.html.md files; but I only use the menu in one place (root of the site).

Plugin currently generates each page's part of this menu in writeBefore, which works fine as I walk the collection, handle each document, and write a file into the partials directory.

But since the docs have all been rendered already by that time, the <%- @partial('foo.html')%> call in my index.html.eco doesn't work unless I run docpad generate twice.

I assumed that if I set renderPasses to a value > 1, then the partials would get picked up on the > 1 pass, but that doesn't happen.

Is there an event I can use that's after an initial render (so there's a DOM to parse) but before partials get rendered?

Thanks.

4

1 回答 1

0

您可以使用renderDocument事件(针对每个文档以及文档具有的每个布局触发)或renderAfter事件。但我想你可能有同样的问题。

让您的菜单需要其他文件的呈现内容的具体原因是什么?因为您可以使用文本插件来呈现相同的元数据属性,并在呈现之前访问这些元数据属性。例如

---
someMarkdown: "<t render="markdown">*hello*</t>"
---

然后在你的菜单或其他

<ul><% for page in @getCollection('html').toJSON(): %>
  <li><%- page.someMarkdown %></li>
<% end %></ul>

这将与文本插件使用 markdown 呈现的元数据属性一样正常工作。

于 2013-07-28T13:06:29.917 回答