This repository was archived by the owner on Apr 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.rb
More file actions
98 lines (77 loc) · 2.42 KB
/
Copy pathconfig.rb
File metadata and controls
98 lines (77 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
require 'active_support/all'
# CONFIG
set :markdown_engine, :redcarpet
set :css_dir, 'assets/stylesheets'
set :js_dir, 'assets/javascripts'
set :images_dir, 'assets/images'
activate :autoprefixer
activate :directory_indexes
activate :livereload
activate :contentful do |f|
f.access_token = ENV['CONTENTFUL_ACCESS_TOKEN']
f.space = { site: ENV['CONTENTFUL_SPACE'] }
f.content_types = {
page: ENV['CONTENTFUL_PAGE_KEY'],
blog_post: ENV['CONTENTFUL_BLOG_POST_KEY']
}
end
activate :deploy do |deploy|
deploy.method = :git
deploy.strategy = :force_push
end
configure :build do
activate :asset_hash
activate :minify_css
activate :minify_javascript
activate :relative_assets
end
# PAGES
helpers do
def menu_link(title, link)
unless page_classes[/(\S+\s+){#{1}}/].blank?
klass = (link == page_classes[/(\S+\s+){#{1}}/].strip ? 'active' : nil)
end
link_to title, "/#{link}", class: klass
end
end
page '/sitemap.xml', layout: false
data.site.page.each do |page|
page "/#{page[1][:slug].downcase}.html", proxy: '/pages/show.html', ignore: true do
@page = page[1]
@title = page[1][:title]
@slug = page[1][:slug]
@body = page[1][:body]
@position = page[1][:position]
end
end
data.site.blog_post.each do |post|
page "/blog/#{post[1][:slug]}.html", proxy: '/blog/show.html', ignore: true do
@post = post[1]
@title = post[1][:title]
@slug = post[1][:slug]
@body = post[1][:body]
@image = post[1][:image]
@date = post[1][:date]
@tags = post[1][:tags]
end
end
@recent_posts = data.site.blog_post.sort_by { |post| post[1][:date] }.reverse.first(5)
@archive_months = data.site.blog_post.map { |post| post[1][:date].strftime('%B %Y') }.uniq
@archive_months.each do |date_string|
date = Date.parse(date_string)
page "/blog/archive/#{date.strftime("%Y")}/#{date.strftime("%m")}.html", proxy: '/blog/archive.html', ignore: true do
@date = date.strftime('%B %Y')
@archive_posts = data.site.blog_post.to_a.select do |post|
post[1][:date].strftime('%B %Y') == date.strftime('%B %Y')
end
end
end
@all_tags = data.site.blog_post.map { |post| post[1][:tags] }.flatten.uniq
@all_tags.each do |tag|
page "/blog/tags/#{tag}.html", proxy: '/blog/tag.html', ignore: true do
@tag = tag
@tag_posts = data.site.blog_post.to_a.select do |post|
post[1][:tags].include? tag
end
end
end