- typed client and useFaq/useFaqApi (SSR, faq:<slug>:<locale> key, server and public bases, x-forwarded-for forwarded also on cached renders) - FaqBlock, FaqList and FaqItem: native details, exclusive and openFirst, server-sanitized description and answers, nothing or #fallback on 404, error or no items - FAQ tokens and base CSS with the .faq-html rules, README - node client tests and a playground SSR smoke against a fixture API
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
// vue-faq-layer: renders a FAQ of the SummerCMS FAQ plugin
|
|
// (GET /_faq/api/v1/faqs/{slug}) as native <details> items. An app consumes
|
|
// it with `extends: ['vue-faq-layer']` and renders <FaqBlock>.
|
|
//
|
|
// 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. The layer declares no Nuxt modules.
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const currentDir = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
export default defineNuxtConfig({
|
|
compatibilityDate: '2025-07-15',
|
|
devtools: { enabled: false },
|
|
|
|
// 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/faq-tokens.css`, `${currentDir}app/assets/css/faq-base.css`],
|
|
|
|
runtimeConfig: {
|
|
faq: {
|
|
// Server-only base for SSR fetches (NUXT_FAQ_API_BASE). It never comes
|
|
// from request input.
|
|
apiBase: 'http://127.0.0.1:8096/_faq/api/v1',
|
|
},
|
|
public: {
|
|
faq: {
|
|
// Same-origin base for browser fetches (NUXT_PUBLIC_FAQ_API_BASE).
|
|
apiBase: '/_faq/api/v1',
|
|
},
|
|
},
|
|
},
|
|
})
|