- server/lib/siteCachePurge.ts and the route, byte for byte from
vue-faq-layer (sha256 pinned in tests/sitePurge.test.ts)
- runtimeConfig.siteCache.purgeToken (NUXT_SITE_CACHE_PURGE_TOKEN) and the
'/api/__site__/**': { cache: false } route rule
- /api/__journal__/cache/purge, app/utils/siteCache.ts and
journal.cachePurgeToken unchanged, documented as aliases for one release
- version 0.4.0
77 lines
3.1 KiB
TypeScript
77 lines
3.1 KiB
TypeScript
// vue-journal-layer: reusable Journal views as a Nuxt layer. An app consumes
|
|
// it with `extends: ['vue-journal-layer']`.
|
|
//
|
|
// Every path below is absolute and built from this file's directory: a
|
|
// relative or ~ path in a layer config resolves against the consuming
|
|
// project, not the layer.
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const currentDir = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2025-07-15',
|
|
devtools: { enabled: false },
|
|
|
|
// The consuming app may have no app/pages directory; the Journal pages are
|
|
// registered by the journal module, so the router must be on regardless.
|
|
pages: true,
|
|
|
|
// Declared once here, so the app never re-lists them (two copies of
|
|
// @nuxtjs/i18n split locale state).
|
|
modules: ['@nuxt/fonts', '@nuxtjs/i18n', '@nuxtjs/seo', `${currentDir}lib/journal-module.ts`],
|
|
|
|
// Tokens first, then the neutral styles that use them. The app's own css
|
|
// array loads after these, so its token overrides win.
|
|
css: [`${currentDir}app/assets/css/journal-tokens.css`, `${currentDir}app/assets/css/journal-base.css`],
|
|
|
|
runtimeConfig: {
|
|
journal: {
|
|
// Server-only base for SSR fetches (NUXT_JOURNAL_API_BASE). It never
|
|
// comes from request input.
|
|
apiBase: 'http://127.0.0.1:8096/_journal/api/v1',
|
|
// Server-only bearer token of the old Journal purge route
|
|
// POST /api/__journal__/cache/purge (NUXT_JOURNAL_CACHE_PURGE_TOKEN),
|
|
// kept for one release; new sites use siteCache.purgeToken. Shorter
|
|
// than 32 characters, the route answers 404.
|
|
cachePurgeToken: '',
|
|
},
|
|
siteCache: {
|
|
// Server-only bearer token of the shared site cache purge route
|
|
// POST /api/__site__/cache/purge (NUXT_SITE_CACHE_PURGE_TOKEN), the
|
|
// backend's site_cache.purge_token. Shorter than 32 characters, the
|
|
// route answers 404.
|
|
purgeToken: '',
|
|
},
|
|
public: {
|
|
journal: {
|
|
// Same-origin base for browser fetches (NUXT_PUBLIC_JOURNAL_API_BASE).
|
|
apiBase: '/_journal/api/v1',
|
|
},
|
|
},
|
|
},
|
|
|
|
// The Journal's internal routes and the shared site routes are never
|
|
// route-cached. Nitro wraps every handler matching an app rule such as
|
|
// '/**': { swr } in its cached handler, which keys by path, does not skip
|
|
// POST and hides request headers, so the purge routes would answer from the
|
|
// cache without running.
|
|
routeRules: {
|
|
'/api/__journal__/**': { cache: false },
|
|
'/api/__site__/**': { cache: false },
|
|
},
|
|
|
|
// No OG image rendering at runtime.
|
|
ogImage: { enabled: false },
|
|
|
|
// Paginated listings keep ?page=N in their canonical URL. nuxt-seo-utils
|
|
// already whitelists page by default; set explicitly to lock the behaviour.
|
|
seo: { canonicalQueryWhitelist: ['page'] },
|
|
|
|
// Journal posts and categories come from the API through the layer's
|
|
// sitemap source; locs are built from journal.routes. One flat sitemap.
|
|
sitemap: { sources: ['/api/__sitemap__/journal'], autoI18n: false },
|
|
|
|
// i18n: the layer declares no locales. The journal module registers the
|
|
// layer's pl/en strings only for locales the app enables.
|
|
})
|