如何创建“草稿”? Nanoc 中的项目?

发布于 2024-12-26 04:43:26 字数 232 浏览 3 评论 0原文

我想根据元数据中的状态代码将帖子呈现到不同的文件夹。

例如,如果我有一个 status: Draft 属性,我希望将这些项目呈现到名为 /draft/ 的文件夹,而 status: live 将渲染到 /blog/。然后我可以用密码保护草稿文件夹,以便只有我可以查看它。如果根本没有状态,则默认为草稿。

这可能吗?

I'd like to render posts to different folders depending on a status code in the metadata.

For example, if I have an attribute of status: draft I'd like for these items to be rendered to a folder called /draft/, while status: live would be rendered to /blog/. I could then password protect the draft folder so that only I could view it. If there is no status at all it would default to draft.

Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生共白头 2025-01-02 04:43:26

在您的规则文件中,使用以下内容:

route '*' do
  if item.binary?
    item.identifier.chop + '.' + item[:extension]
  elsif item[:status]
    '/' + item[:status] + item.identifier.chop + '.' + item[:extension]
  else
    item.identifier + 'index.html'
  end
end

这将为您拥有的每个状态创建一个目录。
以 开头的源文件

---
title: file1
status: testing
---

例如:将在 /testing/ 文件夹中创建

。要在编译后删除剩余文件,可以使用“nanoc prune”(nanoc 3.3.x 中的新增功能)。

In your rules file, use the following:

route '*' do
  if item.binary?
    item.identifier.chop + '.' + item[:extension]
  elsif item[:status]
    '/' + item[:status] + item.identifier.chop + '.' + item[:extension]
  else
    item.identifier + 'index.html'
  end
end

This will create a directory for each status you have.
Eg: A source file that begins with

---
title: file1
status: testing
---

will be created in the /testing/ folder.

To remove leftover files after compilation, you can use “nanoc prune” (new in nanoc 3.3.x).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文