-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
30 lines (25 loc) Β· 715 Bytes
/
Copy pathapp.rb
File metadata and controls
30 lines (25 loc) Β· 715 Bytes
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
require 'decant'
require 'kramdown'
require 'kramdown-parser-gfm'
require 'sinatra'
require_relative 'lib/kramdown_enhancements'
# Define a frontmatter-aware content collection wrapper.
Page = Decant.define(dir: 'content', ext: 'md') do
frontmatter :title
def source_url
"https://github.com/benpickles/parklife.dev/blob/main/content/#{relative_path}"
end
end
# Configure Sinatra's Markdown rendering (Kramdown will be used because it's
# required above).
set :markdown,
input: 'GFM',
smartypants: true,
views: 'content'
get '/*slug' do
slug = params[:slug].empty? ? 'home' : params[:slug]
@page = Page.find(slug)
@page_title = @page.title
@source_url = @page.source_url
erb :page
end