mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-26 09:15:50 +00:00
put multiple posts on the home page
This commit is contained in:
parent
6a9b6da4d5
commit
1d0e7fd36c
4 changed files with 176 additions and 46 deletions
33
bin/rss.rb
33
bin/rss.rb
|
|
@ -31,23 +31,24 @@ class Blag
|
|||
end
|
||||
|
||||
def generate!
|
||||
generate_latest_post_json
|
||||
generate_latest_posts_json
|
||||
generate_rss
|
||||
end
|
||||
|
||||
def generate_latest_post_json
|
||||
post = latest_post
|
||||
data['latest'] = {
|
||||
title: post['title'],
|
||||
date: post['date'],
|
||||
timestamp: post['timestamp'],
|
||||
tags: post['tags'],
|
||||
author: post['author'],
|
||||
url: post['relative_url'],
|
||||
link: post['link'],
|
||||
styles: post['styles'],
|
||||
body: post['body']
|
||||
}.delete_if { |k, v| v.nil? }
|
||||
def generate_latest_posts_json
|
||||
data['posts'] = latest_posts.map do |post|
|
||||
{
|
||||
title: post['title'],
|
||||
date: post['date'],
|
||||
timestamp: post['timestamp'],
|
||||
tags: post['tags'],
|
||||
author: post['author'],
|
||||
url: post['relative_url'],
|
||||
link: post['link'],
|
||||
styles: post['styles'],
|
||||
body: post['body']
|
||||
}.delete_if { |k, v| v.nil? }
|
||||
end
|
||||
json = JSON.pretty_generate data
|
||||
File.open(data_file, 'w') { |f| f.puts json }
|
||||
end
|
||||
|
|
@ -56,8 +57,8 @@ class Blag
|
|||
File.open(rss_file, 'w') { |f| f.puts feed_xml.target! }
|
||||
end
|
||||
|
||||
def latest_post
|
||||
posts.first
|
||||
def latest_posts(n = @num_posts)
|
||||
posts.first(n)
|
||||
end
|
||||
|
||||
def find_post dir, slug
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -326,6 +326,8 @@ body.projects:not(.index) .container {
|
|||
|
||||
article {
|
||||
|
||||
word-wrap: break-word;
|
||||
|
||||
header {
|
||||
|
||||
h2 {
|
||||
|
|
@ -351,6 +353,7 @@ article {
|
|||
|
||||
blockquote {
|
||||
margin-left: 6%;
|
||||
font-family: 'Helvetica Neue', 'Verdana', 'Roboto', sans-serif;
|
||||
font-style: italic;
|
||||
color: lighten(@text, 15%);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,35 @@
|
|||
<% var post = public._data.latest -%>
|
||||
<% var posts = public._data.posts -%>
|
||||
<% for (var i in posts) { -%>
|
||||
|
||||
<% var post = posts[i] -%>
|
||||
|
||||
<% if (post.link) { -%>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<h2><a href="<%= post.link %>"><%= post.title %></a></h2>
|
||||
<time><%= post.date %></time>
|
||||
</header>
|
||||
<%- partial(post.url) %>
|
||||
<p><a class="permalink" href="<%= post.url %>">∞</a></p>
|
||||
</article>
|
||||
|
||||
<% } else { -%>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<h2><a href="<%= post.url %>"><%= post.title %></a></h2>
|
||||
<time><%= post.date %></time>
|
||||
</header>
|
||||
<%- partial(post.url) %>
|
||||
</article>
|
||||
|
||||
<% } -%>
|
||||
|
||||
<% if (i < posts.length - 1) { -%>
|
||||
<div class="row clearfix">
|
||||
<p class="fin"><i class="fa fa-code"></i></p>
|
||||
</div>
|
||||
<% } -%>
|
||||
|
||||
<% if (post.link) { -%>
|
||||
<article>
|
||||
<header>
|
||||
<h2><a href="<%= post.link %>"><%= post.title %></a></h2>
|
||||
<time><%= post.date %></time>
|
||||
</header>
|
||||
<%- post.body %>
|
||||
<p><a class="permalink" href="<%= post.url %>">∞</a></p>
|
||||
</article>
|
||||
<% } else { -%>
|
||||
<article>
|
||||
<header>
|
||||
<h2><a href="<%= post.url %>"><%= post.title %></a></h2>
|
||||
<time><%= post.date %></time>
|
||||
</header>
|
||||
<%- post.body %>
|
||||
</article>
|
||||
<% } -%>
|
||||
|
|
|
|||
Loading…
Reference in a new issue