Files
mathew/frontend/app/pages/wiki/[slug]/index.vue
2026-10-01 02:29:21 +02:00

55 lines
2.2 KiB
Vue

<script setup lang="ts">
/* 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()
const slug = computed(() => String(route.params.slug))
const { t } = useI18n()
const { th } = useAppLocale()
const { get, unreadable } = useArticleLibrary()
/* what the shelf could not bring in, the API said why */
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 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>
<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>
<h3>{{ t('reader.loadFailTitle') }}</h3>
<p v-html="t('common.apiShort')"></p>
<NuxtLink to="/" class="btn btn-ghost">{{ t('common.backHome') }}</NuxtLink>
</template>
</div>
</div>
</div>
</template>