@altafusion/fugue-content 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +352 -2
  4. package/app/components/FugueContent404Page.vue +48 -0
  5. package/app/components/FugueContentAuthSignOut.vue +16 -0
  6. package/app/components/FugueContentContentPage.vue +33 -0
  7. package/app/components/FugueContentEditContent.vue +76 -0
  8. package/app/components/FugueContentEditorMenu.vue +60 -0
  9. package/app/components/FugueContentFooterActions.vue +32 -0
  10. package/app/components/FugueContentFragment.vue +53 -0
  11. package/app/components/FugueContentHeaderActions.vue +37 -0
  12. package/app/components/FugueContentLandingPage.vue +69 -0
  13. package/app/components/FugueContentLayoutArticle.vue +22 -0
  14. package/app/components/FugueContentLayoutArticleAside.vue +88 -0
  15. package/app/components/FugueContentLayoutLanding.vue +5 -0
  16. package/app/components/LandingHeroMedia.vue +91 -0
  17. package/app/components/content/CallToAction.vue +35 -0
  18. package/app/components/content/Hero.vue +34 -0
  19. package/app/composables/useFugueContentCatchAllRoute.ts +91 -0
  20. package/app/composables/useFugueContentFragment.ts +70 -0
  21. package/app/composables/useFugueContentI18n.ts +77 -0
  22. package/app/composables/useFugueContentLanding.ts +24 -0
  23. package/app/composables/useFugueContentPage.ts +37 -0
  24. package/app/composables/useFugueContentSettings.ts +140 -0
  25. package/app/composables/useFugueContentStudioEdit.ts +38 -0
  26. package/app/pages/[...slug].vue +7 -0
  27. package/app/pages/fragments/[slug].vue +25 -0
  28. package/app/pages/index.vue +7 -0
  29. package/app/pages/login.vue +70 -0
  30. package/app/plugins/auth-session-sync.client.ts +33 -0
  31. package/app/plugins/landing-component-registry.ts +15 -0
  32. package/app/plugins/landing-nav.ts +26 -0
  33. package/app/plugins/qe-tools.client.ts +28 -0
  34. package/app/plugins/seo-defaults.ts +4 -0
  35. package/app/plugins/settings-bridge.ts +14 -0
  36. package/app/plugins/shell-display-name.ts +18 -0
  37. package/app/plugins/studio-auto-open.client.ts +30 -0
  38. package/app/plugins/studio-dev-shortcut.client.ts +24 -0
  39. package/app/plugins/studio-footer-actions.client.ts +27 -0
  40. package/app/plugins/studio-footer-actions.server.ts +11 -0
  41. package/app/plugins/studio-hash-cleanup.client.ts +12 -0
  42. package/app/plugins/studio-header-actions.client.ts +30 -0
  43. package/app/plugins/studio-header-actions.server.ts +13 -0
  44. package/app/utils/studio-mount.ts +72 -0
  45. package/composables/useFugueContentAuthMode.ts +16 -0
  46. package/composables/useFugueContentAuthSignOut.ts +82 -0
  47. package/composables/useFugueContentPeekSession.ts +31 -0
  48. package/composables/useFugueContentStudioEditorEntry.ts +112 -0
  49. package/composables/useFugueContentStudioSession.ts +81 -0
  50. package/content.config.ts +199 -0
  51. package/content.d.ts +25 -0
  52. package/eslint.config.mjs +4 -0
  53. package/lib/404-defaults.ts +41 -0
  54. package/lib/article-i18n.ts +10 -0
  55. package/lib/auth-resolve.ts +74 -0
  56. package/lib/auth-utils.ts +44 -0
  57. package/lib/define-site.ts +156 -0
  58. package/lib/header-actions-registration.ts +42 -0
  59. package/lib/i18n-locales.ts +22 -0
  60. package/lib/i18n-utils.ts +136 -0
  61. package/lib/i18n.ts +2 -0
  62. package/lib/landing.ts +129 -0
  63. package/lib/login-redirect.ts +12 -0
  64. package/lib/netlify-ssr.ts +113 -0
  65. package/lib/page-toc.ts +14 -0
  66. package/lib/qe-tools/index.ts +36 -0
  67. package/lib/qe-tools/studio-drafts.ts +315 -0
  68. package/lib/qe-tools/types.ts +14 -0
  69. package/lib/settings-state.ts +1 -0
  70. package/lib/site-config-registry.ts +80 -0
  71. package/lib/studio-activation-gated.d.ts +20 -0
  72. package/lib/studio-activation-gated.js +127 -0
  73. package/lib/studio-auto-open.ts +26 -0
  74. package/lib/studio-cookies.d.ts +10 -0
  75. package/lib/studio-cookies.js +11 -0
  76. package/lib/studio-document-edit.ts +61 -0
  77. package/lib/studio-editor-visibility.ts +54 -0
  78. package/lib/studio-open.ts +7 -0
  79. package/lib/studio-session.ts +91 -0
  80. package/modules/i18n.ts +80 -0
  81. package/modules/landing-components.ts +95 -0
  82. package/modules/studio-auth-gate.ts +48 -0
  83. package/modules/studio-entry.ts +23 -0
  84. package/nuxt.config.ts +90 -0
  85. package/package.json +66 -3
  86. package/schemas/site-settings.schema.json +127 -0
  87. package/server/middleware/studio-oauth-redirect.ts +36 -0
  88. package/server/middleware/studio-provider-check.ts +59 -0
  89. package/server/plugins/studio-hash-cleanup.ts +8 -0
  90. package/tsconfig.build.json +22 -0
  91. package/tsconfig.json +20 -0
  92. package/types/site.ts +79 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Open the Nuxt Studio UI after the official `nuxt-studio` client plugin has initialized
3
+ * `window.useStudioHost`. Do not import `host.dev` here — that bypasses Nuxt transforms and
4
+ * breaks on CJS deps (debug, extend, slugify, …).
5
+ */
6
+
7
+ import { ensureStudioActivation } from '../../lib/studio-activation-gated.js'
8
+
9
+ export function isNuxtStudioMounted(): boolean {
10
+ return import.meta.client && !!document.querySelector('nuxt-studio')
11
+ }
12
+
13
+ function isStudioHostReady(): boolean {
14
+ return typeof (window as Window & { useStudioHost?: () => unknown }).useStudioHost === 'function'
15
+ }
16
+
17
+ async function waitForStudioHost(timeoutMs = 8000): Promise<boolean> {
18
+ if (isStudioHostReady())
19
+ return true
20
+
21
+ const deadline = Date.now() + timeoutMs
22
+ while (Date.now() < deadline) {
23
+ await new Promise(resolve => setTimeout(resolve, 50))
24
+ if (isStudioHostReady())
25
+ return true
26
+ }
27
+
28
+ return isStudioHostReady()
29
+ }
30
+
31
+ async function ensureStudioHostReady(): Promise<boolean> {
32
+ if (isStudioHostReady())
33
+ return true
34
+
35
+ if (!import.meta.client)
36
+ return false
37
+
38
+ await ensureStudioActivation()
39
+ return waitForStudioHost()
40
+ }
41
+
42
+ /** Attach `<nuxt-studio>` when the host is ready (nuxt-studio `studio.client` plugin). */
43
+ export async function mountNuxtStudioClient(): Promise<boolean> {
44
+ if (!import.meta.client)
45
+ return false
46
+
47
+ if (isNuxtStudioMounted())
48
+ return true
49
+
50
+ const config = useRuntimeConfig().public.studio
51
+ if (!config?.repository)
52
+ return false
53
+
54
+ if (!await ensureStudioHostReady()) {
55
+ console.warn(
56
+ '[fugue-content-site] Nuxt Studio host is not ready. Look for errors from the nuxt-studio plugin above, then reload. In dev press ⌘. / Ctrl+.'
57
+ )
58
+ return false
59
+ }
60
+
61
+ if (isNuxtStudioMounted())
62
+ return true
63
+
64
+ try {
65
+ await import('nuxt-studio/app')
66
+ document.body.appendChild(document.createElement('nuxt-studio'))
67
+ return isNuxtStudioMounted()
68
+ } catch (error) {
69
+ console.error('[fugue-content-site] Failed to open Nuxt Studio UI:', error)
70
+ return false
71
+ }
72
+ }
@@ -0,0 +1,16 @@
1
+ import type { ResolvedFugueContentSiteAuthMode } from '../lib/auth-resolve'
2
+ import type { FugueContentPublicAuthConfig } from '../lib/header-actions-registration'
3
+ import {
4
+ resolveFugueContentAuthModeFromPublicConfig
5
+ } from '../lib/header-actions-registration'
6
+
7
+ /**
8
+ * Resolved fugue-content-site auth strategy from the site manifest + env (build time).
9
+ * Prefer this over checking `fugueSimpleAuth` directly — peek gate is inactive when mode is `studio`.
10
+ */
11
+ export function useFugueContentAuthMode() {
12
+ const runtimeConfig = useRuntimeConfig()
13
+ return resolveFugueContentAuthModeFromPublicConfig(runtimeConfig.public as FugueContentPublicAuthConfig)
14
+ }
15
+
16
+ export type { ResolvedFugueContentSiteAuthMode }
@@ -0,0 +1,82 @@
1
+ import type { FugueSimpleAuthConfig } from '@altafusion/fugue-simple-auth/types/config'
2
+ import { shouldShowSimpleAuthSignOut } from '@altafusion/fugue-simple-auth/lib/login'
3
+ import {
4
+ FUGUE_CONTENT_STUDIO_DEV_AUTH_CHECK,
5
+ FUGUE_CONTENT_STUDIO_SESSION_CHECK,
6
+ FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS,
7
+ FUGUE_CONTENT_STUDIO_SESSION_ROUTE,
8
+ isFugueContentStudioSessionCheck
9
+ } from '../lib/studio-session'
10
+
11
+ async function signOutStudioIfActive(clearSession: () => void) {
12
+ if (!import.meta.client)
13
+ return
14
+
15
+ const studioRoute = useRuntimeConfig().public.studio?.route
16
+ if (!studioRoute)
17
+ return
18
+
19
+ const devAuthCheck = useCookie(FUGUE_CONTENT_STUDIO_DEV_AUTH_CHECK, FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS)
20
+ const sessionCheck = useCookie(FUGUE_CONTENT_STUDIO_SESSION_CHECK, FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS)
21
+
22
+ const hasDevSession = import.meta.dev && isFugueContentStudioSessionCheck(devAuthCheck.value)
23
+ const hasProdSession = isFugueContentStudioSessionCheck(sessionCheck.value)
24
+
25
+ if (!hasDevSession && !hasProdSession)
26
+ return
27
+
28
+ if (hasProdSession) {
29
+ try {
30
+ await $fetch(FUGUE_CONTENT_STUDIO_SESSION_ROUTE, { method: 'DELETE' })
31
+ } catch {
32
+ // Best effort — still tear down client state below.
33
+ }
34
+ }
35
+
36
+ clearSession()
37
+ document.querySelector('nuxt-studio')?.remove()
38
+ document.body.removeAttribute('data-studio-active')
39
+
40
+ if ('serviceWorker' in navigator) {
41
+ const registrations = await navigator.serviceWorker.getRegistrations()
42
+ await Promise.all(registrations.map(registration => registration.unregister()))
43
+ }
44
+ }
45
+
46
+ /**
47
+ * End peek and/or Studio sessions. Does not navigate — caller stays on the current page.
48
+ */
49
+ export function useFugueContentAuthSignOut() {
50
+ const { hasPeekGate } = useFugueContentAuthMode()
51
+ const { isAuthenticated, refresh: refreshStudioSession, clearSession } = useFugueContentStudioSession()
52
+ const config = useRuntimeConfig().public.fugueSimpleAuth as FugueSimpleAuthConfig | undefined
53
+ const { session: peekSession, refresh: refreshPeekSession } = useFugueContentPeekSession()
54
+
55
+ const showPeekSignOut = computed(() => {
56
+ if (!hasPeekGate)
57
+ return false
58
+
59
+ return shouldShowSimpleAuthSignOut(peekSession.value)
60
+ })
61
+
62
+ async function signOut() {
63
+ await signOutStudioIfActive(clearSession)
64
+
65
+ if (hasPeekGate && config?.apiPrefix) {
66
+ try {
67
+ await $fetch(`${config.apiPrefix}/logout`, { method: 'POST' })
68
+ } catch {
69
+ // Ignore — studio session already cleared above.
70
+ }
71
+ await refreshPeekSession()
72
+ }
73
+
74
+ await refreshStudioSession()
75
+ }
76
+
77
+ return {
78
+ isAuthenticated,
79
+ showPeekSignOut,
80
+ signOut
81
+ }
82
+ }
@@ -0,0 +1,31 @@
1
+ import type { SimpleAuthSession } from '@altafusion/fugue-simple-auth/lib/login'
2
+ import type { FugueSimpleAuthConfig } from '@altafusion/fugue-simple-auth/types/config'
3
+
4
+ /** Peek-gate session fetch — skips the API when peek auth is inactive. */
5
+ export function useFugueContentPeekSession() {
6
+ const { hasPeekGate } = useFugueContentAuthMode()
7
+ const config = useRuntimeConfig().public.fugueSimpleAuth as FugueSimpleAuthConfig | undefined
8
+
9
+ const { data, pending, refresh } = useAsyncData<SimpleAuthSession | null>(
10
+ 'fugue-simple-auth-session',
11
+ () => {
12
+ if (!hasPeekGate || !config?.apiPrefix)
13
+ return Promise.resolve(null)
14
+
15
+ return $fetch<SimpleAuthSession>(`${config.apiPrefix}/session`)
16
+ }
17
+ )
18
+
19
+ const session = computed((): SimpleAuthSession | null | undefined => {
20
+ if (!hasPeekGate || !config?.apiPrefix)
21
+ return null
22
+
23
+ return data.value
24
+ })
25
+
26
+ return {
27
+ session,
28
+ pending,
29
+ refresh
30
+ }
31
+ }
@@ -0,0 +1,112 @@
1
+ import { getCurrentInstance, onMounted, onUnmounted } from 'vue'
2
+ import { isNuxtStudioMounted } from '../app/utils/studio-mount'
3
+ import { openFugueContentStudioEditorPanel } from '../lib/studio-auto-open'
4
+
5
+ /**
6
+ * Open Nuxt Studio from editor chrome (**Edit content** menu or ⌘. in dev).
7
+ * Local dev: mount in-page after `/login` or ⌘.
8
+ * Production: Google OAuth via `/_studio`.
9
+ */
10
+ export function useFugueContentStudioEditorEntry() {
11
+ const runtimeConfig = useRuntimeConfig()
12
+ const studioConfig = runtimeConfig.public.studio
13
+ const route = useRoute()
14
+ const isActive = ref(false)
15
+ const isClientReady = ref(false)
16
+
17
+ const { hasPeekGate } = useFugueContentAuthMode()
18
+ const { session: peekSession, pending: peekPending } = useFugueContentPeekSession()
19
+ const { isAuthenticated } = useFugueContentStudioSession()
20
+
21
+ function refreshActive() {
22
+ isActive.value = isNuxtStudioMounted()
23
+ }
24
+
25
+ const instance = getCurrentInstance()
26
+ const inSetup = Boolean(instance && !instance.isMounted)
27
+
28
+ function bindStudioActiveWatcher() {
29
+ if (!import.meta.client)
30
+ return
31
+
32
+ isClientReady.value = true
33
+ refreshActive()
34
+
35
+ const observer = new MutationObserver(() => refreshActive())
36
+ observer.observe(document.body, { childList: true, subtree: true })
37
+
38
+ if (inSetup)
39
+ onUnmounted(() => observer.disconnect())
40
+ }
41
+
42
+ if (import.meta.client) {
43
+ if (inSetup)
44
+ onMounted(bindStudioActiveWatcher)
45
+ else
46
+ onNuxtReady(bindStudioActiveWatcher)
47
+ }
48
+
49
+ function studioOAuthUrl(redirectPath = route.fullPath) {
50
+ const redirect = encodeURIComponent(redirectPath)
51
+ return `${studioConfig!.route}?redirect=${redirect}`
52
+ }
53
+
54
+ function goToStudioOAuth(redirectPath = route.fullPath) {
55
+ window.location.assign(studioOAuthUrl(redirectPath))
56
+ }
57
+
58
+ async function openEditor() {
59
+ if (!studioConfig?.route || isActive.value)
60
+ return
61
+
62
+ const mounted = await openFugueContentStudioEditorPanel()
63
+ refreshActive()
64
+ if (mounted)
65
+ return
66
+
67
+ if (!import.meta.dev) {
68
+ if (isAuthenticated.value) {
69
+ console.warn('[fugue-content-site] Nuxt Studio did not open after sign-in. Reload the page and try again.')
70
+ return
71
+ }
72
+ goToStudioOAuth()
73
+ return
74
+ }
75
+
76
+ console.warn(
77
+ `[fugue-content-site] Nuxt Studio did not open.${
78
+ hasPeekGate ? ' Log in at /login if prompted, then try again (or ⌘. in dev).' : ' Check the console for nuxt-studio errors, reload, or press ⌘. / Ctrl+.'}`
79
+ )
80
+ }
81
+
82
+ function goToLogin(redirectPath = route.fullPath) {
83
+ void navigateTo({
84
+ path: '/login',
85
+ query: { redirect: redirectPath }
86
+ })
87
+ }
88
+
89
+ async function handleEditEntry() {
90
+ if (!studioConfig?.route || isActive.value)
91
+ return
92
+
93
+ if (!isAuthenticated.value) {
94
+ goToLogin()
95
+ return
96
+ }
97
+
98
+ await openEditor()
99
+ }
100
+
101
+ return {
102
+ isActive: readonly(isActive),
103
+ isClientReady: readonly(isClientReady),
104
+ peekSession,
105
+ peekPending,
106
+ openEditor,
107
+ handleEditEntry,
108
+ goToLogin,
109
+ goToStudioOAuth,
110
+ refreshActive
111
+ }
112
+ }
@@ -0,0 +1,81 @@
1
+ import type { FugueContentStudioSessionPayload, FugueContentStudioUser } from '../lib/studio-session'
2
+ import {
3
+ FUGUE_CONTENT_STUDIO_DEV_AUTH_CHECK,
4
+ FUGUE_CONTENT_STUDIO_DEV_USER,
5
+ FUGUE_CONTENT_STUDIO_SESSION_CHECK,
6
+ FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS,
7
+ FUGUE_CONTENT_STUDIO_SESSION_ROUTE,
8
+ hasFugueContentStudioSession,
9
+ resolveFugueContentStudioUser
10
+ } from '../lib/studio-session'
11
+
12
+ export function useFugueContentStudioDevAuthCookie() {
13
+ return useCookie(FUGUE_CONTENT_STUDIO_DEV_AUTH_CHECK, FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS)
14
+ }
15
+
16
+ export function useFugueContentStudioSessionCheckCookie() {
17
+ return useCookie(FUGUE_CONTENT_STUDIO_SESSION_CHECK, FUGUE_CONTENT_STUDIO_SESSION_COOKIE_OPTIONS)
18
+ }
19
+
20
+ export function useFugueContentStudioSession() {
21
+ const studioConfig = useRuntimeConfig().public.studio
22
+ const sessionCheck = useFugueContentStudioSessionCheckCookie()
23
+ const devAuthCheck = useFugueContentStudioDevAuthCookie()
24
+ const devUser = useState<FugueContentStudioUser | null>('studio-session', () => null)
25
+
26
+ // Never call session.get in dev — nuxt-studio deletes `studio-session-check` when no server session exists.
27
+ const { data: sessionData, pending, refresh } = useAsyncData<FugueContentStudioSessionPayload | null>(
28
+ 'fugue-content-studio-session',
29
+ () => {
30
+ if (import.meta.dev || !studioConfig?.route)
31
+ return Promise.resolve(null)
32
+
33
+ return $fetch<FugueContentStudioSessionPayload>(FUGUE_CONTENT_STUDIO_SESSION_ROUTE)
34
+ }
35
+ )
36
+
37
+ const session = computed((): FugueContentStudioSessionPayload | null | undefined => {
38
+ if (import.meta.dev || !studioConfig?.route)
39
+ return null
40
+
41
+ return sessionData.value
42
+ })
43
+
44
+ if (import.meta.client && import.meta.dev && devAuthCheck.value === 'true' && !devUser.value?.email)
45
+ devUser.value = FUGUE_CONTENT_STUDIO_DEV_USER
46
+
47
+ const user = computed(() => resolveFugueContentStudioUser(session.value, devUser.value, {
48
+ devAuthCheck: devAuthCheck.value,
49
+ sessionCheck: sessionCheck.value,
50
+ isDev: import.meta.dev
51
+ }))
52
+
53
+ const isAuthenticated = computed(() => hasFugueContentStudioSession(
54
+ sessionCheck.value,
55
+ session.value,
56
+ devUser.value,
57
+ import.meta.dev,
58
+ devAuthCheck.value
59
+ ))
60
+
61
+ function activateDevSession() {
62
+ devUser.value = FUGUE_CONTENT_STUDIO_DEV_USER
63
+ devAuthCheck.value = 'true'
64
+ }
65
+
66
+ function clearSession() {
67
+ devAuthCheck.value = null
68
+ sessionCheck.value = null
69
+ devUser.value = null
70
+ }
71
+
72
+ return {
73
+ session,
74
+ pending,
75
+ user,
76
+ isAuthenticated,
77
+ refresh,
78
+ activateDevSession,
79
+ clearSession
80
+ }
81
+ }
@@ -0,0 +1,199 @@
1
+ import { defineCollection, defineContentConfig, z } from '@nuxt/content'
2
+ import { logger, useNuxt } from '@nuxt/kit'
3
+ import { joinURL } from 'ufo'
4
+ import { resolveI18nLocaleCodes } from './lib/i18n-locales'
5
+ import {
6
+ contentPrefixForLocale,
7
+ fragmentsCollectionName,
8
+ fragmentsRoutePrefix,
9
+ fugueContentNuxtOptions,
10
+ pagesCollectionName,
11
+ settingsCollectionName
12
+ } from './lib/i18n-utils'
13
+
14
+ const log = logger.withTag('fugue-content-site')
15
+
16
+ const options = fugueContentNuxtOptions(useNuxt().options)
17
+ const cwd = joinURL(options.rootDir, 'content')
18
+
19
+ const pageSchema = z.object({
20
+ layout: z.enum(['landing', 'article', 'article-aside']).default('landing'),
21
+ nav: z.object({
22
+ primary: z.string().optional()
23
+ }).optional()
24
+ })
25
+
26
+ const fragmentImageSchema = z.object({
27
+ src: z.string(),
28
+ alt: z.string(),
29
+ span: z.number().optional()
30
+ })
31
+
32
+ const fragmentSchema = z.object({
33
+ title: z.string().optional(),
34
+ description: z.string().optional(),
35
+ /** Optional gallery for section shells such as ActivitiesFragment */
36
+ images: z.array(fragmentImageSchema).optional()
37
+ })
38
+
39
+ const landingSectionNavSchema = z.object({
40
+ labelKey: z.string().optional(),
41
+ label: z.string().optional(),
42
+ icon: z.string().optional(),
43
+ id: z.string().optional(),
44
+ to: z.string().optional()
45
+ }).optional()
46
+
47
+ const landingSectionComponentSchema = z.union([
48
+ z.string(),
49
+ z.object({
50
+ name: z.string(),
51
+ props: z.record(z.string(), z.unknown()).optional()
52
+ })
53
+ ])
54
+
55
+ const landingSectionSchema = z.object({
56
+ slug: z.string(),
57
+ anchor: z.string(),
58
+ component: landingSectionComponentSchema.default('FugueContentFragment'),
59
+ sectionClass: z.string().optional(),
60
+ variant: z.string().optional(),
61
+ nav: landingSectionNavSchema
62
+ })
63
+
64
+ const landingSchema = z.object({
65
+ sections: z.array(landingSectionSchema).default([])
66
+ }).optional()
67
+
68
+ const themeSchema = z.object({
69
+ darkCanvas: z.enum(['gray', 'black']).optional()
70
+ }).optional()
71
+
72
+ const settingsSchema = z.object({
73
+ siteName: z.string().optional(),
74
+ phone: z.string().optional(),
75
+ email: z.string().optional(),
76
+ address: z.object({
77
+ street: z.string().optional(),
78
+ city: z.string().optional(),
79
+ region: z.string().optional(),
80
+ postalCode: z.string().optional(),
81
+ country: z.string().optional()
82
+ }).optional(),
83
+ hours: z.string().optional(),
84
+ mapEmbedUrl: z.string().optional(),
85
+ social: z.object({
86
+ instagram: z.string().optional(),
87
+ facebook: z.string().optional()
88
+ }).optional(),
89
+ seo: z.object({
90
+ title: z.string().optional(),
91
+ description: z.string().optional(),
92
+ titleTemplate: z.string().optional(),
93
+ ogImage: z.string().optional(),
94
+ twitterCard: z.enum(['summary', 'summary_large_image']).optional()
95
+ }).optional(),
96
+ landing: landingSchema,
97
+ theme: themeSchema
98
+ })
99
+
100
+ const i18nOptions = options.i18n
101
+ const hasI18nLocales = i18nOptions
102
+ && typeof i18nOptions === 'object'
103
+ && Array.isArray(i18nOptions.locales)
104
+ && i18nOptions.locales.length > 0
105
+
106
+ const defaultLocale = hasI18nLocales
107
+ ? ((i18nOptions.defaultLocale as string | undefined) ?? 'en')
108
+ : 'en'
109
+
110
+ const localeCodes = hasI18nLocales && i18nOptions.locales
111
+ ? resolveI18nLocaleCodes(
112
+ options.rootDir,
113
+ i18nOptions.locales,
114
+ code => log.warn(`Content folder not found: content/${code}/ — skipping locale "${code}" in collections`)
115
+ )
116
+ : []
117
+
118
+ function pagesCollectionForLocale(code?: string) {
119
+ const localeSegment = code
120
+ ? `${code}/`
121
+ : ''
122
+ const prefix = code
123
+ ? contentPrefixForLocale(code, defaultLocale)
124
+ : '/'
125
+
126
+ return defineCollection({
127
+ type: 'page',
128
+ source: {
129
+ cwd,
130
+ include: `${localeSegment}**/*.md`,
131
+ exclude: code
132
+ ? [`${code}/fragments/**`, '**/.*']
133
+ : ['fragments/**', '**/.*'],
134
+ prefix
135
+ },
136
+ schema: pageSchema
137
+ })
138
+ }
139
+
140
+ function fragmentsCollectionForLocale(code?: string) {
141
+ const localeSegment = code
142
+ ? `${code}/`
143
+ : ''
144
+ const routePrefix = code
145
+ ? fragmentsRoutePrefix(code, defaultLocale)
146
+ : '/fragments'
147
+
148
+ return defineCollection({
149
+ type: 'page',
150
+ source: {
151
+ cwd,
152
+ include: `${localeSegment}fragments/**/*.md`,
153
+ exclude: ['**/.*'],
154
+ prefix: routePrefix
155
+ },
156
+ schema: fragmentSchema
157
+ })
158
+ }
159
+
160
+ function settingsCollectionForLocale(code?: string) {
161
+ const localeSegment = code
162
+ ? `${code}/`
163
+ : ''
164
+
165
+ return defineCollection({
166
+ type: 'data',
167
+ source: {
168
+ cwd,
169
+ include: `${localeSegment}settings/**/*.yml`,
170
+ exclude: ['**/.*']
171
+ },
172
+ schema: settingsSchema
173
+ })
174
+ }
175
+
176
+ const collections = localeCodes.length > 0
177
+ ? Object.fromEntries(
178
+ localeCodes.flatMap(code => [
179
+ [
180
+ pagesCollectionName(code),
181
+ pagesCollectionForLocale(code)
182
+ ],
183
+ [
184
+ fragmentsCollectionName(code),
185
+ fragmentsCollectionForLocale(code)
186
+ ],
187
+ [
188
+ settingsCollectionName(code),
189
+ settingsCollectionForLocale(code)
190
+ ]
191
+ ])
192
+ )
193
+ : {
194
+ pages: pagesCollectionForLocale(),
195
+ fragments: fragmentsCollectionForLocale(),
196
+ settings: settingsCollectionForLocale()
197
+ }
198
+
199
+ export default defineContentConfig({ collections })
package/content.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ import type { PageCollectionItemBase } from '@nuxt/content'
2
+
3
+ declare module '@nuxt/content' {
4
+ interface PagesCollectionItem extends PageCollectionItemBase {
5
+ layout?: 'landing' | 'article' | 'article-aside'
6
+ nav?: {
7
+ primary?: string
8
+ }
9
+ }
10
+
11
+ interface PageCollections {
12
+ pages: PagesCollectionItem
13
+ pages_en: PagesCollectionItem
14
+ pages_es: PagesCollectionItem
15
+ }
16
+
17
+ interface Collections {
18
+ pages: PagesCollectionItem
19
+ pages_en: PagesCollectionItem
20
+ pages_es: PagesCollectionItem
21
+ [key: `pages_${string}`]: PagesCollectionItem
22
+ }
23
+ }
24
+
25
+ export {}
@@ -0,0 +1,4 @@
1
+ // @ts-check
2
+ import { createPackageEslintConfig } from '@altafusion/eslint-config'
3
+
4
+ export default createPackageEslintConfig()
@@ -0,0 +1,41 @@
1
+ export const FUGUE_CONTENT_404_DEFAULTS = {
2
+ statusCode: 404,
3
+ title: 'Page Not Found',
4
+ description: 'The page you requested does not exist or may have moved.',
5
+ actionLabel: 'Back to Home',
6
+ actionTo: '/'
7
+ } as const
8
+
9
+ /** i18n keys — translate in the app `i18n/locales/*.yaml` under `fugueContent404.*`. */
10
+ export const FUGUE_CONTENT_404_I18N_KEYS = {
11
+ title: 'fugueContent404.title',
12
+ description: 'fugueContent404.description',
13
+ actionLabel: 'fugueContent404.actionLabel'
14
+ } as const
15
+
16
+ export interface FugueContent404Copy {
17
+ title: string
18
+ description: string
19
+ actionLabel: string
20
+ }
21
+
22
+ export function resolveFugueContent404Copy(
23
+ t: (_key: string, _fallback: string) => string
24
+ ): FugueContent404Copy {
25
+ return {
26
+ title: t(FUGUE_CONTENT_404_I18N_KEYS.title, FUGUE_CONTENT_404_DEFAULTS.title),
27
+ description: t(FUGUE_CONTENT_404_I18N_KEYS.description, FUGUE_CONTENT_404_DEFAULTS.description),
28
+ actionLabel: t(FUGUE_CONTENT_404_I18N_KEYS.actionLabel, FUGUE_CONTENT_404_DEFAULTS.actionLabel)
29
+ }
30
+ }
31
+
32
+ export interface FugueContentPageRouteState {
33
+ loading: boolean
34
+ error: unknown
35
+ contentPage: unknown
36
+ i18nReady: boolean
37
+ }
38
+
39
+ export function isFugueContent404(state: FugueContentPageRouteState): boolean {
40
+ return state.i18nReady && !state.loading && !state.error && !state.contentPage
41
+ }
@@ -0,0 +1,10 @@
1
+ /** i18n keys — translate in the app `i18n/locales/*.yaml` under `cmsArticle.*`. */
2
+ export const FUGUE_CONTENT_ARTICLE_I18N_KEYS = {
3
+ onThisPage: 'cmsArticle.onThisPage',
4
+ editPage: 'cmsArticle.editPage'
5
+ } as const
6
+
7
+ export const FUGUE_CONTENT_ARTICLE_DEFAULTS = {
8
+ onThisPage: 'On This Page',
9
+ editPage: 'Edit'
10
+ } as const