Last active
April 28, 2017 20:55
-
-
Save anthonymoralez/75cc0607e19fdf956485d514736c2473 to your computer and use it in GitHub Desktop.
Adding Tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html lang='en'> | |
| <head> | |
| <!-- Elided: a bunch of header stuff --> | |
| </head> | |
| <body> | |
| <nav class='navbar navbar-inverse' > | |
| <div class='container-fluid'> | |
| <div class='collapse navbar-collapse' > | |
| <!-- Elided: Navbar top of the page --> | |
| </div> | |
| </div> | |
| </nav> | |
| <section class='content'> | |
| <%= yield %> | |
| </section> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML> | |
| <html lang='en'> | |
| <head> | |
| <!-- Elided: a bunch of header stuff --> | |
| </head> | |
| <body> | |
| <nav class='navbar navbar-inverse' > | |
| <div class='container-fluid'> | |
| <div class='collapse navbar-collapse' > | |
| <!-- Elided: Navbar top of the page --> | |
| </div> | |
| </div> | |
| </nav> | |
| <section class='container'> | |
| <div class="row"> | |
| <div class="col-md-8"> | |
| <%= yield %> | |
| </div> | |
| <% if content_for(@item, :tags) %> | |
| <div class="col-md-3"> | |
| <div class="tags panel panel-default affix"> | |
| <div class="panel-heading">Tags</div> | |
| <div class="panel-body"> | |
| <%= content_for(@item, :tags) || '(none)' %> | |
| </div> | |
| </div> | |
| </div> | |
| <% end %> | |
| </div> | |
| </section> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% render '/default.html' do %> | |
| <% content_for :tags, tags_for(@item, base_url: "/") %> | |
| <div class="post panel panel-default"> | |
| <div class="panel-heading"> | |
| <h3 class="panel-title"><%= item[:title] %></h3> | |
| <aside>Posted at: <%= get_pretty_date(item) %></aside> | |
| </div> | |
| <article class="panel-body"> | |
| <%= yield %> | |
| </article> | |
| </div> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% render '/default.html' do %> | |
| <div class="panel panel-default"> | |
| <div class="panel-heading"> | |
| <h3 class="panel-title"><%= item[:title] %></h3> | |
| <aside>Posted at: <%= get_pretty_date(item) %></aside> | |
| </div> | |
| <article class="panel-body"> | |
| <%= yield %> | |
| </article> | |
| </div> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| preprocess do | |
| tags = @items.map { |i| i[:tags] }.flatten.uniq | |
| tags.each do |tag| | |
| next unless tag | |
| content = '' | |
| attributes = { tag: tag } | |
| identifier = "/tags/#{tag}" | |
| @items.create(content, attributes, identifier) | |
| end | |
| end | |
| compile '/tags/*' do | |
| layout '/tags.*' | |
| end | |
| route '/tags/*' do | |
| '/' + item.identifier.to_s.split('/')[-1] + '/index.html' | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| compile '/posts/**.md' do | |
| filter :kramdown | |
| filter :gists | |
| layout '/post.*' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment