// A FAQ by slug, fetched during SSR through useAsyncData with the key // faq::. data is null for a missing (404) FAQ; error is set // when the API failed. import type { MaybeRefOrGetter } from 'vue' import type { Faq } from '../utils/types.ts' export interface UseFaqOptions { /** ?locale= for the API; the API's default locale when empty. */ locale?: MaybeRefOrGetter } export function useFaq(slug: MaybeRefOrGetter, opts: UseFaqOptions = {}) { const api = useFaqApi() const key = computed(() => `faq:${toValue(slug)}:${toValue(opts.locale) ?? ''}`) return useAsyncData(key, () => api.getFaq(toValue(slug), toValue(opts.locale) || undefined), { default: () => null, }) }