From fd8023989634e395d4abbf489db221f9311256d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 25 Aug 2025 21:34:26 +0200 Subject: [PATCH] Implement mini blog on home page, third try --- docs/.vuepress/client.js | 8 ++ docs/.vuepress/components/MiniBlog.vue | 156 ++++++++++++++++++------- docs/.vuepress/config.js | 35 +++++- docs/.vuepress/styles/palette.scss | 2 +- 4 files changed, 158 insertions(+), 43 deletions(-) create mode 100644 docs/.vuepress/client.js diff --git a/docs/.vuepress/client.js b/docs/.vuepress/client.js new file mode 100644 index 0000000..08ee6d0 --- /dev/null +++ b/docs/.vuepress/client.js @@ -0,0 +1,8 @@ +import { defineClientConfig } from "vuepress/client"; +import MiniBlog from "./components/MiniBlog.vue"; + +export default defineClientConfig({ + enhance({ app }) { + app.component("MiniBlog", MiniBlog); + }, +}); diff --git a/docs/.vuepress/components/MiniBlog.vue b/docs/.vuepress/components/MiniBlog.vue index 1ce14b9..73f697e 100644 --- a/docs/.vuepress/components/MiniBlog.vue +++ b/docs/.vuepress/components/MiniBlog.vue @@ -1,64 +1,138 @@ diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 95c50e5..b4d6954 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -33,5 +33,38 @@ export default defineUserConfig({ '/fr/': { lang: 'fr-FR', }, - } + }, + plugins: [ + { + name: "collect-article-true", + async onPrepared(app) { + const rows = app.pages + .filter((p) => p.frontmatter?.article === true || p.frontmatter?.article === "true") + .map((p) => { + const fm = p.frontmatter || {}; + // gängige Cover-Keys im Theme Hope Umfeld: + const cover = fm.cover || fm.image || fm.banner || fm.heroImage || null; + // kurze Beschreibung / Excerpt + const excerpt = p.excerpt || fm.description || ""; + return { + path: p.path, + title: p.title || fm.title || "", + date: fm.date || null, // ISO empfohlen + tags: Array.isArray(fm.tags) ? fm.tags : (fm.tag ? [].concat(fm.tag) : []), + category: Array.isArray(fm.category) ? fm.category : (fm.categories ? fm.categories : []), + cover, + excerpt, + locale: p.pathLocale || "/", + }; + }) + .sort((a, b) => { + const ta = a.date ? Date.parse(a.date) : 0; + const tb = b.date ? Date.parse(b.date) : 0; + return tb - ta; + }); + + await app.writeTemp("mini-blog.articles.json", JSON.stringify(rows, null, 2)); + }, + }, + ], }) diff --git a/docs/.vuepress/styles/palette.scss b/docs/.vuepress/styles/palette.scss index e2437db..26112a6 100644 --- a/docs/.vuepress/styles/palette.scss +++ b/docs/.vuepress/styles/palette.scss @@ -240,7 +240,7 @@ h2.large-header { line-height: 1.2em; text-align: center; margin-top: 0; - padding-top: 1.8em; + padding-top: 2.8em !important; border: 0; }