More things

This commit is contained in:
2026-10-01 02:29:21 +02:00
parent e1df4d3ae1
commit 13b659662e
54 changed files with 4409 additions and 911 deletions

View File

@@ -1,11 +1,11 @@
<script setup lang="ts">
/* The article route is a thin host for the book that ArticleBookStack draws.
The open-article middleware has already laid the article on the library's
shelf — that is what the page in view is made of, and what the stack of
open pages is filed under — so all that is left to do here is speak for the
URL: the title, and the visitor's "recently viewed" line.
When nothing lives at the address, this is what says so, over the top of
whatever else is open. */
/* The short address — /wiki/<slug>, the shape a wiki link to [[Bayes Theorem]]
writes and an old bookmark holds — names no language. The open-article
middleware reads which document the slug speaks and turns the address onto
that version's own, /wiki/en/bayes-theorem, so this page is what is left of
it: the words said when the wiki has nothing at the slug, or the API has no
answer about it — an address worth writing, over the top of whatever else is
open. */
definePageMeta({ middleware: 'open-article' })
const route = useRoute()
@@ -14,34 +14,33 @@ const slug = computed(() => String(route.params.slug))
const { t } = useI18n()
const { th } = useAppLocale()
const { get, unreadable } = useArticleLibrary()
const article = computed(() => get(slug.value))
const { record } = useRecentlyViewed()
watch(
article,
(a) => {
if (import.meta.client && a?.slug && a?.title) record({ slug: a.slug, title: a.title })
},
{ immediate: true }
)
useSeoMeta({
title: () => article.value?.title ?? t('card.kickerArticle'),
})
/* what the shelf could not bring in, the API said why */
const missingStatus = computed(() => (article.value ? 0 : unreadable.value[slug.value] ?? 0))
const missingStatus = computed(() => (get(slug.value) ? 0 : unreadable.value[slug.value] ?? 0))
useSeoMeta({ title: () => t('card.kickerArticle') })
/* a missing address was never laid on the book, so "back" leads to whatever
else is open: the last of the pages still in the stack, if there are any. */
const { tabs } = useArticleTabs()
const backHref = computed(() => {
const last = tabs.value[tabs.value.length - 1]
return last ? tabHref(last) : null
})
</script>
<template>
<div class="reader-host">
<div v-if="!article" class="reader-note">
<div class="reader-note">
<div class="empty" style="padding-top: 64px">
<template v-if="missingStatus === 404">
<div class="glyph">∄</div>
<h3>{{ t('reader.notFoundTitle') }}</h3>
<p v-html="th('reader.notFoundText', { path: `/wiki/${slug}` })"></p>
<NuxtLink to="/new" class="btn btn-primary">{{ t('reader.writeTopic') }}</NuxtLink>
<div class="empty-actions">
<NuxtLink to="/new" class="btn btn-primary">{{ t('reader.writeTopic') }}</NuxtLink>
<NuxtLink v-if="backHref" :to="backHref" class="btn btn-ghost">{{ t('reader.backToArticles') }}</NuxtLink>
</div>
</template>
<template v-else>
<div class="glyph">!</div>