Files
vue-journal-layer/app/composables/useJournalLinks.ts
Jakub Zych c408eeb2ca feat: Journal list, category pages, pagination, tokens and pl/en strings
- index and category pages paginate with ?page=N and 404 out of range
- category content renders above the list through the html gate
- related posts fall back to the latest posts
- --journal-* tokens and neutral base styles
- pl/en strings registered only for locales the app enables
2026-10-09 18:02:48 +02:00

24 lines
1.1 KiB
TypeScript

// Links to Journal views, built from stable route names through
// useLocalePath() (i18n gives every route a per-locale name), never from
// concatenated paths. A link to a disabled view (journal.routes.<key>: false)
// is null; components then render plain text.
import { JOURNAL_ROUTE_NAMES } from '../utils/routes.ts'
import type { JournalRoutes } from '../utils/types.ts'
export function useJournalLinks() {
const localePath = useLocalePath()
const routes = (useRuntimeConfig().public.journal as { routes: JournalRoutes }).routes
const link = (key: keyof JournalRoutes, params?: Record<string, string>, query?: Record<string, string>) =>
routes[key] === false ? null : localePath({ name: JOURNAL_ROUTE_NAMES[key], params, query })
return {
postLink: (slug: string) => link('post', { slug }),
categoryLink: (slug: string) => link('category', { category: slug }),
tagLink: (slug: string) => link('tag', { tag: slug }),
authorLink: (slug: string) => link('author', { author: slug }),
indexLink: (page: number = 1) => link('index', undefined, page > 1 ? { page: String(page) } : undefined),
}
}