feat: show at least n posts and configure last text
This commit is contained in:
@@ -5,10 +5,10 @@ import { loadArticle } from '@lib/articles'
|
||||
import { useRoute, onBeforeRouteUpdate, type RouteLocation } from 'vue-router'
|
||||
import NotFoundView from './NotFoundView.vue'
|
||||
import { simpleDateFormat } from '@lib/dates'
|
||||
import { BACK_LINK, SIGNATURE, TITLE } from '@lib/meta'
|
||||
import { BACK_LINK, PUBLISHED_ON, SIGNATURE, TITLE } from '@lib/config'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { stripHTML } from '@/lib/strings'
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
import NavBar from '@components/NavBar.vue'
|
||||
|
||||
const article = ref<Article | null>(null)
|
||||
const loading = ref<boolean>(true)
|
||||
@@ -40,8 +40,7 @@ onBeforeRouteUpdate(loadPage)
|
||||
<RouterLink class="link-home" to="/"><i icon="undo-2">↑</i></RouterLink>
|
||||
<h1 class="article-title" v-html="article.metadata.title"></h1>
|
||||
<div class="article-published">
|
||||
{{ article.metadata.draft ? 'Drafted on' : 'Published on' }}
|
||||
{{ simpleDateFormat(article.metadata.date) }}
|
||||
<span v-html="PUBLISHED_ON"></span> {{ simpleDateFormat(article.metadata.date) }}
|
||||
</div>
|
||||
<img
|
||||
v-if="article.metadata.thumbnail"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { TITLE } from '@/lib/meta'
|
||||
import { stripHTML } from '@/lib/strings'
|
||||
import { TITLE } from '@lib/config'
|
||||
import { stripHTML } from '@lib/strings'
|
||||
import PageFooter from '@components/PageFooter.vue'
|
||||
import { onBeforeMount } from 'vue'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user