Skip to content

Commit

Permalink
Merge pull request #397 from phansch/notes-2
Browse files Browse the repository at this point in the history
Add notes listing page / refactor
  • Loading branch information
phansch authored Jul 22, 2024
2 parents 7094b0d + e55df51 commit 76931e7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions content/notes/_index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
+++
title = "Recent Notes"
template = "notes.html"
page_template = "post.html"
sort_by = "date"
+++
11 changes: 11 additions & 0 deletions templates/macros/post_meta.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% import "macros/time_to_read.html" as util %}
{% macro post_meta(resource) %}
<p class="meta">
<a href="{{ resource.permalink }}" class="u-url" title="Permalink">
<em>
<time class="dt-published" datetime="{{ resource.date }}">{{ resource.date | date(format="%d %b %Y") }}</time>
</em>
</a>,
<em>{{ util::time_to_read(content=resource.content) }}</em>
</p>
{% endmacro post_meta %}
12 changes: 12 additions & 0 deletions templates/notes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "base.html" %}
{% import "macros/post_meta.html" as macros %}

{% block content %}
<h2>{{ section.title }}</h2>
{% for note in section.pages %}
{{ macros::post_meta(resource=note) }}
<h3>{{ note.title }}</h3>
{{ note.content | safe}}
<hr />
{% endfor %}
{% endblock content %}
11 changes: 2 additions & 9 deletions templates/post.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% import "macros/time_to_read.html" as util %}
{% import "macros/post_meta.html" as foo %}
{% import "macros/toc.html" as macros %}

{% block title %}{{ page.title }}{% endblock title %}
Expand All @@ -16,14 +16,7 @@
<div class="post">
<article class="col h-entry">
<h1 class="p-name">{{ page.title }}</h1>
<p class="meta">
<a href="{{ page.permalink }}" class="u-url" title="Permalink">
<em>
<time class="dt-published" datetime="{{ page.date }}">{{ page.date | date(format="%d %b %Y") }}</time>
</em>
</a>,
<em>{{ util::time_to_read(content=page.content) }}</em>
</p>
{{ foo::post_meta(resource=page) | safe }}
<div class="e-content">{{ macros::replace_toc(resource=page) | safe }}</div>
</article>
<hr />
Expand Down

0 comments on commit 76931e7

Please sign in to comment.