通过中间人博客将 haml 用于 post 文件

Using haml for post files with middleman blog

我有一个 Middleman 博客,在 source/journal 中有 post 个文件。

我的博客配置:

activate :blog do |blog|
  # set options on blog
  blog.prefix = "journal"
  blog.permalink = "{year}-{month}-{day}-{title}.html.haml"
  blog.sources = "{title}.html.haml"
  blog.layout = "journal_layout"
end

还有一个 post 文件在 source/journal/2015-12-02-hello-world.html.haml

\---
title: Hello World
date: 2015-12-02
category: Photography
\---

%article
  %h1 Hello World
  %p Denver, Colorado :: December 2nd, 2015
  %p Lore ipsum dolar

我可以直接使用 url 调出页面,但是 post 没有注册:

- blog.articles[0...5].each do |article|
  %article
    %h2= link_to article.title, article.url

...而前言仅以纯文本形式出现在页面顶部。

非常感谢您的宝贵时间。

更新!

博客配置应该是:

activate :blog do |blog|
  # set options on blog
  blog.prefix = "journal"
  blog.permalink = "{year}-{month}-{day}-{title}.html"
  blog.sources = "{year}-{month}-{day}-{title}.html.haml"
  blog.layout = "journal_layout"
end

和文章 HAML 文件:

---
title: Hello World
date: 2015-12-02
category: Photography
---

%article
  %h1 Hello World
  %p Denver, Colorado :: December 2nd, 2015
  %p Lore ipsum dolar

问题是您包含了完整的文件扩展名“.html.haml”,但中间人博客扩展名期望的是最终(已处理)文件扩展名,它只是“.html” .

将您的博客配置更改为以下内容,它应该可以工作:

activate :blog do |blog|
  # set options on blog
  blog.prefix = "journal"
  blog.permalink = "{year}-{month}-{day}-{title}.html"
  blog.sources = "{title}.html"
  blog.layout = "journal_layout"
end