fimo 0.14.0 → 0.15.0-staging.2
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.
- package/README.md +1 -0
- package/assets/astro/components/Boolean.astro +14 -0
- package/assets/astro/components/Date.astro +23 -0
- package/assets/astro/components/Image.astro +79 -0
- package/assets/astro/components/Json.astro +14 -0
- package/assets/astro/components/RichText.astro +17 -0
- package/assets/astro/components/StaticImage.astro +66 -0
- package/assets/astro/components/Text.astro +23 -0
- package/assets/astro/components/Video.astro +47 -0
- package/assets/astro/components/index.d.ts +8 -0
- package/assets/astro/components/index.js +8 -0
- package/assets/content-templates/shared/server.eta +56 -0
- package/assets/content-templates/sveltekit/content.eta +86 -0
- package/assets/skills/fimo/SKILL.md +13 -4
- package/assets/skills/fimo-cli/SKILL.md +28 -28
- package/assets/skills/fimo-cli/references/account.md +0 -2
- package/assets/skills/fimo-cli/references/agent-setup.md +7 -9
- package/assets/skills/fimo-cli/references/agents.md +0 -2
- package/assets/skills/fimo-cli/references/analytics.md +0 -2
- package/assets/skills/fimo-cli/references/assets.md +2 -4
- package/assets/skills/fimo-cli/references/branches.md +14 -15
- package/assets/skills/fimo-cli/references/content.md +9 -11
- package/assets/skills/fimo-cli/references/credits.md +0 -2
- package/assets/skills/fimo-cli/references/deploy.md +6 -7
- package/assets/skills/fimo-cli/references/describe.md +1 -3
- package/assets/skills/fimo-cli/references/domains.md +0 -2
- package/assets/skills/fimo-cli/references/forms.md +5 -7
- package/assets/skills/fimo-cli/references/history.md +0 -2
- package/assets/skills/fimo-cli/references/init.md +34 -26
- package/assets/skills/fimo-cli/references/integrations/firecrawl.md +0 -2
- package/assets/skills/fimo-cli/references/integrations.md +0 -2
- package/assets/skills/fimo-cli/references/invite.md +0 -2
- package/assets/skills/fimo-cli/references/labels.md +5 -7
- package/assets/skills/fimo-cli/references/locales.md +2 -4
- package/assets/skills/fimo-cli/references/mcp.md +2 -4
- package/assets/skills/fimo-cli/references/media.md +0 -2
- package/assets/skills/fimo-cli/references/preview.md +0 -2
- package/assets/skills/fimo-cli/references/project-vars-and-secrets.md +1 -3
- package/assets/skills/fimo-cli/references/projects.md +1 -3
- package/assets/skills/fimo-cli/references/schedules.md +0 -2
- package/assets/skills/fimo-cli/references/support.md +0 -2
- package/assets/skills/fimo-cli/references/webhooks.md +0 -2
- package/assets/skills/fimo-code/SKILL.md +11 -3
- package/assets/skills/fimo-code/references/assets.md +2 -2
- package/assets/skills/fimo-code/references/content/clients.md +5 -1
- package/assets/skills/fimo-code/references/content.md +3 -1
- package/assets/skills/fimo-code/references/frameworks/astro.md +127 -0
- package/assets/skills/fimo-code/references/frameworks/compatibility.md +19 -0
- package/assets/skills/fimo-code/references/frameworks/hosting.md +15 -3
- package/assets/skills/fimo-code/references/frameworks/react-router.md +37 -209
- package/assets/skills/fimo-code/references/frameworks/sveltekit.md +110 -0
- package/assets/skills/fimo-code/references/frameworks/vite-react.md +35 -166
- package/assets/skills/fimo-code/references/labels.md +16 -6
- package/assets/skills/fimo-code/references/locales.md +3 -1
- package/assets/skills/fimo-code/references/ui.md +19 -15
- package/assets/skills/fimo-migration/SKILL.md +99 -146
- package/assets/skills/fimo-migration/references/frameworks/nextjs.md +26 -0
- package/assets/skills/fimo-migration/references/inventory/coordinator.md +40 -0
- package/assets/skills/fimo-migration/references/inventory/locales/next-intl.md +39 -0
- package/assets/skills/fimo-migration/references/inventory/locales.md +41 -0
- package/assets/skills/fimo-migration/references/workflow.md +3 -2
- package/assets/skills/fimo-migration/scripts/inventory/locales/next-intl.mjs +459 -0
- package/assets/skills/fimo-studio/SKILL.md +1 -1
- package/assets/skills/fimo-studio/references/project-creation.md +10 -18
- package/assets/starters/fimo-site/template/.fimo/agents/content-guide/capabilities.yaml +0 -1
- package/assets/starters/fimo-site/template/.fimo/agents/site-review/capabilities.yaml +0 -1
- package/assets/sveltekit/components/Boolean.svelte +19 -0
- package/assets/sveltekit/components/Date.svelte +33 -0
- package/assets/sveltekit/components/FimoProvider.svelte +35 -0
- package/assets/sveltekit/components/Image.svelte +80 -0
- package/assets/sveltekit/components/Json.svelte +18 -0
- package/assets/sveltekit/components/Label.svelte +16 -0
- package/assets/sveltekit/components/Number.svelte +21 -0
- package/assets/sveltekit/components/RichText.svelte +19 -0
- package/assets/sveltekit/components/Text.svelte +30 -0
- package/assets/sveltekit/components/Video.svelte +37 -0
- package/assets/sveltekit/components/index.d.ts +10 -0
- package/assets/sveltekit/components/index.js +10 -0
- package/dist/build/astro/config.d.ts +4 -0
- package/dist/build/astro/config.js +64 -0
- package/dist/build/next/config.js +16 -0
- package/dist/build/sveltekit/config.d.ts +6 -0
- package/dist/build/sveltekit/config.js +8 -0
- package/dist/build/sveltekit/data-id.d.ts +3 -0
- package/dist/build/sveltekit/data-id.js +171 -0
- package/dist/build/sveltekit/vite.d.ts +13 -0
- package/dist/build/sveltekit/vite.js +15 -0
- package/dist/build/vite/index.js +2 -0
- package/dist/build/vite/plugins/data-id.d.ts +9 -0
- package/dist/build/vite/plugins/data-id.js +6 -1
- package/dist/build/vite/plugins/runtime-env.d.ts +21 -0
- package/dist/build/vite/plugins/runtime-env.js +68 -0
- package/dist/cli/bundle.json +1 -1
- package/dist/cli/index.js +108 -101
- package/dist/runtime/app/FimoProviders.d.ts +1 -1
- package/dist/runtime/app/FimoProviders.js +11 -5
- package/dist/runtime/astro/internal.d.ts +6 -0
- package/dist/runtime/astro/internal.js +16 -0
- package/dist/runtime/astro/preview.d.ts +14 -0
- package/dist/runtime/astro/preview.js +103 -0
- package/dist/runtime/astro/render-rich-text.d.ts +2 -0
- package/dist/runtime/astro/render-rich-text.js +1 -0
- package/dist/runtime/astro/server-runtime.d.ts +3 -0
- package/dist/runtime/astro/server-runtime.js +20 -0
- package/dist/runtime/astro/server.d.ts +15 -0
- package/dist/runtime/astro/server.js +14 -0
- package/dist/runtime/content/client/collection-core.d.ts +2 -17
- package/dist/runtime/content/client/collection-core.js +15 -8
- package/dist/runtime/content/client/core-types.d.ts +96 -0
- package/dist/runtime/content/client/core-types.js +1 -0
- package/dist/runtime/content/client/internal.d.ts +4 -4
- package/dist/runtime/content/client/internal.js +4 -3
- package/dist/runtime/content/client/runtime.d.ts +1 -1
- package/dist/runtime/content/client/server-content-client.d.ts +3 -3
- package/dist/runtime/content/client/server-content-client.js +2 -29
- package/dist/runtime/content/client/singleton-core.d.ts +2 -9
- package/dist/runtime/content/client/singleton-core.js +9 -4
- package/dist/runtime/content/client/types.d.ts +5 -115
- package/dist/runtime/content/index.d.ts +3 -3
- package/dist/runtime/labels/fetch.js +5 -3
- package/dist/runtime/next/client.d.ts +2 -1
- package/dist/runtime/next/facade.d.ts +1 -1
- package/dist/runtime/next/provider.js +1 -1
- package/dist/runtime/next/server-runtime.js +1 -1
- package/dist/runtime/next/server.d.ts +5 -4
- package/dist/runtime/paths/get-fimo-paths.js +8 -3
- package/dist/runtime/preview/bridge.d.ts +8 -0
- package/dist/runtime/preview/bridge.js +20 -0
- package/dist/runtime/preview/location.d.ts +23 -0
- package/dist/runtime/preview/location.js +93 -0
- package/dist/runtime/preview/routes.d.ts +10 -0
- package/dist/runtime/preview/routes.js +29 -0
- package/dist/runtime/primitives/index.d.ts +4 -1
- package/dist/runtime/primitives/index.js +1 -0
- package/dist/runtime/primitives/lib/image-optimization.d.ts +27 -2
- package/dist/runtime/primitives/lib/image-optimization.js +40 -0
- package/dist/runtime/primitives/lib/index.d.ts +1 -1
- package/dist/runtime/primitives/lib/primitives.d.ts +0 -54
- package/dist/runtime/primitives/lib/primitives.js +6 -0
- package/dist/runtime/primitives/lib/render-rich-text.d.ts +3 -0
- package/dist/runtime/primitives/lib/render-rich-text.js +112 -0
- package/dist/runtime/react/primitives/contracts.d.ts +40 -2
- package/dist/runtime/react/primitives/renderers/ImageRenderer.js +15 -34
- package/dist/runtime/react/primitives/renderers/RichTextRenderer.d.ts +2 -1
- package/dist/runtime/react/primitives/renderers/StaticImage.js +13 -30
- package/dist/runtime/routing/AppRoutesProvider.js +20 -8
- package/dist/runtime/shared/env-identity.d.ts +43 -0
- package/dist/runtime/shared/env-identity.js +88 -0
- package/dist/runtime/shared/local-runtime-env.d.ts +65 -0
- package/dist/runtime/shared/local-runtime-env.js +169 -0
- package/dist/runtime/{react-router → shared}/preview-location.d.ts +7 -13
- package/dist/runtime/{react-router → shared}/preview-location.js +26 -27
- package/dist/runtime/sveltekit/content.d.ts +25 -0
- package/dist/runtime/sveltekit/content.js +33 -0
- package/dist/runtime/sveltekit/context-contract.d.ts +5 -0
- package/dist/runtime/sveltekit/context-contract.js +2 -0
- package/dist/runtime/sveltekit/context.d.ts +8 -0
- package/dist/runtime/sveltekit/context.js +25 -0
- package/dist/runtime/sveltekit/index.d.ts +7 -0
- package/dist/runtime/sveltekit/index.js +4 -0
- package/dist/runtime/sveltekit/internal.d.ts +6 -0
- package/dist/runtime/sveltekit/internal.js +12 -0
- package/dist/runtime/sveltekit/labels.d.ts +16 -0
- package/dist/runtime/sveltekit/labels.js +13 -0
- package/dist/runtime/sveltekit/preview.d.ts +19 -0
- package/dist/runtime/sveltekit/preview.js +77 -0
- package/dist/runtime/sveltekit/runtime.d.ts +8 -0
- package/dist/runtime/sveltekit/runtime.js +17 -0
- package/dist/runtime/templates.d.ts +1 -1
- package/dist/runtime/templates.js +1 -1
- package/dist/runtime/vite/Label.d.ts +13 -0
- package/dist/runtime/vite/Label.js +16 -0
- package/dist/scripts/extract-translations.js +103 -43
- package/dist/scripts/sync-forms.js +1 -1
- package/dist/scripts/sync-schemas.js +83 -16
- package/package.json +57 -2
- package/release.json +2 -2
- package/templates/nextjs/AGENTS.md +10 -5
- package/templates/nextjs/_gitignore +1 -0
- package/templates/react-router/AGENTS.md +4 -3
- package/templates/react-router/package.json +1 -1
- package/templates/sveltekit/.fimo/config.json +15 -0
- package/templates/sveltekit/AGENTS.md +36 -0
- package/templates/sveltekit/CLAUDE.md +5 -0
- package/templates/sveltekit/_gitignore +16 -0
- package/templates/sveltekit/package.json +28 -0
- package/templates/sveltekit/pnpm-workspace.yaml +4 -0
- package/templates/sveltekit/src/app.html +11 -0
- package/templates/sveltekit/src/routes/+layout.server.ts +8 -0
- package/templates/sveltekit/src/routes/+layout.svelte +12 -0
- package/templates/sveltekit/src/routes/+page.svelte +48 -0
- package/templates/sveltekit/svelte.config.js +5 -0
- package/templates/sveltekit/tsconfig.json +14 -0
- package/templates/sveltekit/vite.config.ts +5 -0
- /package/assets/content-templates/{form-template.eta → forms/react.eta} +0 -0
- /package/assets/content-templates/{next-client-template.eta → next/client.eta} +0 -0
- /package/assets/content-templates/{next-server-template.eta → next/server.eta} +0 -0
- /package/assets/content-templates/{hooks-template.eta → react/client.eta} +0 -0
- /package/assets/content-templates/{types-template.eta → shared/types.eta} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# SvelteKit integration
|
|
2
|
+
|
|
3
|
+
Use this reference when `fimo describe --json` reports
|
|
4
|
+
`framework.slug: "sveltekit"`. SvelteKit keeps owning routes, load functions,
|
|
5
|
+
locale resolution, links, document metadata, and SEO.
|
|
6
|
+
|
|
7
|
+
## Compatibility
|
|
8
|
+
|
|
9
|
+
The adapter targets SvelteKit 2 with Svelte 5. The acceptance baseline currently
|
|
10
|
+
uses SvelteKit `2.70.2`, Svelte `5.56.8`, and Vite `8.2.0`; do not assume that
|
|
11
|
+
SvelteKit 1 or Svelte 4 projects are compatible.
|
|
12
|
+
|
|
13
|
+
## Connect the Vite plugin
|
|
14
|
+
|
|
15
|
+
Add Fimo's source-tagging plugin alongside SvelteKit's own plugin:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
19
|
+
import { fimo } from 'fimo/sveltekit/vite';
|
|
20
|
+
import { defineConfig } from 'vite';
|
|
21
|
+
|
|
22
|
+
export default defineConfig({ plugins: [fimo(), sveltekit()] });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The plugin tags native Svelte elements during `vite dev` so Studio can map
|
|
26
|
+
elements back to source. It does not change production output or own routing.
|
|
27
|
+
|
|
28
|
+
## Hosted configuration
|
|
29
|
+
|
|
30
|
+
For a new Fimo-hosted SvelteKit project, keep the hosting adapter behind Fimo's
|
|
31
|
+
config seam:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { fimo } from 'fimo/sveltekit/config';
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
kit: { adapter: fimo() },
|
|
38
|
+
};
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Do not import or install a provider-specific adapter in the generated project.
|
|
42
|
+
If an adopted project already owns a different adapter, preserve it; Fimo does
|
|
43
|
+
not replace application-owned hosting configuration.
|
|
44
|
+
|
|
45
|
+
## Read content and labels
|
|
46
|
+
|
|
47
|
+
Use SvelteKit's server `load` functions and pass the request event so Fimo uses
|
|
48
|
+
SvelteKit's request-aware `fetch`:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// src/routes/articles/+page.server.ts
|
|
52
|
+
import { createFimo } from 'fimo/sveltekit';
|
|
53
|
+
import { content } from '../../../schemas';
|
|
54
|
+
|
|
55
|
+
export async function load(event) {
|
|
56
|
+
const fimo = createFimo({ content, event });
|
|
57
|
+
const result = await fimo.articles.list({ limit: 12 });
|
|
58
|
+
return { articles: fimo.articles.serialize(result.items) };
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Resolve the locale with the application's existing policy, then fetch labels in
|
|
63
|
+
the root server layout and publish the snapshot to descendants:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// src/routes/+layout.server.ts
|
|
67
|
+
import { env } from '$env/dynamic/public';
|
|
68
|
+
import { getLabels } from 'fimo/sveltekit';
|
|
69
|
+
|
|
70
|
+
export async function load(event) {
|
|
71
|
+
const locale = 'en'; // replace with the application's resolved locale
|
|
72
|
+
return { labels: await getLabels({ apiUrl: env.PUBLIC_FIMO_API_URL, event, locale }) };
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```svelte
|
|
77
|
+
<!-- src/routes/+layout.svelte -->
|
|
78
|
+
<script lang="ts">
|
|
79
|
+
import { FimoProvider } from 'fimo/sveltekit/components';
|
|
80
|
+
import type { LayoutData } from './$types';
|
|
81
|
+
import type { Snippet } from 'svelte';
|
|
82
|
+
|
|
83
|
+
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<FimoProvider labels={data.labels}>
|
|
87
|
+
{@render children()}
|
|
88
|
+
</FimoProvider>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Generated values are serialized at a `load` boundary and hydrated in the
|
|
92
|
+
component that renders them. Use `Text`, `RichText`, `Image`, `Video`, `Date`,
|
|
93
|
+
`Boolean`, `Json`, and `Number` from `fimo/sveltekit/components`. `Number`
|
|
94
|
+
formats plain numeric values for display; numeric fields currently have no
|
|
95
|
+
source metadata, so it is not a Studio-editable primitive.
|
|
96
|
+
|
|
97
|
+
## Live preview
|
|
98
|
+
|
|
99
|
+
`FimoProvider` owns the Studio browser bridge. On mount it reads
|
|
100
|
+
`PUBLIC_FIMO_PREVIEW_SCRIPT_URL` from SvelteKit's dynamic public environment,
|
|
101
|
+
loads that script once, delegates navigation to SvelteKit's `goto`, and
|
|
102
|
+
refreshes data with `invalidateAll()`. Without that environment value it does
|
|
103
|
+
nothing. Do not add a Fimo server hook or a second preview component.
|
|
104
|
+
|
|
105
|
+
## Boundaries
|
|
106
|
+
|
|
107
|
+
- SvelteKit owns routing, history, 404s, locale URLs, and SEO.
|
|
108
|
+
- `fimo/sveltekit/vite` owns dev source tagging only.
|
|
109
|
+
- `FimoProvider` owns labels and the optional Studio preview bridge.
|
|
110
|
+
- Do not add React, React Query, or a Vite SPA fallback to a SvelteKit project.
|
|
@@ -1,100 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Vite and React
|
|
2
2
|
|
|
3
|
-
Use this
|
|
4
|
-
This is also the upgrade path for legacy Fimo v3 projects — v3 was plain Vite,
|
|
5
|
-
so this layout is what those projects look like now.
|
|
3
|
+
Use this reference for a Vite + React SPA without React Router framework mode. Preserve the application's browser router, provider tree, and build structure.
|
|
6
4
|
|
|
7
|
-
##
|
|
5
|
+
## Install and build
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
React Router library router (`BrowserRouter`, no framework-mode SSR/SSG);
|
|
11
|
-
SEO via build-time HTML rewrite. Per-route SEO that crawlers see requires
|
|
12
|
-
prerendering (SSG); without it, the SPA serves one `index.html` for every
|
|
13
|
-
URL and crawlers see only the home SEO.
|
|
14
|
-
- **React Router (`references/frameworks/react-router.md`):** framework-mode SSR + per-route
|
|
15
|
-
SEO via `meta` export; recommended when you want real per-route crawler SEO.
|
|
16
|
-
|
|
17
|
-
## Prerequisites
|
|
18
|
-
|
|
19
|
-
- Node 20+
|
|
20
|
-
- A Fimo project created via `fimo init`.
|
|
21
|
-
|
|
22
|
-
## Install
|
|
23
|
-
|
|
24
|
-
```
|
|
7
|
+
```bash
|
|
25
8
|
pnpm add fimo react react-dom react-router @tanstack/react-query
|
|
26
|
-
pnpm add -D vite @vitejs/plugin-react
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## File: `package.json`
|
|
30
|
-
|
|
31
|
-
```json
|
|
32
|
-
{
|
|
33
|
-
"name": "__PROJECT_SLUG__",
|
|
34
|
-
"version": "0.0.0",
|
|
35
|
-
"private": true,
|
|
36
|
-
"type": "module",
|
|
37
|
-
"scripts": {
|
|
38
|
-
"dev": "vite --host 0.0.0.0 --port 5173",
|
|
39
|
-
"build": "vite build",
|
|
40
|
-
"preview": "vite preview --host 0.0.0.0 --port 4173",
|
|
41
|
-
"typecheck": "tsc --noEmit"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
9
|
+
pnpm add -D vite @vitejs/plugin-react
|
|
44
10
|
```
|
|
45
11
|
|
|
46
|
-
|
|
12
|
+
Add Fimo's Vite plugins without replacing the application's existing plugins:
|
|
47
13
|
|
|
48
14
|
```ts
|
|
15
|
+
import react from '@vitejs/plugin-react';
|
|
49
16
|
import { defineConfig } from 'vite';
|
|
50
|
-
|
|
51
17
|
import { fimo } from 'fimo/vite';
|
|
52
18
|
|
|
53
|
-
export default defineConfig(
|
|
54
|
-
plugins: fimo({ seo: true }),
|
|
55
|
-
})
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Notes:
|
|
59
|
-
|
|
60
|
-
- `fimo({ seo: true })` opts in to the build-time SEO plugin
|
|
61
|
-
(`transformIndexHtml`-based). This is the right tool for plain Vite — there's
|
|
62
|
-
no framework `meta` export to plug into.
|
|
63
|
-
- Add `fimo({ seo: true, sitemap: true, robots: true })` to also emit
|
|
64
|
-
`sitemap.xml` and `robots.txt` at build.
|
|
65
|
-
|
|
66
|
-
## File: `index.html`
|
|
67
|
-
|
|
68
|
-
```html
|
|
69
|
-
<!doctype html>
|
|
70
|
-
<html lang="en">
|
|
71
|
-
<head>
|
|
72
|
-
<meta charset="UTF-8" />
|
|
73
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
74
|
-
<title>__PROJECT_SLUG__</title>
|
|
75
|
-
</head>
|
|
76
|
-
<body>
|
|
77
|
-
<div id="root"></div>
|
|
78
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
79
|
-
</body>
|
|
80
|
-
</html>
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
plugins: [react(), ...fimo({ seo: true })],
|
|
21
|
+
});
|
|
81
22
|
```
|
|
82
23
|
|
|
83
|
-
|
|
84
|
-
`.fimo/config.json#seo` at build time. You can leave a placeholder title in
|
|
85
|
-
`index.html`; it'll be replaced.
|
|
24
|
+
`fimo()` is synchronous and returns a `PluginOption[]`. `seo: true` updates the shared `index.html` at build time. Add `sitemap: true` or `robots: true` only when requested.
|
|
86
25
|
|
|
87
|
-
##
|
|
26
|
+
## Application root
|
|
88
27
|
|
|
89
|
-
`FimoProviders`
|
|
90
|
-
`useLocation`/`useNavigate`). It reuses a host app's
|
|
91
|
-
`@tanstack/react-query` client when one exists and supplies a stable fallback
|
|
92
|
-
for adopted SPAs. This recipe still mounts an explicit provider so the app owns
|
|
93
|
-
the shared cache and its configuration:
|
|
28
|
+
`FimoProviders` needs a React Router context for Studio navigation and pageview tracking. Keep the application's existing router type:
|
|
94
29
|
|
|
95
30
|
```tsx
|
|
96
|
-
import { FimoProviders } from 'fimo/react-router';
|
|
97
31
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
32
|
+
import { FimoProviders } from 'fimo/react-router';
|
|
98
33
|
import React from 'react';
|
|
99
34
|
import { createRoot } from 'react-dom/client';
|
|
100
35
|
import { BrowserRouter } from 'react-router';
|
|
@@ -116,111 +51,45 @@ createRoot(document.getElementById('root')!).render(
|
|
|
116
51
|
);
|
|
117
52
|
```
|
|
118
53
|
|
|
119
|
-
`
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
when the app needs custom query defaults or shared cache access; adopted SPAs
|
|
123
|
-
can omit it.
|
|
54
|
+
An adopted SPA can omit the explicit `QueryClientProvider` when it does not need custom defaults; Fimo supplies a stable fallback.
|
|
55
|
+
|
|
56
|
+
## Content and labels
|
|
124
57
|
|
|
125
|
-
|
|
58
|
+
Use `fimo/ui` for tracked values:
|
|
126
59
|
|
|
127
60
|
```tsx
|
|
128
|
-
import {
|
|
61
|
+
import { Label } from 'fimo/ui';
|
|
129
62
|
|
|
130
63
|
export function App() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return (
|
|
134
|
-
<main>
|
|
135
|
-
<Text value={t('home.hero.title')} as="h1" />
|
|
136
|
-
</main>
|
|
137
|
-
);
|
|
64
|
+
return <Label value="home.hero.title" as="h1" />;
|
|
138
65
|
}
|
|
139
66
|
```
|
|
140
67
|
|
|
141
|
-
|
|
68
|
+
Use `useLabels().t()` for attributes, metadata, or composed strings. `references/labels.md` owns the complete contract.
|
|
69
|
+
|
|
70
|
+
## Project profile and browser routes
|
|
71
|
+
|
|
72
|
+
Vite defaults to `dist`. Declare a different output only when the application intentionally emits elsewhere.
|
|
73
|
+
|
|
74
|
+
A `BrowserRouter` SPA needs an application-shell rewrite for direct visits to client routes:
|
|
142
75
|
|
|
143
76
|
```json
|
|
144
77
|
{
|
|
145
78
|
"runtime": { "framework": "vite" },
|
|
146
79
|
"hosting": {
|
|
147
80
|
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
|
|
148
|
-
},
|
|
149
|
-
"version": "4",
|
|
150
|
-
"seo": {
|
|
151
|
-
"title": "__PROJECT_SLUG__",
|
|
152
|
-
"siteName": "__PROJECT_SLUG__"
|
|
153
|
-
},
|
|
154
|
-
"routes": {
|
|
155
|
-
"home": {
|
|
156
|
-
"label": "Home",
|
|
157
|
-
"path": "/"
|
|
158
|
-
}
|
|
159
81
|
}
|
|
160
82
|
}
|
|
161
83
|
```
|
|
162
84
|
|
|
163
|
-
|
|
164
|
-
hosting. Omit it for `HashRouter` or real per-route static output. See
|
|
165
|
-
`references/frameworks/hosting.md`.
|
|
166
|
-
|
|
167
|
-
## File: `.fimo/project.json`
|
|
168
|
-
|
|
169
|
-
```json
|
|
170
|
-
{
|
|
171
|
-
"projectId": "__PROJECT_ID__",
|
|
172
|
-
"organizationId": "__ORG_ID__",
|
|
173
|
-
"apiUrl": "__API_URL__"
|
|
174
|
-
}
|
|
175
|
-
```
|
|
85
|
+
Omit the rewrite for `HashRouter` or real per-route static output. The catch-all lets the browser router render its own not-found page, but the initial host response remains HTTP 200.
|
|
176
86
|
|
|
177
|
-
|
|
87
|
+
The optional `routes` object is Studio's page catalog, not production routing.
|
|
178
88
|
|
|
179
|
-
|
|
180
|
-
{
|
|
181
|
-
"compilerOptions": {
|
|
182
|
-
"target": "ES2022",
|
|
183
|
-
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
184
|
-
"module": "ESNext",
|
|
185
|
-
"moduleResolution": "Bundler",
|
|
186
|
-
"jsx": "react-jsx",
|
|
187
|
-
"strict": true,
|
|
188
|
-
"esModuleInterop": true,
|
|
189
|
-
"skipLibCheck": true,
|
|
190
|
-
"resolveJsonModule": true,
|
|
191
|
-
"isolatedModules": true,
|
|
192
|
-
"types": ["vite/client"]
|
|
193
|
-
},
|
|
194
|
-
"include": ["src", "*.config.ts"]
|
|
195
|
-
}
|
|
196
|
-
```
|
|
89
|
+
## Boundaries
|
|
197
90
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
repeat with the developer. `fimo deploy` is on-demand (hosted preview / shareable
|
|
204
|
-
link / go live), run only on the developer's signal; the dashboard's preview iframe
|
|
205
|
-
shows the **deployed** app, not the localhost dev server.
|
|
206
|
-
|
|
207
|
-
## Known limitations vs. React Router
|
|
208
|
-
|
|
209
|
-
- **Per-route SEO that crawlers see** requires either (a) using React Router
|
|
210
|
-
framework mode with prerender, (b) a Vite SSG plugin like `vite-plugin-ssg`,
|
|
211
|
-
or (c) accepting that the crawler sees the home SEO for every URL.
|
|
212
|
-
- **Dashboard "live edit SEO" preview** requires a reload on plain Vite —
|
|
213
|
-
there's no React-side head-mutation component yet. The static `seo` plugin
|
|
214
|
-
bakes SEO at build time.
|
|
215
|
-
- **Routing**: `FimoProviders` requires a React Router context, so this recipe
|
|
216
|
-
wires `BrowserRouter` from `react-router`. You can swap it for another
|
|
217
|
-
React Router setup (e.g. a `createBrowserRouter` data router with
|
|
218
|
-
`<RouterProvider>`), but a `<Router>` ancestor is mandatory — the runtime's
|
|
219
|
-
preview bridge and pageview tracker call `useLocation`/`useNavigate`.
|
|
220
|
-
|
|
221
|
-
## What to do next
|
|
222
|
-
|
|
223
|
-
- Add a sitemap: pass `fimo({ seo: true, sitemap: true })` and set
|
|
224
|
-
`.fimo/config.json#seo.url` to your production base URL.
|
|
225
|
-
- Look up exports: see `references/ui.md`.
|
|
226
|
-
- Use schema content: see `references/content.md`.
|
|
91
|
+
- The application owns routes, links, locale resolution, and browser behavior.
|
|
92
|
+
- Build-time SEO changes one HTML shell. Crawler-visible per-route SEO requires prerendering or a framework with native route output.
|
|
93
|
+
- Do not add React Router framework-mode files to a plain Vite application.
|
|
94
|
+
- Use `fimo deploy` only when the developer requests a hosted preview or publication.
|
|
95
|
+
- Load `references/ui.md` for rendering and `references/frameworks/hosting.md` for hosting overrides.
|
|
@@ -4,16 +4,24 @@ Labels are project-wide, locale-scoped, editor-managed static copy. Use them for
|
|
|
4
4
|
|
|
5
5
|
For label CLI writes and missing-key validation, load `fimo-cli/references/labels.md`.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Vite and React Router
|
|
8
|
+
|
|
9
|
+
Standalone visible copy can use `Label` because these runtimes already provide label context:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<Label value="hero.title" as="h1" />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use `t()` for attributes, metadata, and composed strings:
|
|
8
16
|
|
|
9
17
|
```tsx
|
|
10
18
|
const { t } = useLabels();
|
|
11
|
-
return <
|
|
19
|
+
return <input placeholder={String(t('email.placeholder'))} />;
|
|
12
20
|
```
|
|
13
21
|
|
|
14
|
-
`t(key)` returns a source-tracked `FimoString`. Render
|
|
22
|
+
`t(key)` returns a source-tracked `FimoString`. Render visible values with `Text`; convert with `String(t(...))` only for HTML attributes or framework APIs that require a primitive.
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
Label keys — the first argument to `t()` and the `value` of `Label` — must be string literals so extraction and source tracking remain deterministic:
|
|
17
25
|
|
|
18
26
|
```tsx
|
|
19
27
|
const items = [
|
|
@@ -32,9 +40,11 @@ The label contract is shared; acquisition differs by runtime:
|
|
|
32
40
|
|
|
33
41
|
- Next server: `getLabels({ locale? })` from `fimo/next`.
|
|
34
42
|
- Next client: `useLabels()` from `fimo/next/client`, under `FimoProvider`.
|
|
35
|
-
- React Router/Vite client: `useLabels()` from `fimo/ui`, under the existing framework integration.
|
|
43
|
+
- React Router/Vite client: `Label` and `useLabels()` from `fimo/ui`, under the existing framework integration.
|
|
44
|
+
- SvelteKit: resolve the locale in the root server load and return `getLabels({ apiUrl, event, locale })`. Wrap the root layout with `FimoProvider` from `fimo/sveltekit/components`; the snapshot supplies its locale. Descendants use `Label` from that entrypoint or `useLabels().t()` from `fimo/sveltekit`. Pass the same resolved locale to `createFimo({ content, event, locale })` in content loads.
|
|
45
|
+
- Astro server page: `getLabels({ locale? })` from `fimo/astro`; no provider.
|
|
36
46
|
|
|
37
|
-
Load
|
|
47
|
+
Load the matching framework reference before choosing a provider or server reader.
|
|
38
48
|
|
|
39
49
|
## Locale behavior
|
|
40
50
|
|
|
@@ -27,13 +27,15 @@ For an already linked project, enable each locale in Fimo before writing non-def
|
|
|
27
27
|
## Fimo responsibilities
|
|
28
28
|
|
|
29
29
|
- Fetch the correct localized content variant and label dictionary after receiving locale.
|
|
30
|
-
-
|
|
30
|
+
- Resolve an omitted locale to the project default; server reads let the tenant API choose it.
|
|
31
31
|
- Preserve one shared entry for schemas with `i18n.enabled: false`.
|
|
32
32
|
- Preserve source metadata for editing.
|
|
33
33
|
|
|
34
34
|
## Framework handoff
|
|
35
35
|
|
|
36
36
|
- Next.js → load `references/frameworks/next/locales.md`.
|
|
37
|
+
- Astro → load `references/frameworks/astro.md` and pass the locale resolved by the page.
|
|
38
|
+
- SvelteKit → load `references/frameworks/sveltekit.md`; resolve locale in the app's load functions and pass it to Fimo reads.
|
|
37
39
|
- React Router standard locale routing → load `references/frameworks/react-router.md`.
|
|
38
40
|
- Vite + React/custom React router → load `references/frameworks/vite-react.md` and pass locale through its existing provider seam.
|
|
39
41
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Rendering primitives
|
|
2
2
|
|
|
3
3
|
Use Fimo components for source-tracked schema and label values so Studio can identify the field being rendered. Generated reads wrap editable fields with source metadata; pass the whole value to the matching primitive because unwrapping it first removes Studio's edit target.
|
|
4
4
|
|
|
5
|
-
| Schema/read value | Component
|
|
6
|
-
| -------------------------------- |
|
|
7
|
-
| string/text/date as `FimoString` | `Text`
|
|
8
|
-
| richtext as `FimoRichText` | `RichText`
|
|
9
|
-
| media as `FimoMedia` | `Image`
|
|
10
|
-
| non-schema URL | `StaticImage`
|
|
11
|
-
| media as `FimoMedia` | `Video`
|
|
12
|
-
| date as `FimoString` | `Date`
|
|
13
|
-
| boolean as `FimoBoolean` | `Boolean`
|
|
14
|
-
| source-tagged plain JSON | `Json`
|
|
15
|
-
| number | normal JSX
|
|
16
|
-
| reference | target fields
|
|
17
|
-
| blocks | nested fields
|
|
5
|
+
| Schema/read value | Component | Use |
|
|
6
|
+
| -------------------------------- | ------------------------------ | ------------------------------------------------------------------ |
|
|
7
|
+
| string/text/date as `FimoString` | `Text` | editable text and `t()` values |
|
|
8
|
+
| richtext as `FimoRichText` | `RichText` | Tiptap JSONContent |
|
|
9
|
+
| media as `FimoMedia` | `Image` | schema media images |
|
|
10
|
+
| non-schema URL | `StaticImage` | decorative/static image URLs |
|
|
11
|
+
| media as `FimoMedia` | `Video` | schema media videos |
|
|
12
|
+
| date as `FimoString` | `Date` | schema dates |
|
|
13
|
+
| boolean as `FimoBoolean` | `Boolean` | schema booleans |
|
|
14
|
+
| source-tagged plain JSON | `Json` | schema JSON |
|
|
15
|
+
| number | normal JSX; SvelteKit `Number` | numbers stay plain; SvelteKit `Number` formats display-only values |
|
|
16
|
+
| reference | target fields | populate before rendering |
|
|
17
|
+
| blocks | nested fields | render each value with its primitive |
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
20
|
<Text value={article.title} as="h1" />
|
|
@@ -46,6 +46,8 @@ Do not render those values as `{program.title}` or `{highlight.label}`. That dis
|
|
|
46
46
|
|
|
47
47
|
Use `<StaticImage>` only when the image is deliberately not editor-managed. Use `String(value)` for attributes/third-party APIs that cannot accept a `FimoString`; keep editable visible text in `<Text>`.
|
|
48
48
|
|
|
49
|
+
Numeric fields stay plain JavaScript numbers, so they do not carry Studio source metadata. SvelteKit's `Number` component is an optional display/formatting helper; it is not source-editable. Other framework surfaces should render numeric fields normally until a shared tracked-number contract exists.
|
|
50
|
+
|
|
49
51
|
Never construct `FimoString`, `FimoRichText`, `FimoBoolean`, or `FimoMedia` manually. Generated clients and label readers attach the correct source path.
|
|
50
52
|
|
|
51
53
|
## Imports
|
|
@@ -55,8 +57,10 @@ Choose the framework surface:
|
|
|
55
57
|
- Next Server Components and data functions → `fimo/next`
|
|
56
58
|
- Next Client Components → `fimo/next/client`
|
|
57
59
|
- React Router/Vite client → `fimo/ui`
|
|
60
|
+
- Astro pages → `fimo/astro/components`
|
|
61
|
+
- Svelte components → `fimo/sveltekit/components`
|
|
58
62
|
|
|
59
|
-
Load the framework reference before copying an example. Next server and client imports are deliberately separate so React Query/client code does not leak into server bundles.
|
|
63
|
+
Load the framework reference before copying an example. Next server and client imports are deliberately separate so React Query/client code does not leak into server bundles. Astro uses native `.astro` components and does not require React.
|
|
60
64
|
|
|
61
65
|
## Component ownership
|
|
62
66
|
|