summaryrefslogtreecommitdiff
path: root/layouts/_shortcodes
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2026-01-22 23:12:06 +0800
committerBigCoke233 <hi@guhub.cn>2026-01-22 23:12:06 +0800
commitc61224f71c60e3c466ff7f48dd5fdeb2111552bb (patch)
treef03e19cbe86ca42a0ce64063934956fe29204d64 /layouts/_shortcodes
parent09d43c331031b07f121f5c00e4a49966e03d6fe3 (diff)
feat: display recently added bookmarks in linkroll page
Diffstat (limited to 'layouts/_shortcodes')
-rw-r--r--layouts/_shortcodes/linkding-bookmarks.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/layouts/_shortcodes/linkding-bookmarks.html b/layouts/_shortcodes/linkding-bookmarks.html
new file mode 100644
index 00000000..45109c2a
--- /dev/null
+++ b/layouts/_shortcodes/linkding-bookmarks.html
@@ -0,0 +1,62 @@
+{{/*
+Shortcode to display Linkding RSS feed bookmarks
+Usage: {{< linkding-bookmarks >}}
+*/}}
+
+{{/* Read the RSS feed file */}}
+{{ $rssFile := "data/linkding.xml" }}
+{{ if fileExists $rssFile }}
+ {{ $rssContent := readFile $rssFile }}
+
+ {{/* Parse RSS XML */}}
+ {{ $rss := $rssContent | transform.Unmarshal }}
+
+ {{ if $rss }}
+ {{/* Get channel items */}}
+ {{ $items := $rss.channel.item }}
+
+ {{ if $items }}
+ <div class="linkding-bookmarks">
+ {{ range $items }}
+ <div class="bookmark-item mb-4 p-4 rounded-md" style="background-color: var(--block-background-color);">
+ <h3 class="m-0 mb-2">
+ <a href="{{ .link }}" target="_blank" rel="noopener noreferrer"
+ style="color: var(--text-color); text-decoration: none;">
+ {{ .title }}
+ </a>
+ </h3>
+ {{ if .description }}
+ <p class="m-0 text-sm opacity-80">{{ .description }}</p>
+ {{ end }}
+ {{ if .category }}
+ <div class="mt-2 flex flex-wrap gap-2">
+ {{ if reflect.IsSlice .category }}
+ {{ range .category }}
+ <span class="text-secondary text-xs rounded"
+ style="background-color: var(--border-color-light);">
+ #{{ . }}
+ </span>
+ {{ end }}
+ {{ else }}
+ <span class="text-secondary text-xs rounded"
+ style="background-color: var(--border-color-light);">
+ #{{ .category }}
+ </span>
+ {{ end }}
+ </div>
+ {{ end }}
+ <div class="mt-2 text-xs opacity-60">
+ 于 {{ dateFormat "2006-01-02" .pubDate }} 添加至书签
+ </div>
+ </div>
+ {{ end }}
+ </div>
+ {{ else }}
+ <p>No bookmarks found in RSS feed.</p>
+ {{ end }}
+ {{ else }}
+ <p>Unable to parse RSS feed.</p>
+ {{ end }}
+{{ else }}
+ <p>RSS feed file not found. Please run the GitHub Action to fetch the feed.</p>
+{{ end }}