Compare commits

..

13 commits
v0.1.0 ... main

6 changed files with 85 additions and 50 deletions

View file

@ -1,35 +0,0 @@
---
name: 'deploy'
on:
push:
tags:
- 'v*'
jobs:
deploy:
runs-on: docker
steps:
- name: Cloning repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Github remote
run: |
mkdir -p $HOME/.ssh
echo "${{ secrets.PUBLISH_TO_GITHUB_KEY }}" > $HOME/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
chmod 600 $HOME/.ssh/*
chmod 700 $HOME/.ssh
git config --global user.name 'Leon Mika'
git config --global user.email 'lmika@lmika.org'
git remote add downstream git@github.com:lmika/postlist-for-micro.blog.git
- name: Push main to Github
run: |
git checkout main
git pull origin main
git push downstream main
- name: Push tags to Github
run: |
git fetch origin --tags
git push downstream --tags

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.DS_Store

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2025 lmika
Copyright (c) 2025 Leon Mika
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View file

@ -1,3 +1,15 @@
# postlist-for-micro.blog
# Postlist for Micro.blog
A shortcode for post-list
A Micro.blog plugin for adding a shortcode for displaying a dynamic list of posts, similar to [Bear Blog's post macro](https://docs.bearblog.dev/embedding-blog-post-lists/).
## Installing
To install on your Micro.blog site, go to the plugin directory and search for "postlist".
Once installed, you can add a post list to your site by using the `postlist` short-code:
```
{{< postlist >}}
```
See [the usage guide](https://postlist.micro.blog/) for how you can customise this post list, including filtering to posts matching a given category, or changing the sort order.

View file

@ -5,17 +5,66 @@
{{- $pgr = (where $pgr "Params.categories" "intersect" (slice .)) -}}
{{- end -}}
{{- end -}}
{{- if (eq (.Get "order") "link-title" ) -}}
{{- $pgr = $pgr.ByLinkTitle -}}
{{- if (ne (.Get "order") "") -}}
{{- $order := split (.Get "order") " " -}}
{{- if (eq (index $order 0) "alpha" ) -}}
{{- $pgr = $pgr.ByLinkTitle -}}
{{- else if (eq (index $order 0) "date" ) -}}
{{- $pgr = $pgr.ByDate -}}
{{- end -}}
{{- if (and (eq (len $order) 2) (eq (index $order 1) "desc")) -}}
{{- $pgr = $pgr.Reverse -}}
{{- end -}}
{{- end -}}
<ul class="postlist">
{{ range $pgr }}
{{- if (ne .LinkTitle "") -}}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{- else if (ne .Summary "") -}}
<li><a href="{{ .RelPermalink }}">{{ .Summary | safeHTML | truncate 70 }}</a></li>
{{- if (ne (.Get "limit") "") -}}
{{- $pgr = $pgr.Limit (int (.Get "limit")) -}}
{{- end -}}
{{- if (eq (.Get "display") "content") -}}
{{ if templates.Exists "partials/_postlist/post-content-before.html" }}
{{ partial "_postlist/post-content-before.html" $pgr }}
{{ end }}
<div class="postlist postlist-display-content h-feed">
{{ range $pgr }}
{{ if templates.Exists "partials/_postlist/post-content.html" }}
{{ partial "_postlist/post-content.html" . }}
{{ else }}
<div class="h-entry">
{{ if .Title }}
<h2 class="p-name"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
{{ if .Params.custom_summary }}
<div class="p-summary">
<p>{{ .Summary | safeHTML }}<p>
</div>
{{ else }}
<div class="e-content">
{{ .Content }}
</div>
{{ end }}
{{ else }}
<div class="e-content">
{{ .Content }}
</div>
{{ end }}
</div>
{{ end }}
{{ end }}
</div>
{{ if templates.Exists "partials/_postlist/post-content-after.html" }}
{{ partial "_postlist/post-content-after.html" $pgr }}
{{ end }}
{{- else -}}
<li><a href="{{ .RelPermalink }}">{{ .Content | safeHTML | truncate 70 }}</a></li>
{{ end }}
{{ end }}
</ul>
<ul class="postlist">
{{ range $pgr }}
{{- if (ne .LinkTitle "") -}}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{- else if (ne .Summary "") -}}
<li><a href="{{ .RelPermalink }}">{{ .Summary | safeHTML | truncate 70 }}</a></li>
{{- else -}}
<li><a href="{{ .RelPermalink }}">{{ .Content | safeHTML | truncate 70 }}</a></li>
{{ end }}
{{ end }}
</ul>
{{- end -}}

8
plugin.json Normal file
View file

@ -0,0 +1,8 @@
{
"version": "1.2.0",
"title": "Postlist",
"description": "Shortcode for dynamically adding a list of posts",
"includes": [
"/postlist.css"
]
}