fimo-react-router 2.10.1-staging.1 → 2.10.1-staging.3

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/dist/seo.d.ts CHANGED
@@ -3,33 +3,43 @@ type FimoSEO = NonNullable<ReturnType<typeof resolveSeoForPath>>;
3
3
  export declare function getSeoForPath(pathname: string, routeData?: unknown): FimoSEO | undefined;
4
4
  export declare function buildMetaForPath(pathname: string, routeData?: unknown): ({
5
5
  title: string;
6
- name?: undefined;
7
- property?: undefined;
8
- content?: undefined;
9
6
  tagName?: undefined;
10
7
  rel?: undefined;
11
8
  href?: undefined;
12
9
  } | {
10
+ "data-fimo-spa-shell"?: undefined;
13
11
  title?: undefined;
14
- name: string;
12
+ property: string;
15
13
  content: string;
16
- property?: undefined;
17
14
  tagName?: undefined;
18
15
  rel?: undefined;
19
16
  href?: undefined;
20
17
  } | {
18
+ "data-fimo-spa-shell": string;
21
19
  title?: undefined;
22
- name?: undefined;
23
20
  property: string;
24
21
  content: string;
25
22
  tagName?: undefined;
26
23
  rel?: undefined;
27
24
  href?: undefined;
25
+ } | {
26
+ "data-fimo-spa-shell"?: undefined;
27
+ title?: undefined;
28
+ name: string;
29
+ content: string;
30
+ tagName?: undefined;
31
+ rel?: undefined;
32
+ href?: undefined;
33
+ } | {
34
+ "data-fimo-spa-shell": string;
35
+ title?: undefined;
36
+ name: string;
37
+ content: string;
38
+ tagName?: undefined;
39
+ rel?: undefined;
40
+ href?: undefined;
28
41
  } | {
29
42
  title?: undefined;
30
- name?: undefined;
31
- property?: undefined;
32
- content?: undefined;
33
43
  tagName: string;
34
44
  rel: string;
35
45
  href: string;
@@ -41,33 +51,43 @@ export declare function buildFimoMeta(args: {
41
51
  matches: readonly unknown[];
42
52
  }): ({
43
53
  title: string;
44
- name?: undefined;
45
- property?: undefined;
46
- content?: undefined;
47
54
  tagName?: undefined;
48
55
  rel?: undefined;
49
56
  href?: undefined;
50
57
  } | {
58
+ "data-fimo-spa-shell"?: undefined;
51
59
  title?: undefined;
52
- name: string;
60
+ property: string;
53
61
  content: string;
54
- property?: undefined;
55
62
  tagName?: undefined;
56
63
  rel?: undefined;
57
64
  href?: undefined;
58
65
  } | {
66
+ "data-fimo-spa-shell": string;
59
67
  title?: undefined;
60
- name?: undefined;
61
68
  property: string;
62
69
  content: string;
63
70
  tagName?: undefined;
64
71
  rel?: undefined;
65
72
  href?: undefined;
73
+ } | {
74
+ "data-fimo-spa-shell"?: undefined;
75
+ title?: undefined;
76
+ name: string;
77
+ content: string;
78
+ tagName?: undefined;
79
+ rel?: undefined;
80
+ href?: undefined;
81
+ } | {
82
+ "data-fimo-spa-shell": string;
83
+ title?: undefined;
84
+ name: string;
85
+ content: string;
86
+ tagName?: undefined;
87
+ rel?: undefined;
88
+ href?: undefined;
66
89
  } | {
67
90
  title?: undefined;
68
- name?: undefined;
69
- property?: undefined;
70
- content?: undefined;
71
91
  tagName: string;
72
92
  rel: string;
73
93
  href: string;
package/dist/seo.js CHANGED
@@ -8,6 +8,12 @@ const config = rawConfig;
8
8
  export function getSeoForPath(pathname, routeData) {
9
9
  return resolveSeoForPath(pathname, config, routeData);
10
10
  }
11
+ /**
12
+ * Marks the SPA shell's image tags. Social crawlers read only the shell, so it keeps the site image,
13
+ * but React adds the page's image next to it instead of replacing it. In the browser,
14
+ * `buildFimoMeta` removes the marked tags before React renders the page's own.
15
+ */
16
+ const SPA_SHELL_TAG = 'data-fimo-spa-shell';
11
17
  /**
12
18
  * `canonical` is undefined for the SPA shell. With `pageTags: false` the description and the
13
19
  * social title and description stay out too: React Router adds the page's own next to them,
@@ -16,6 +22,7 @@ export function getSeoForPath(pathname, routeData) {
16
22
  function seoToMeta(seo, canonical, pageTags = true) {
17
23
  const description = pageTags ? seo.description : undefined;
18
24
  const socialTitle = pageTags ? seo.title : undefined;
25
+ const shellTag = pageTags ? {} : { [SPA_SHELL_TAG]: '' };
19
26
  return [
20
27
  ...(seo.title ? [{ title: seo.title }] : []),
21
28
  ...(description ? [{ name: 'description', content: description }] : []),
@@ -26,13 +33,13 @@ function seoToMeta(seo, canonical, pageTags = true) {
26
33
  ...(socialTitle ? [{ property: 'og:title', content: socialTitle }] : []),
27
34
  ...(description ? [{ property: 'og:description', content: description }] : []),
28
35
  ...(canonical ? [{ property: 'og:url', content: canonical }] : []),
29
- ...(seo.image ? [{ property: 'og:image', content: seo.image }] : []),
36
+ ...(seo.image ? [{ property: 'og:image', content: seo.image, ...shellTag }] : []),
30
37
  ...(seo.locale ? [{ property: 'og:locale', content: seo.locale }] : []),
31
38
  { name: 'twitter:card', content: 'summary_large_image' },
32
39
  ...(seo.twitterSite ? [{ name: 'twitter:site', content: seo.twitterSite }] : []),
33
40
  ...(socialTitle ? [{ name: 'twitter:title', content: socialTitle }] : []),
34
41
  ...(description ? [{ name: 'twitter:description', content: description }] : []),
35
- ...(seo.image ? [{ name: 'twitter:image', content: seo.image }] : []),
42
+ ...(seo.image ? [{ name: 'twitter:image', content: seo.image, ...shellTag }] : []),
36
43
  ...(canonical ? [{ tagName: 'link', rel: 'canonical', href: canonical }] : []),
37
44
  ...(seo.favicon
38
45
  ? [
@@ -57,13 +64,18 @@ export function buildFimoMeta(args) {
57
64
  ? (firstMatch.loaderData ?? firstMatch.data)
58
65
  : undefined;
59
66
  const rootRecord = rootData && typeof rootData === 'object' ? rootData : undefined;
67
+ // The SPA shell is one HTML file served for every path, so only the browser knows which page it shows.
68
+ const isSpaShell = rootRecord?.fimoSpaShell === true;
69
+ if (isSpaShell && typeof document !== 'undefined') {
70
+ // This runs while React renders, before it commits the tags returned below, so React never
71
+ // takes a marked shell tag as the page's own.
72
+ document.head?.querySelectorAll(`meta[${SPA_SHELL_TAG}]`).forEach((tag) => tag.remove());
73
+ }
60
74
  const seo = getSeoForPath(pathname, rootRecord?.fimoMetaData);
61
75
  if (!seo) {
62
76
  return [];
63
77
  }
64
- // The SPA shell is one HTML file served for every path, so only the browser knows which page it shows.
65
- const isSpaShellRender = rootRecord?.fimoSpaShell === true && typeof document === 'undefined';
66
- if (isSpaShellRender) {
78
+ if (isSpaShell && typeof document === 'undefined') {
67
79
  return seoToMeta(seo, undefined, false);
68
80
  }
69
81
  return seoToMeta(seo, buildCanonicalUrl(seo.url, pathname));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fimo-react-router",
3
- "version": "2.10.1-staging.1",
3
+ "version": "2.10.1-staging.3",
4
4
  "description": "Fimo runtime, routing and build integration for React Router projects. Pairs with the fimo package at the same version.",
5
5
  "files": [
6
6
  "dist/",
@@ -42,14 +42,14 @@
42
42
  "react-error-boundary": "^6.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@fimo/tsconfig": "2.10.1-staging.1",
45
+ "@fimo/tsconfig": "2.10.1-staging.3",
46
46
  "@tanstack/react-query": "^5.80.6",
47
47
  "@types/node": "22.18.6",
48
48
  "@types/react": "19.2.14",
49
49
  "@types/react-dom": "19.2.3",
50
- "fimo": "2.10.1-staging.1",
51
- "fimo-react": "2.10.1-staging.1",
52
- "fimo-vite": "2.10.1-staging.1",
50
+ "fimo": "2.10.1-staging.3",
51
+ "fimo-react": "2.10.1-staging.3",
52
+ "fimo-vite": "2.10.1-staging.3",
53
53
  "react": "19.2.4",
54
54
  "react-dom": "19.2.4",
55
55
  "react-router": "7.18.4",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@tanstack/react-query": "^5.80.6",
62
- "fimo": "2.10.1-staging.1",
62
+ "fimo": "2.10.1-staging.3",
63
63
  "fimo-react": ">=2.0.1",
64
64
  "fimo-vite": ">=2.0.1",
65
65
  "react": "^18.2.0 || ^19.0.0",