feat: show at least n posts and configure last text
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user