Adds micro posts to the home page

Adds support for displaying microposts (e.g. Mastodon toots) on the home
page. This includes adding a new "secondarysections" parameter to the
configuration, updating the index layout to display these posts, and
adding a default comment section to the micro archetype.
This commit is contained in:
fundor333
2025-05-28 13:07:13 +02:00
parent 00fc72ae23
commit bbde4caedf
4 changed files with 25 additions and 0 deletions

View File

@@ -10,5 +10,10 @@ repost:
like: like:
rsvp: rsvp:
bookmark: bookmark:
comments:
host: mastodon.social
username: fundor333
id:
--- ---

View File

@@ -10,6 +10,7 @@ defaultColor:
# the default value is set to 'auto'. # the default value is set to 'auto'.
# You can take a look at layouts/index.html for more information. # You can take a look at layouts/index.html for more information.
mainSections: ["post", "photos", "weeknote"] mainSections: ["post", "photos", "weeknote"]
secondarysections: ["micro"]
feedSections: ["post", "photos", "micro", "weeknote"] feedSections: ["post", "photos", "micro", "weeknote"]
commentSections: ["post", "photos", "micro", "weeknote"] commentSections: ["post", "photos", "micro", "weeknote"]
suggestionSections: ["post"] suggestionSections: ["post"]

View File

@@ -12,6 +12,11 @@ repost:
like: like:
rsvp: rsvp:
bookmark: bookmark:
comments:
host: mastodon.social
username: fundor333
id: 114581620705519039
--- ---
#Pocket is closing and I had rework all the stuff I got into my personal #Django server. #Pocket is closing and I had rework all the stuff I got into my personal #Django server.

View File

@@ -32,6 +32,20 @@
{{ end }} {{ end }}
</p> </p>
{{ end }} {{ end }}
<h3 class="posts-item-note" aria-label="Recent status/toots/micropost">{{ T "home.recent_posts" }}</h3>
{{/* Show last 10 posts in reverse date order */}}
{{ $pagesToShow := where .Site.RegularPages "Type" "in" site.Params.secondarysections }}
{{ $posts := $pagesToShow.ByDate.Reverse }}
{{ range first 10 $posts }}
{{ partial "postCard" . }}
{{ end }}
{{ if gt (len $posts) 5 }}
<p>
{{ range $firstSection := (where .Site.Sections "Section" "in" (first 1 (.Site.Params.mainSections))) }}
<a href="{{ $firstSection.Permalink }}">{{ T "home.see_all_posts" }}</a>
{{ end }}
</p>
{{ end }}
</main> </main>
</div> </div>
{{- partial "footer.html" . -}} {{- partial "footer.html" . -}}