fimo 2.4.0-staging.1 → 2.4.0-staging.10
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/assets/skills/fimo-cli/SKILL.md +3 -2
- package/assets/skills/fimo-cli/references/agent-setup.md +2 -1
- package/assets/skills/fimo-cli/references/agents.md +13 -1
- package/assets/skills/fimo-cli/references/branches.md +4 -4
- package/assets/skills/fimo-cli/references/deploy.md +3 -6
- package/assets/skills/fimo-cli/references/domains.md +5 -5
- package/assets/skills/fimo-cli/references/forms.md +4 -2
- package/assets/skills/fimo-cli/references/hosting.md +5 -4
- package/assets/skills/fimo-cli/references/preview.md +1 -1
- package/assets/skills/fimo-cli/references/projects.md +5 -5
- package/assets/skills/fimo-cli/references/site-checks.md +73 -0
- package/assets/skills/fimo-code/SKILL.md +1 -0
- package/assets/skills/fimo-code/references/assets.md +4 -2
- package/assets/skills/fimo-code/references/best-practices/next.md +0 -2
- package/assets/skills/fimo-code/references/content/schema.md +4 -1
- package/assets/skills/fimo-code/references/design.md +2 -2
- package/assets/skills/fimo-code/references/frameworks/astro.md +37 -1
- package/assets/skills/fimo-code/references/frameworks/compatibility.md +5 -5
- package/assets/skills/fimo-code/references/frameworks/hosting.md +23 -2
- package/assets/skills/fimo-code/references/frameworks/next/app-router.md +7 -21
- package/assets/skills/fimo-code/references/frameworks/next/seo.md +168 -0
- package/assets/skills/fimo-code/references/frameworks/next.md +1 -1
- package/assets/skills/fimo-code/references/frameworks/seo-head.md +78 -0
- package/assets/skills/fimo-code/references/frameworks/sveltekit.md +57 -4
- package/assets/skills/fimo-migration/SKILL.md +33 -33
- package/assets/skills/fimo-migration/references/content.md +1 -1
- package/assets/skills/fimo-migration/references/frameworks/nextjs.md +7 -0
- package/assets/skills/fimo-migration/references/import-contract.md +4 -6
- package/assets/skills/fimo-migration/references/manifest.md +4 -3
- package/assets/skills/fimo-migration/references/qa.md +6 -0
- package/assets/skills/fimo-migration/references/questions-and-improvements.md +1 -1
- package/assets/skills/fimo-migration/references/workflow.md +7 -5
- package/assets/skills/fimo-studio/references/agents.md +7 -1
- package/assets/skills/fimo-studio/references/billing-and-credits.md +21 -7
- package/assets/skills/fimo-studio/references/seo-settings.md +2 -0
- package/dist/cli/bundle.json +2 -2
- package/dist/cli/index.js +502 -986
- package/dist/runtime/astro/server-runtime.js +2 -2
- package/dist/runtime/paths/get-fimo-paths.js +1 -1
- package/dist/runtime/seo/head.d.ts +31 -0
- package/dist/runtime/seo/head.js +47 -0
- package/dist/runtime/seo/index.d.ts +2 -0
- package/dist/runtime/seo/index.js +1 -0
- package/dist/runtime/seo/resolver.d.ts +16 -2
- package/dist/runtime/seo/resolver.js +10 -0
- package/dist/runtime/seo/server.d.ts +13 -0
- package/dist/runtime/seo/server.js +23 -0
- package/dist/runtime/shared/branch-identity.d.ts +3 -5
- package/dist/runtime/shared/branch-identity.js +3 -5
- package/dist/runtime/shared/fimo-config.server.d.ts +2 -0
- package/dist/runtime/shared/fimo-config.server.js +18 -14
- package/dist/scripts/export-static.d.ts +3 -4
- package/dist/scripts/export-static.js +3 -20
- package/dist/scripts/sync-schemas.js +12 -5
- package/package.json +12 -8
- package/templates/astro/.fimo/config.json +1 -0
- package/templates/astro/AGENTS.md +1 -1
- package/templates/astro/astro.config.mjs +1 -0
- package/templates/astro/package.json +2 -2
- package/templates/astro/src/layouts/Base.astro +20 -4
- package/templates/astro/src/pages/[locale]/index.astro +1 -1
- package/templates/astro/src/pages/[locale]/projects/[slug].astro +4 -1
- package/templates/astro/src/pages/index.astro +1 -1
- package/templates/astro/src/pages/projects/[slug].astro +4 -1
- package/templates/nextjs/AGENTS.md +1 -1
- package/templates/nextjs/package.json +3 -3
- package/templates/nextjs/src/app/layout.tsx +5 -3
- package/templates/nextjs/src/app/page.tsx +6 -0
- package/templates/react-router/package.json +4 -4
- package/templates/sveltekit/AGENTS.md +1 -1
- package/templates/sveltekit/package.json +2 -2
- package/templates/sveltekit/src/routes/+layout.server.ts +4 -0
- package/templates/sveltekit/src/routes/+layout.svelte +12 -0
- package/templates/sveltekit/src/routes/[[locale=locale]]/+page.svelte +0 -5
- package/templates/vite/package.json +4 -4
- package/assets/skills/fimo-migration/scripts/build-canonical-manifest.mjs +0 -595
|
@@ -9,8 +9,8 @@ export const astroServerContentRuntime = {
|
|
|
9
9
|
headers(extra) {
|
|
10
10
|
const headers = { ...extra };
|
|
11
11
|
// `FIMO_ENV` is the variable name a customer's deployed build reads and
|
|
12
|
-
// keeps its spelling; only the header this build emits is canonical
|
|
13
|
-
//
|
|
12
|
+
// keeps its spelling; only the header this build emits is canonical.
|
|
13
|
+
// Builds already in production keep sending
|
|
14
14
|
// `X-Fimo-Env`, which the API still accepts.
|
|
15
15
|
const branch = import.meta.env.FIMO_ENV?.trim();
|
|
16
16
|
if (branch) {
|
|
@@ -47,7 +47,7 @@ async function fetchEntries(baseUrl, schema, rootDir, locale) {
|
|
|
47
47
|
}
|
|
48
48
|
const headers = {};
|
|
49
49
|
// `FIMO_ENV` is a customer-facing variable name and keeps its spelling; the
|
|
50
|
-
// header this build emits is canonical
|
|
50
|
+
// header this build emits is canonical. A
|
|
51
51
|
// deployed site always talks to the current API, and builds produced by an
|
|
52
52
|
// older `fimo` keep sending `X-Fimo-Env`, which the API still accepts.
|
|
53
53
|
const branch = readEnvValue(rootDir, 'FIMO_ENV') ?? resolveLocalRuntimeEnv({ cwd: rootDir })?.env;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FimoSEO } from '../shared/fimo-config.types.js';
|
|
2
|
+
export type FimoHeadMeta = {
|
|
3
|
+
name: string;
|
|
4
|
+
content: string;
|
|
5
|
+
} | {
|
|
6
|
+
property: string;
|
|
7
|
+
content: string;
|
|
8
|
+
};
|
|
9
|
+
export interface FimoHeadLink {
|
|
10
|
+
rel: string;
|
|
11
|
+
href: string;
|
|
12
|
+
}
|
|
13
|
+
/** Document head for one page: spread each entry onto a `<meta>` or `<link>`. */
|
|
14
|
+
export interface FimoHead {
|
|
15
|
+
title?: string;
|
|
16
|
+
meta: FimoHeadMeta[];
|
|
17
|
+
links: FimoHeadLink[];
|
|
18
|
+
}
|
|
19
|
+
export interface SeoHeadOptions {
|
|
20
|
+
/** Final canonical URL chosen by the app, also used for og:url. Omit to emit neither tag. */
|
|
21
|
+
canonicalUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Convert final SEO values to native tag attributes without I/O, route resolution
|
|
25
|
+
* or merging. The app resolves content and policy first. Absent/empty fields emit
|
|
26
|
+
* no tags; omitted SEO emits an empty head unless a canonical URL is supplied.
|
|
27
|
+
* `seo.url` is a site base, not a page canonical: only options.canonicalUrl emits
|
|
28
|
+
* canonical/og:url. Render attributes through the framework, never as raw HTML.
|
|
29
|
+
*/
|
|
30
|
+
export declare function toSeoHead(seo?: FimoSEO, options?: SeoHeadOptions): FimoHead;
|
|
31
|
+
//# sourceMappingURL=head.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert final SEO values to native tag attributes without I/O, route resolution
|
|
3
|
+
* or merging. The app resolves content and policy first. Absent/empty fields emit
|
|
4
|
+
* no tags; omitted SEO emits an empty head unless a canonical URL is supplied.
|
|
5
|
+
* `seo.url` is a site base, not a page canonical: only options.canonicalUrl emits
|
|
6
|
+
* canonical/og:url. Render attributes through the framework, never as raw HTML.
|
|
7
|
+
*/
|
|
8
|
+
export function toSeoHead(seo = {}, options = {}) {
|
|
9
|
+
const canonical = options.canonicalUrl;
|
|
10
|
+
if (!Object.values(seo).some(Boolean) && !canonical) {
|
|
11
|
+
return { meta: [], links: [] };
|
|
12
|
+
}
|
|
13
|
+
const meta = [];
|
|
14
|
+
const named = (name, content) => {
|
|
15
|
+
if (content) {
|
|
16
|
+
meta.push({ name, content });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const property = (name, content) => {
|
|
20
|
+
if (content) {
|
|
21
|
+
meta.push({ property: name, content });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
named('description', seo.description);
|
|
25
|
+
named('robots', seo.robots);
|
|
26
|
+
named('theme-color', seo.themeColor);
|
|
27
|
+
property('og:type', 'website');
|
|
28
|
+
property('og:site_name', seo.siteName);
|
|
29
|
+
property('og:title', seo.title);
|
|
30
|
+
property('og:description', seo.description);
|
|
31
|
+
property('og:url', canonical);
|
|
32
|
+
property('og:image', seo.image);
|
|
33
|
+
property('og:locale', seo.locale);
|
|
34
|
+
named('twitter:card', 'summary_large_image');
|
|
35
|
+
named('twitter:site', seo.twitterSite);
|
|
36
|
+
named('twitter:title', seo.title);
|
|
37
|
+
named('twitter:description', seo.description);
|
|
38
|
+
named('twitter:image', seo.image);
|
|
39
|
+
const links = [];
|
|
40
|
+
if (canonical) {
|
|
41
|
+
links.push({ rel: 'canonical', href: canonical });
|
|
42
|
+
}
|
|
43
|
+
if (seo.favicon) {
|
|
44
|
+
links.push({ rel: 'icon', href: seo.favicon }, { rel: 'apple-touch-icon', href: seo.favicon });
|
|
45
|
+
}
|
|
46
|
+
return { ...(seo.title ? { title: seo.title } : {}), meta, links };
|
|
47
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FimoRouteConfig, FimoSEO, RouteSEO } from '../shared/fimo-config.types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Shared SEO resolver for the generated app.
|
|
4
4
|
*
|
|
@@ -40,5 +40,19 @@ export declare function matchRoutePath(pathname: string, pathPattern: string): {
|
|
|
40
40
|
export declare function resolveRouteConfig(pathname: string, routes: Record<string, FimoRouteConfig> | undefined): FimoRouteConfig | undefined;
|
|
41
41
|
export declare function getNestedValue(input: unknown, path: string): unknown;
|
|
42
42
|
export declare function resolveTemplate(template: string, context: Record<string, unknown>): string;
|
|
43
|
-
|
|
43
|
+
/** SEO slices of an imported JSON config; unrelated framework literal unions need not be preserved. */
|
|
44
|
+
export interface FimoSeoConfig {
|
|
45
|
+
seo?: FimoSEO;
|
|
46
|
+
i18n?: {
|
|
47
|
+
defaultLocale?: string;
|
|
48
|
+
locales?: string[];
|
|
49
|
+
};
|
|
50
|
+
routes?: Record<string, {
|
|
51
|
+
path?: string;
|
|
52
|
+
label?: string;
|
|
53
|
+
seo?: RouteSEO;
|
|
54
|
+
params?: object;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
57
|
+
export declare function resolveSeoForPath(pathname: string, config: FimoSeoConfig, routeData?: unknown): FimoSEO | undefined;
|
|
44
58
|
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -86,6 +86,16 @@ export function resolveTemplate(template, context) {
|
|
|
86
86
|
}
|
|
87
87
|
function resolveSeoField(routeValue, globalValue, context) {
|
|
88
88
|
if (routeValue) {
|
|
89
|
+
for (const token of routeValue.matchAll(/\{\{([^}]+)\}\}/g)) {
|
|
90
|
+
const raw = getNestedValue(context, token[1].trim());
|
|
91
|
+
const value = raw instanceof String || raw instanceof Number || raw instanceof Boolean ? raw.valueOf() : raw;
|
|
92
|
+
if (value == null ||
|
|
93
|
+
(typeof value === 'string' && value.trim() === '') ||
|
|
94
|
+
!['string', 'number', 'boolean'].includes(typeof value) ||
|
|
95
|
+
(typeof value === 'number' && !Number.isFinite(value))) {
|
|
96
|
+
return globalValue;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
89
99
|
return resolveTemplate(routeValue, context);
|
|
90
100
|
}
|
|
91
101
|
return globalValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FimoSEO } from '../shared/fimo-config.types.js';
|
|
2
|
+
export interface GetFimoSeoOptions {
|
|
3
|
+
pathname?: string;
|
|
4
|
+
routeData?: Record<string, unknown>;
|
|
5
|
+
rootDir?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Read global SEO, or resolve an explicit pathname against the project's route
|
|
9
|
+
* catalog. Node only. Missing config/SEO returns undefined; other read and JSON
|
|
10
|
+
* errors propagate. No cache: rendering/revalidation remains application-owned.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getFimoSeo({ pathname, routeData, rootDir }?: GetFimoSeoOptions): FimoSEO | undefined;
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readConfigServer } from '../shared/fimo-config.server.js';
|
|
2
|
+
import { resolveSeoForPath } from './resolver.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read global SEO, or resolve an explicit pathname against the project's route
|
|
5
|
+
* catalog. Node only. Missing config/SEO returns undefined; other read and JSON
|
|
6
|
+
* errors propagate. No cache: rendering/revalidation remains application-owned.
|
|
7
|
+
*/
|
|
8
|
+
export function getFimoSeo({ pathname, routeData, rootDir = process.cwd() } = {}) {
|
|
9
|
+
let config;
|
|
10
|
+
try {
|
|
11
|
+
config = readConfigServer(rootDir);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
if (pathname !== undefined) {
|
|
20
|
+
return resolveSeoForPath(pathname, config, routeData);
|
|
21
|
+
}
|
|
22
|
+
return config.seo && Object.keys(config.seo).length > 0 ? config.seo : undefined;
|
|
23
|
+
}
|
|
@@ -19,8 +19,7 @@ export declare const PROD_BRANCH_PREFIX = "release/";
|
|
|
19
19
|
export declare function isValidBranch(branch: string): boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Mirror of `envResourceKey` in `@fimo/api-contracts`. Keeps that name on both
|
|
22
|
-
* sides: its OUTPUT is a live tenant hostname and R2 prefix
|
|
23
|
-
* rename is a later slice (branch-cutover ledger, F10).
|
|
22
|
+
* sides: its OUTPUT is a live tenant hostname and R2 prefix.
|
|
24
23
|
*/
|
|
25
24
|
export declare function envResourceKey(branch: string): string;
|
|
26
25
|
/** Mirror of `buildTenantApiUrl` in `@fimo/api-contracts`. */
|
|
@@ -32,15 +31,14 @@ export declare function buildTenantApiUrl(projectId: string, branch: string, ten
|
|
|
32
31
|
* reads is one more line to reason about when a site talks to the wrong Branch.
|
|
33
32
|
*
|
|
34
33
|
* These are process-env variable names in a CUSTOMER's app; they keep their
|
|
35
|
-
* `ENV` spelling
|
|
34
|
+
* `ENV` spelling.
|
|
36
35
|
*/
|
|
37
36
|
export declare const LOCAL_CONTENT_API_ENV_KEYS: readonly ['FIMO_CONTENT_API_URL', 'VITE_API_URL', 'NEXT_PUBLIC_FIMO_API_URL', 'PUBLIC_FIMO_API_URL'];
|
|
38
37
|
/**
|
|
39
38
|
* Branch selectors a runtime turns into the Branch request header.
|
|
40
39
|
*
|
|
41
40
|
* `FIMO_ENV` / `NEXT_PUBLIC_FIMO_ENV` are the variable names a customer's
|
|
42
|
-
* deployed build reads; renaming either breaks it
|
|
43
|
-
* "Names that must not be mechanically renamed").
|
|
41
|
+
* deployed build reads; renaming either breaks it.
|
|
44
42
|
*/
|
|
45
43
|
export declare const LOCAL_ENV_SELECTOR_KEYS: readonly ['FIMO_ENV', 'NEXT_PUBLIC_FIMO_ENV'];
|
|
46
44
|
/**
|
|
@@ -46,8 +46,7 @@ function fnv1a8(s) {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Mirror of `envResourceKey` in `@fimo/api-contracts`. Keeps that name on both
|
|
49
|
-
* sides: its OUTPUT is a live tenant hostname and R2 prefix
|
|
50
|
-
* rename is a later slice (branch-cutover ledger, F10).
|
|
49
|
+
* sides: its OUTPUT is a live tenant hostname and R2 prefix.
|
|
51
50
|
*/
|
|
52
51
|
export function envResourceKey(branch) {
|
|
53
52
|
const base = branch
|
|
@@ -71,7 +70,7 @@ export function buildTenantApiUrl(projectId, branch, tenantApiBaseUrl) {
|
|
|
71
70
|
* reads is one more line to reason about when a site talks to the wrong Branch.
|
|
72
71
|
*
|
|
73
72
|
* These are process-env variable names in a CUSTOMER's app; they keep their
|
|
74
|
-
* `ENV` spelling
|
|
73
|
+
* `ENV` spelling.
|
|
75
74
|
*/
|
|
76
75
|
export const LOCAL_CONTENT_API_ENV_KEYS = [
|
|
77
76
|
'FIMO_CONTENT_API_URL',
|
|
@@ -83,8 +82,7 @@ export const LOCAL_CONTENT_API_ENV_KEYS = [
|
|
|
83
82
|
* Branch selectors a runtime turns into the Branch request header.
|
|
84
83
|
*
|
|
85
84
|
* `FIMO_ENV` / `NEXT_PUBLIC_FIMO_ENV` are the variable names a customer's
|
|
86
|
-
* deployed build reads; renaming either breaks it
|
|
87
|
-
* "Names that must not be mechanically renamed").
|
|
85
|
+
* deployed build reads; renaming either breaks it.
|
|
88
86
|
*/
|
|
89
87
|
export const LOCAL_ENV_SELECTOR_KEYS = ['FIMO_ENV', 'NEXT_PUBLIC_FIMO_ENV'];
|
|
90
88
|
/**
|
|
@@ -4,6 +4,8 @@ import type { FimoConfig } from './fimo-config.types.js';
|
|
|
4
4
|
* Reads JSON directly to avoid virtual module issues during config loading.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getConfigServer(rootDir: string): FimoConfig;
|
|
7
|
+
/** Read the selected config without swallowing I/O or JSON errors. */
|
|
8
|
+
export declare function readConfigServer(rootDir: string): FimoConfig;
|
|
7
9
|
export declare function getConfigVersion(rootDir: string): number;
|
|
8
10
|
/** Resolve the current config path while keeping legacy projects readable. */
|
|
9
11
|
export declare function resolveFimoConfigPath(rootDir: string): string;
|
|
@@ -13,25 +13,29 @@ const defaultConfig = {
|
|
|
13
13
|
*/
|
|
14
14
|
export function getConfigServer(rootDir) {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
const content = readFileSync(configPath, 'utf-8');
|
|
18
|
-
// `fimo validate` owns strict config validation. The public runtime only
|
|
19
|
-
// reads the already-validated values and must stay self-contained: importing
|
|
20
|
-
// the repository-private API contracts package would break installed apps.
|
|
21
|
-
const raw = JSON.parse(content);
|
|
22
|
-
return {
|
|
23
|
-
runtime: raw.runtime,
|
|
24
|
-
hosting: raw.hosting,
|
|
25
|
-
seo: raw.seo,
|
|
26
|
-
i18n: raw.i18n,
|
|
27
|
-
routes: raw.routes,
|
|
28
|
-
version: raw.version,
|
|
29
|
-
};
|
|
16
|
+
return readConfigServer(rootDir);
|
|
30
17
|
}
|
|
31
18
|
catch {
|
|
32
19
|
return defaultConfig;
|
|
33
20
|
}
|
|
34
21
|
}
|
|
22
|
+
/** Read the selected config without swallowing I/O or JSON errors. */
|
|
23
|
+
export function readConfigServer(rootDir) {
|
|
24
|
+
const configPath = resolveFimoConfigPath(rootDir);
|
|
25
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
26
|
+
// `fimo validate` owns strict config validation. The public runtime only
|
|
27
|
+
// reads the already-validated values and must stay self-contained: importing
|
|
28
|
+
// the repository-private API contracts package would break installed apps.
|
|
29
|
+
const raw = JSON.parse(content);
|
|
30
|
+
return {
|
|
31
|
+
runtime: raw.runtime,
|
|
32
|
+
hosting: raw.hosting,
|
|
33
|
+
seo: raw.seo,
|
|
34
|
+
i18n: raw.i18n,
|
|
35
|
+
routes: raw.routes,
|
|
36
|
+
version: raw.version,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
35
39
|
export function getConfigVersion(rootDir) {
|
|
36
40
|
try {
|
|
37
41
|
const configPath = resolveFimoConfigPath(rootDir);
|
|
@@ -2,10 +2,9 @@ export interface ExportStaticOptions {
|
|
|
2
2
|
cwd?: string;
|
|
3
3
|
}
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* never fetched because navigation uses full-page <a> loads)
|
|
5
|
+
* Removes `dist/server/` after a static React Router build. Requires
|
|
6
|
+
* `dist/client/` to exist and preserves its contents, including `*.data`
|
|
7
|
+
* files used by React Router client navigation or authored as static assets.
|
|
9
8
|
*
|
|
10
9
|
* Run from `react-router build && fimo export-static`.
|
|
11
10
|
*/
|
|
@@ -9,23 +9,10 @@ async function pathExists(targetPath) {
|
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
async function removeDataFiles(dir) {
|
|
13
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
14
|
-
for (const entry of entries) {
|
|
15
|
-
const fullPath = path.join(dir, entry.name);
|
|
16
|
-
if (entry.isDirectory()) {
|
|
17
|
-
await removeDataFiles(fullPath);
|
|
18
|
-
}
|
|
19
|
-
else if (entry.name.endsWith('.data')) {
|
|
20
|
-
await fs.rm(fullPath);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
12
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* never fetched because navigation uses full-page <a> loads)
|
|
13
|
+
* Removes `dist/server/` after a static React Router build. Requires
|
|
14
|
+
* `dist/client/` to exist and preserves its contents, including `*.data`
|
|
15
|
+
* files used by React Router client navigation or authored as static assets.
|
|
29
16
|
*
|
|
30
17
|
* Run from `react-router build && fimo export-static`.
|
|
31
18
|
*/
|
|
@@ -36,12 +23,8 @@ export async function exportStatic(options = {}) {
|
|
|
36
23
|
if (!(await pathExists(clientDir))) {
|
|
37
24
|
throw new Error('Missing dist/client output. Run `react-router build` first.');
|
|
38
25
|
}
|
|
39
|
-
// In framework mode with buildDirectory=dist, the static output already lives in dist/client.
|
|
40
26
|
if (await pathExists(serverDir)) {
|
|
41
27
|
await fs.rm(serverDir, { recursive: true, force: true });
|
|
42
28
|
}
|
|
43
|
-
// Remove .data files — all data is embedded in prerendered HTML.
|
|
44
|
-
// Navigation uses <a> tags (full page loads), so .data files are never fetched.
|
|
45
|
-
await removeDataFiles(clientDir);
|
|
46
29
|
console.log('Static export complete.');
|
|
47
30
|
}
|
|
@@ -144,6 +144,7 @@ function resolveProjectRuntime(cwd) {
|
|
|
144
144
|
version,
|
|
145
145
|
providesLegacyReactRuntime: packageExportsSubpath(packageJson, './ui'),
|
|
146
146
|
providesReactRuntime: packageExportsSubpath(readProjectPackage(cwd, 'fimo-react'), '.'),
|
|
147
|
+
providesLegacyNextRuntime: packageExportsSubpath(packageJson, './next') && packageExportsSubpath(packageJson, './next/client'),
|
|
147
148
|
providesNextRuntime: packageExportsSubpath(readProjectPackage(cwd, 'fimo-next'), '.') &&
|
|
148
149
|
packageExportsSubpath(readProjectPackage(cwd, 'fimo-next'), './client'),
|
|
149
150
|
providesAstroRuntime: packageExportsSubpath(packageJson, './astro'),
|
|
@@ -154,7 +155,7 @@ function resolveProjectRuntime(cwd) {
|
|
|
154
155
|
}
|
|
155
156
|
function contentRuntimeImportFor(framework, runtime) {
|
|
156
157
|
if (framework === 'nextjs') {
|
|
157
|
-
return 'fimo-next';
|
|
158
|
+
return isVersionAtLeast(runtime.version, MINIMUM_FRAMEWORK_COMPANION_RUNTIME_VERSION) ? 'fimo-next' : 'fimo/next';
|
|
158
159
|
}
|
|
159
160
|
if (framework === 'astro') {
|
|
160
161
|
return 'fimo/astro';
|
|
@@ -196,6 +197,12 @@ function resolveSchemaGenerationTarget(runtimeImport, runtime) {
|
|
|
196
197
|
if (runtimeImport === 'fimo-react') {
|
|
197
198
|
return 'react';
|
|
198
199
|
}
|
|
200
|
+
if (runtimeImport === 'fimo/next' && !runtime.providesLegacyNextRuntime) {
|
|
201
|
+
throw new Error(`Cannot generate schema clients because project-local fimo@${runtime.version} does not provide the ` +
|
|
202
|
+
'legacy fimo/next and fimo/next/client exports required by this Next.js project. ' +
|
|
203
|
+
`Run \`${CONTENT_CLIENT_RUNTIME_UPGRADE_COMMAND}\` in the project, then run \`npx fimo@latest validate\` again. ` +
|
|
204
|
+
'No generated files were changed.');
|
|
205
|
+
}
|
|
199
206
|
if (runtimeImport === 'fimo-next' && !runtime.providesNextRuntime) {
|
|
200
207
|
throw new Error(`Cannot generate schema clients because the project does not provide the ` +
|
|
201
208
|
'fimo-next and fimo-next/client exports required by this Next.js project. ' +
|
|
@@ -213,7 +220,7 @@ function resolveSchemaGenerationTarget(runtimeImport, runtime) {
|
|
|
213
220
|
`Run \`npm install fimo-sveltekit@${runtime.version}\` in the project, then run \`npx fimo@latest validate\` again. ` +
|
|
214
221
|
'No generated files were changed.');
|
|
215
222
|
}
|
|
216
|
-
if (runtimeImport === 'fimo-next') {
|
|
223
|
+
if (runtimeImport === 'fimo/next' || runtimeImport === 'fimo-next') {
|
|
217
224
|
return 'next';
|
|
218
225
|
}
|
|
219
226
|
return runtimeImport === 'fimo/astro' ? 'astro' : 'sveltekit';
|
|
@@ -224,17 +231,17 @@ function templatesForTarget(target, runtime, runtimeImport) {
|
|
|
224
231
|
{
|
|
225
232
|
suffix: '.types.ts',
|
|
226
233
|
path: templatePath(runtime, 'types'),
|
|
227
|
-
runtimeImport
|
|
234
|
+
runtimeImport,
|
|
228
235
|
},
|
|
229
236
|
{
|
|
230
237
|
suffix: '.ts',
|
|
231
238
|
path: templatePath(runtime, 'nextServer'),
|
|
232
|
-
runtimeImport
|
|
239
|
+
runtimeImport,
|
|
233
240
|
},
|
|
234
241
|
{
|
|
235
242
|
suffix: '.client.ts',
|
|
236
243
|
path: templatePath(runtime, 'nextClient'),
|
|
237
|
-
runtimeImport:
|
|
244
|
+
runtimeImport: `${runtimeImport}/client`,
|
|
238
245
|
},
|
|
239
246
|
];
|
|
240
247
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fimo",
|
|
3
|
-
"version": "2.4.0-staging.
|
|
3
|
+
"version": "2.4.0-staging.10",
|
|
4
4
|
"description": "Fimo CLI - create, deploy, and manage Fimo projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro-component"
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
"types": "./dist/runtime/seo/index.d.ts",
|
|
58
58
|
"import": "./dist/runtime/seo/index.js"
|
|
59
59
|
},
|
|
60
|
+
"./seo/server": {
|
|
61
|
+
"types": "./dist/runtime/seo/server.d.ts",
|
|
62
|
+
"import": "./dist/runtime/seo/server.js"
|
|
63
|
+
},
|
|
60
64
|
"./sync": {
|
|
61
65
|
"types": "./dist/scripts/index.d.ts",
|
|
62
66
|
"import": "./dist/scripts/index.js"
|
|
@@ -189,13 +193,13 @@
|
|
|
189
193
|
"devDependencies": {
|
|
190
194
|
"@clack/core": "^1.2.0",
|
|
191
195
|
"@clack/prompts": "^1.2.0",
|
|
192
|
-
"@fimo/agents-bundle": "2.4.0-staging.
|
|
193
|
-
"@fimo/api-contracts": "2.4.0-staging.
|
|
194
|
-
"@fimo/cli-kit": "2.4.0-staging.
|
|
195
|
-
"@fimo/framework-detect": "2.4.0-staging.
|
|
196
|
-
"@fimo/routes": "2.4.0-staging.
|
|
197
|
-
"@fimo/sdk": "2.4.0-staging.
|
|
198
|
-
"@fimo/tsconfig": "2.4.0-staging.
|
|
196
|
+
"@fimo/agents-bundle": "2.4.0-staging.10",
|
|
197
|
+
"@fimo/api-contracts": "2.4.0-staging.10",
|
|
198
|
+
"@fimo/cli-kit": "2.4.0-staging.10",
|
|
199
|
+
"@fimo/framework-detect": "2.4.0-staging.10",
|
|
200
|
+
"@fimo/routes": "2.4.0-staging.10",
|
|
201
|
+
"@fimo/sdk": "2.4.0-staging.10",
|
|
202
|
+
"@fimo/tsconfig": "2.4.0-staging.10",
|
|
199
203
|
"@types/node": "22.18.6",
|
|
200
204
|
"agent-install": "^0.0.5",
|
|
201
205
|
"astro": "^7.1.6",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"project": {
|
|
19
19
|
"label": "Project",
|
|
20
20
|
"path": "/:locale/projects/:slug",
|
|
21
|
+
"seo": { "title": "{{project.title}}", "description": "{{project.summary}}" },
|
|
21
22
|
"params": {
|
|
22
23
|
"locale": { "type": "locale", "optional": true },
|
|
23
24
|
"slug": { "schema": "Project", "queryField": "slug", "displayField": "title" }
|
|
@@ -31,7 +31,7 @@ a code-only task, or use `npx fimo@latest` for project-local code generation and
|
|
|
31
31
|
- Treat the user's language request as part of setup. The first explicitly requested locale is the primary locale. Load `fimo skills get fimo-cli --ref locales` and use `fimo locales` to configure the exact locale set and default. Never edit `i18n.defaultLocale` or `i18n.locales` directly. If no language is requested, keep `en` and state that choice. Astro reads the synchronized config, keeps the default locale unprefixed, and prefixes the others.
|
|
32
32
|
- Preserve both the unprefixed default pages and the `[locale]` page tree. Astro has no optional single-segment file route, so the paired native pages keep one-locale URLs clean and allow another locale without changing the route shape. Use `Astro.currentLocale` for Fimo content reads, `getLabels`, and document language.
|
|
33
33
|
- Keep `.fimo/config.json#routes` as Studio metadata aligned with Astro's page files. It does not configure Astro routing.
|
|
34
|
-
- Astro owns routes, locale resolution, links
|
|
34
|
+
- Astro owns routes, locale resolution, links and SEO. Base.astro resolves the actual path with `resolveSeoForPath` and renders `toSeoHead` from `fimo/seo`. Content pages pass already-resolved `seo` with their route data. Keep title/social tags in agreement and preserve the app's canonical policy.
|
|
35
35
|
- Use generated schema clients, `getLabels({ locale })`, and native components from `fimo/astro/components` for editable values.
|
|
36
36
|
- Do not add React or a second deployment platform.
|
|
37
37
|
- Never edit `.fimo/project.json`; it links this directory to the remote project.
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"check": "astro sync && astro check"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"fimo": "2.4.0-staging.
|
|
13
|
-
"fimo-astro": "2.4.0-staging.
|
|
12
|
+
"fimo": "2.4.0-staging.10",
|
|
13
|
+
"fimo-astro": "2.4.0-staging.10"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@astrojs/check": "^0.9.10",
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { resolveSeoForPath, toSeoHead, type FimoSEO } from 'fimo/seo';
|
|
3
|
+
|
|
4
|
+
import fimoConfig from '../../.fimo/config.json';
|
|
5
|
+
|
|
2
6
|
interface Props {
|
|
3
7
|
lang: string;
|
|
4
|
-
title
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
seo?: FimoSEO;
|
|
11
|
+
canonicalUrl?: string | null;
|
|
5
12
|
}
|
|
6
13
|
|
|
7
|
-
const { lang, title } = Astro.props;
|
|
14
|
+
const { lang, title, description, seo = resolveSeoForPath(Astro.url.pathname, fimoConfig) } = Astro.props;
|
|
15
|
+
const canonicalUrl = Astro.props.canonicalUrl === undefined
|
|
16
|
+
? (seo?.url ? new URL(Astro.url.pathname, seo.url).href : undefined)
|
|
17
|
+
: Astro.props.canonicalUrl ?? undefined;
|
|
18
|
+
const head = toSeoHead({
|
|
19
|
+
...seo,
|
|
20
|
+
...(title !== undefined ? { title } : {}),
|
|
21
|
+
...(description !== undefined ? { description } : {}),
|
|
22
|
+
}, { canonicalUrl });
|
|
8
23
|
---
|
|
9
24
|
|
|
10
25
|
<!doctype html>
|
|
@@ -12,10 +27,11 @@ const { lang, title } = Astro.props;
|
|
|
12
27
|
<head>
|
|
13
28
|
<meta charset="UTF-8" />
|
|
14
29
|
<meta name="viewport" content="width=device-width" />
|
|
15
|
-
<
|
|
30
|
+
<title>{head.title ?? 'Fimo + Astro'}</title>
|
|
31
|
+
{head.meta.map((attributes) => <meta {...attributes} />)}
|
|
32
|
+
{head.links.map((attributes) => <link {...attributes} />)}
|
|
16
33
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
17
34
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
|
|
18
|
-
<title>{title}</title>
|
|
19
35
|
</head>
|
|
20
36
|
<body>
|
|
21
37
|
<slot />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getLabels } from 'fimo/astro';
|
|
3
3
|
import { Text } from 'fimo/astro/components';
|
|
4
|
+
import { resolveSeoForPath } from 'fimo/seo';
|
|
4
5
|
|
|
6
|
+
import config from '../../../../.fimo/config.json';
|
|
5
7
|
import Base from '../../../layouts/Base.astro';
|
|
6
8
|
import { prefixedLocales } from '../../../locales';
|
|
7
9
|
import * as Project from '../../../schemas/Project';
|
|
@@ -22,9 +24,10 @@ const [project, labels] = await Promise.all([Project.getBySlug(slug, { locale })
|
|
|
22
24
|
if (!project) {
|
|
23
25
|
return Astro.redirect('/404');
|
|
24
26
|
}
|
|
27
|
+
const seo = resolveSeoForPath(Astro.url.pathname, config, { project });
|
|
25
28
|
---
|
|
26
29
|
|
|
27
|
-
<Base lang={locale} title={String(project.title)}>
|
|
30
|
+
<Base lang={locale} seo={seo} title={seo?.title ?? String(project.title)}>
|
|
28
31
|
<main data-framework="astro" data-rendering="server" data-project-slug={slug}>
|
|
29
32
|
<a href={`/${locale}/projects`}><Text as="span" value={labels.t('navigation.projects')} /></a>
|
|
30
33
|
<article>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getLabels } from 'fimo/astro';
|
|
3
3
|
import { Text } from 'fimo/astro/components';
|
|
4
|
+
import { resolveSeoForPath } from 'fimo/seo';
|
|
4
5
|
|
|
6
|
+
import config from '../../../.fimo/config.json';
|
|
5
7
|
import Base from '../../layouts/Base.astro';
|
|
6
8
|
import { defaultLocale } from '../../locales';
|
|
7
9
|
import * as Project from '../../schemas/Project';
|
|
@@ -15,9 +17,10 @@ const [project, labels] = await Promise.all([Project.getBySlug(slug, { locale })
|
|
|
15
17
|
if (!project) {
|
|
16
18
|
return Astro.redirect('/404');
|
|
17
19
|
}
|
|
20
|
+
const seo = resolveSeoForPath(Astro.url.pathname, config, { project });
|
|
18
21
|
---
|
|
19
22
|
|
|
20
|
-
<Base lang={locale} title={String(project.title)}>
|
|
23
|
+
<Base lang={locale} seo={seo} title={seo?.title ?? String(project.title)}>
|
|
21
24
|
<main data-framework="astro" data-rendering="server" data-project-slug={slug}>
|
|
22
25
|
<a href="/projects"><Text as="span" value={labels.t('navigation.projects')} /></a>
|
|
23
26
|
<article>
|
|
@@ -40,7 +40,7 @@ The scaffolded homepage is disposable. Replace it on the first real generation.
|
|
|
40
40
|
- Next's `app` tree is the router and stays authoritative: the default shell is one ordinary root layout plus `/` as the homepage, and unknown paths get Next's native 404. When a product requires locale URLs, implement the framework-native strategy (`[locale]` segments, middleware, cookies, domains, or an i18n library), pass the resolved locale into Fimo server reads and `FimoProvider`, and load `fimo skills get fimo-code --ref frameworks/next/locales` first. Do not impose locale-prefixed URLs on a default-only project.
|
|
41
41
|
- `FimoProvider` owns the optional Studio preview runtime. Do not add a preview bridge component, read Fimo preview environment variables, or inject Fimo scripts in application code.
|
|
42
42
|
- Keep `.fimo/config.json#routes` as Studio metadata, not as the Next.js router. Describe only URLs the application actually serves; add a `:locale` segment to a route's metadata only after the application implements that locale routing. There, `params.locale.optional: true` means omit the configured default locale from the URL; use `optional: false` only when every locale, including the default, must be prefixed.
|
|
43
|
-
- The application owns
|
|
43
|
+
- The application owns SEO policy. Keep the root's global SEO wiring and the homepage's explicit route wiring. When creating or adding a page, load `fimo skills get fimo-code --ref frameworks/next/seo` and reuse the established route pattern. Resolve the real pathname and content in that route module; add route viewport wiring only for route-specific theme color. Preserve app-owned metadata and file-based images; Next replaces nested metadata objects rather than merging their fields.
|
|
44
44
|
- Do not add a second deployment platform.
|
|
45
45
|
- Never edit `.fimo/project.json`; it links this directory to the remote project.
|
|
46
46
|
- Keep `.fimo/config.json#runtime` true to the code: framework, `dev`/`build`/`install` commands, output directory. Update it when you rename a package script, move the build output, or change framework; the reference is `fimo skills get fimo-code --ref frameworks/hosting`.
|