Skip to content

Commit

Permalink
Merge pull request #394 from phansch/notes-feature
Browse files Browse the repository at this point in the history
Add notes feature and first note
  • Loading branch information
phansch authored Jul 20, 2024
2 parents 2536b1c + 1c735fb commit 7094b0d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
7 changes: 7 additions & 0 deletions content/notes/2024-07-20-a-first-note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+++
title = "A notes section for the website"
+++

I decided I want to write more on here, but I also don't want the pressure of writing a full blog post every time I get the urge to write. So I set up this notes section that gives me a separate space to dump my current thoughts without much editing.

So here goes my first note.
4 changes: 4 additions & 0 deletions content/notes/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
+++
page_template = "post.html"
sort_by = "date"
+++
10 changes: 10 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@
{% endif %}
</div>
{% endmacro timeline_item_post %}

{% macro timeline_item_note(item) %}
{{ item[0].date | date(format='%Y-%m-%d') }}: Published new note: '<a href="{{ item[0].permalink }}">{{ item[0].title }}</a>'

<div class="body">
{% if item[0].extra.excerpt %}
<span class="greater-than"></span> {{ item[0].extra.excerpt }}
{% endif %}
</div>
{% endmacro timeline_item_note %}
15 changes: 11 additions & 4 deletions templates/macros/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@

{% macro timeline(g_timeline, limit=-1) %}
{% set posts = get_section(path="posts/_index.md") %}
{% set timeline_with_posts = g_timeline | concat(with=posts.pages) %}
{% set notes = get_section(path="notes/_index.md") %}
{% set timeline_with_posts = g_timeline | concat(with=posts.pages) | concat(with=notes.pages) %}
{% set timeline_with_posts = timeline_with_posts | sort(attribute="date") | reverse %}
{% if limit > -1 %}
{% set timeline_with_posts = timeline_with_posts | slice(end=10) %}
{% endif %}

{% for entry in timeline_with_posts %}
{% set entry_type = entry.type | default(value="post") %}
{% set entry_type = entry.type | default(value="post_or_note") %}

<article class="timeline-entry {{ entry_type }}">
{% if entry_type == "code" %}
{{ macros::timeline_item_code(item=[entry]) }}
{% elif entry_type == "post" %}
{{ macros::timeline_item_post(item=[entry]) }}
{% elif entry_type == "post_or_note" %}
{% set ancestors = get_section(path=entry.ancestors[1]) %}
{% set type = ancestors.components[0] %}
{% if type == "posts" %}
{{ macros::timeline_item_post(item=[entry]) }}
{% elif type == "notes" %}
{{ macros::timeline_item_note(item=[entry]) }}
{% endif %}
{% elif entry_type == "docs" %}
{{ macros::timeline_item_docs(item=[entry]) }}
{% elif entry_type == "reading" %}
Expand Down

0 comments on commit 7094b0d

Please sign in to comment.