将haml用于中间人博客

时间:2015-12-08 21:44:01

标签: haml middleman

我有一个中间人博客,其中包含源/日记中的帖子文件。

我的博客配置:

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

源文件/ 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

我可以使用直接网址提取页面,但帖子没有注册:

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

...并且前端只是在页面顶部显示为纯文本。

非常感谢你的时间。

UPDATE!

博客配置应该是:

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

1 个答案:

答案 0 :(得分:0)

问题是你要包含完整的文件扩展名“.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