I’m trying to upgrade my blog after a long time of inactivity. Most things worked out of the box however I’m having trouble with accessing blog articles. I have two blogs, one named “articles” and another named “essays”. Here is my config.rb
:
# blogging
activate :blog do |blog|
# This will add a prefix to all links, template references and source paths
blog.name ="articles"
blog.prefix = "articles"
blog.permalink = "{year}/{month}/{day}/{title}.html"
blog.custom_collections = {
category: {
link: '/categories/{category}.html',
template: '/articles_category.html'
}
}
# Matcher for blog source files
blog.sources = "{year}-{month}-{day}-{title}.html"
blog.layout = "post"
blog.summary_separator = /(READMORE)/
blog.summary_length = 250
blog.year_link = "{year}.html"
blog.month_link = "{year}/{month}.html"
blog.day_link = "{year}/{month}/{day}.html"
blog.default_extension = ".markdown"
end
# Essays
activate :blog do |blog|
# This will add a prefix to all links, template references and source paths
blog.name ="essays"
blog.prefix = "essays"
blog.permalink = "{year}/{month}/{day}/{title}.html"
blog.custom_collections = {
category: {
link: '/categories/{category}.html',
template: '/essays_category.html'
}
}
blog.sources = "{year}-{month}-{day}-{title}.html"
blog.layout = "essay"
blog.summary_separator = /(READMORE)/
blog.summary_length = 250
blog.year_link = "{year}.html"
blog.month_link = "{year}/{month}.html"
blog.day_link = "{year}/{month}/{day}.html"
blog.default_extension = ".markdown"
end
The index looks like this:
/ Display multiple Blog posts
#frontblog
%h1.section
Articles
%a.inline{:href => '/feed-articles.xml'}
%i.fa.fa-rss
- blog('articles').articles[0...10].each do |article|
%p.hpost
%i.fa.fa-pencil
= link_to article.title, article.url
%span{:class => "frdate"}
%time{:datetime => "#{article.date.strftime('%Y-%m-%d')}"}= article.date.strftime('%Y %b %d')
%p.meta_inline{style: 'margin-left: 5%;'}
%i.fa.fa-arrow-right
= link_to 'browse articles archive', '/articles.html'
%br
%h1.section
Essays
%a.inline{:href => '/feed-essays.xml'}
%i.fa.fa-rss
- if blog('essays').articles.size > 2
- blog('essays').articles[0...3].each do |essay|
%p.hpost
%i.fa.fa-leaf
= link_to essay.title, essay.url
%span{:class => "frdate"}
%time{:datetime => "#{essay.date.strftime('%Y-%m-%d')}"}= essay.date.strftime('%Y %b %d')
-else
- blog('essays').articles.each do |essay|
%p.hpost
%i.fa.fa-leaf
= link_to essay.title, essay.url
%time{:datetime => "#{essay.date.strftime('%Y-%m-%d')}"}= essay.date.strftime('%Y %b %d')
%p.meta_inline{style: 'margin-left: 5%;'}
%i.fa.fa-arrow-right
= link_to 'browse essays archive', '/essays.html'
%h1.section
Projects
%i.fa.fa-terminal
%i.fa.fa-code
= link_to 'argosnap', 'https://github.com/atmosx/argosnap'
%span{:class => "project_description"}
Enhanced tarsnap notifications.
However, the articles are empty. I’m not getting an error or exception, meaning no HAML syntax error, the articles
object exists and is a list of objects, which have the methods, I tested article.methods.sort.join(', ')
returns the expected set of methods, but the article titles do not get displayed. Here is a sample HTML result block:
<p class='hpost'>
<i class='fa fa-pencil'></i>
<a href="/articles/2016/10/01/security-policies-for-remote-workers.html"></a>
<span class='frdate'>
<time datetime='2016-10-01'>2016 Oct 01</time>
</span>
</p>
As you can see the article.title
is empty. My directory source
layout is like:
404.html.haml
articles
2007-03-15-Tourkia-Ellada-kai-EE.markdown
2008-04-27-Pws-na-kerdisete-thn-sympatheia-twn-petherikwn-sas.markdown
2009-03-06-taksidi-sto-verolino.markdown
[...]
articles.html.haml
articles_category.html.haml
assets
essays
essays.html.haml
essays_category.html.haml
fonts
index.html.haml
javascripts
layouts
pages
partials
stylesheets
Ideas / thoughts are welcome!
Best Regards,
atmosx