use preprocessor
This commit is contained in:
parent
444ce9ae7a
commit
84dfdf596f
5 changed files with 16 additions and 9 deletions
2
Rules
2
Rules
|
@ -25,6 +25,8 @@ preprocess do
|
|||
ignore_old_content('blog', 'events', 'about/verslagen') if development?
|
||||
|
||||
update_blog_attributes
|
||||
convert_tags('Blog')
|
||||
convert_tags('Events')
|
||||
create_yearly_items('Blog')
|
||||
create_yearly_items('Events')
|
||||
create_tagly_items('Blog')
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
<div class="blogpreview-tags">
|
||||
<% post[:tags]&.each do |tag| %>
|
||||
<!-- The following code is a bit hacky, fix when necessary -->
|
||||
<a class="tag is-normal is-rounded" href=<%= "/blog/#{tag.split.map(&:capitalize).join('_')}/index.html" %>>
|
||||
<%= tag.split.map(&:capitalize).join(' ') %>
|
||||
<a class="tag is-normal is-rounded" href=<%= "/blog/#{tag.gsub(' ', '_')}/index.html" %>>
|
||||
<%= tag %>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -18,7 +18,6 @@ module ArchiveHelper
|
|||
Set.new(items
|
||||
.find_all('/blog/*/*')
|
||||
.flat_map { |i| i[:tags] || [] })
|
||||
.map{ |y| y.split.map(&:capitalize).join(' ') }
|
||||
.to_a
|
||||
.sort
|
||||
.uniq.map { |y| [y, items["/blog/#{y.gsub(' ', '_')}.html"]]}
|
||||
|
@ -36,7 +35,7 @@ module ArchiveHelper
|
|||
def posts_with_tag(tag)
|
||||
items
|
||||
.find_all('/blog/*/*')
|
||||
.filter{|i| (i[:tags] || []).map{ |t| t.split.map(&:capitalize).join(' ') }.include? tag }
|
||||
.filter{|i| (i[:tags] || []).include? tag }
|
||||
end
|
||||
|
||||
def posts_in_year_or_with_tag(item)
|
||||
|
|
|
@ -25,10 +25,7 @@ module EventsHelper
|
|||
|
||||
def all_events_by_tag(tag = nil, soon = nil)
|
||||
@items.find_all('/events/*/*.md')
|
||||
.filter { |i|
|
||||
(i[:tags] || [])
|
||||
.map{ |t| t.split.map(&:capitalize).join(' ') }
|
||||
.include? tag }
|
||||
.filter { |i| (i[:tags] || []).include? tag }
|
||||
.select { |x| x[:soon] == soon }
|
||||
.sort_by { |x| x[:time] }
|
||||
end
|
||||
|
|
|
@ -88,7 +88,6 @@ module PreprocessHelper
|
|||
type = type.to_s
|
||||
tags = @items.find_all("/#{type.downcase}/*/*")
|
||||
.flat_map { |i| i[:tags] || [] }
|
||||
.flat_map { |i| i.split.map(&:capitalize).join(' ') }
|
||||
.uniq
|
||||
|
||||
tags.each do |tag|
|
||||
|
@ -121,6 +120,16 @@ module PreprocessHelper
|
|||
end
|
||||
end
|
||||
|
||||
def convert_tags(type)
|
||||
type = type.to_s
|
||||
@items.find_all("/#{type.downcase}/*/*").each do |item|
|
||||
if item.key?(:tags)
|
||||
item[:tags] = item[:tags]
|
||||
.map{ |tag| tag.split.map(&:capitalize).join(' ') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def add_report_metadata
|
||||
@items.find_all('/about/verslagen/*/*').each do |report|
|
||||
report[:academic_year] = report.identifier.to_s.split('/')[-2]
|
||||
|
|
Loading…
Reference in a new issue