feat: show at least n posts and configure last text

This commit is contained in:
2026-04-26 22:02:41 +02:00
parent 65f4dd1ac5
commit 99867aa03e
12 changed files with 45 additions and 32 deletions
+9 -5
View File
@@ -3,15 +3,17 @@ import { ref, onBeforeMount } from 'vue'
import { listArticles } from '@lib/articles'
import type { ArticleMetadata } from '@interfaces'
import { simpleDateFormat } from '@lib/dates'
import { TITLE } from '@lib/meta'
import { HOME_COUNT, PROD, PUBLISHED_ON, TITLE } from '@lib/config'
import PageFooter from '@components/PageFooter.vue'
import { stripHTML } from '@/lib/strings'
import NavBar from '@/components/NavBar.vue'
import NavBar from '@components/NavBar.vue'
const articles = ref<ArticleMetadata[]>([])
onBeforeMount(async () => {
const newArticles = await listArticles()
const newArticles = (await listArticles())
.filter((metadata) => (!metadata.draft || !PROD) && metadata.path)
.slice(0, HOME_COUNT)
articles.value.splice(0, articles.value.length, ...newArticles)
window.document.title = stripHTML(TITLE) + ' — Home'
})
@@ -21,10 +23,12 @@ onBeforeMount(async () => {
<main class="home">
<NavBar />
<template v-for="(metadata, index) in articles" v-bind:key="index">
<div v-if="!metadata.draft && metadata.path" class="article-item">
<div v-if="(!metadata.draft || !PROD) && metadata.path" class="article-item">
<RouterLink :to="metadata.path">
<h2 v-html="metadata.title"></h2>
<span class="article-published">Published on {{ simpleDateFormat(metadata.date) }}</span>
<span class="article-published"
><span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(metadata.date) }}</span
>
<img
v-if="metadata.thumbnail"
alt="thumbnail"