fimo-vite 2.9.0-staging.4 → 2.9.0-staging.6
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/plugins/seo.js +13 -6
- package/package.json +4 -4
package/dist/plugins/seo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getConfigServer } from 'fimo/config';
|
|
2
|
-
import { normalizePathname, resolveSeoForPath } from 'fimo/seo';
|
|
2
|
+
import { buildCanonicalUrl, buildSiteSchemas, normalizePathname, resolveSeoForPath, serializeJsonLd } from 'fimo/seo';
|
|
3
3
|
class HtmlTag {
|
|
4
4
|
tags = [];
|
|
5
5
|
addMeta(name, content) {
|
|
@@ -51,6 +51,8 @@ export default function seoPlugin() {
|
|
|
51
51
|
if (seo.favicon) {
|
|
52
52
|
nextHtml = nextHtml.replace(/<link\b[^>]*\brel=(?:"[^"]*icon[^"]*"|'[^']*icon[^']*'|[^>\s]*icon[^>\s]*)[^>]*>/gi, '');
|
|
53
53
|
}
|
|
54
|
+
// The built index.html serves every route, so only a dev request knows which page it renders.
|
|
55
|
+
const canonical = ctx?.originalUrl ? buildCanonicalUrl(seo.url, ctx.originalUrl) : undefined;
|
|
54
56
|
const tags = new HtmlTag();
|
|
55
57
|
if (seo.description) {
|
|
56
58
|
tags.addMeta('description', seo.description);
|
|
@@ -61,8 +63,8 @@ export default function seoPlugin() {
|
|
|
61
63
|
if (seo.themeColor) {
|
|
62
64
|
tags.addMeta('theme-color', seo.themeColor);
|
|
63
65
|
}
|
|
64
|
-
if (
|
|
65
|
-
tags.addLink('canonical',
|
|
66
|
+
if (canonical) {
|
|
67
|
+
tags.addLink('canonical', canonical);
|
|
66
68
|
}
|
|
67
69
|
if (seo.favicon) {
|
|
68
70
|
tags.addLink('icon', seo.favicon);
|
|
@@ -76,8 +78,8 @@ export default function seoPlugin() {
|
|
|
76
78
|
tags.addProperty('og:description', seo.description);
|
|
77
79
|
}
|
|
78
80
|
tags.addProperty('og:type', 'website');
|
|
79
|
-
if (
|
|
80
|
-
tags.addProperty('og:url',
|
|
81
|
+
if (canonical) {
|
|
82
|
+
tags.addProperty('og:url', canonical);
|
|
81
83
|
}
|
|
82
84
|
if (seo.siteName) {
|
|
83
85
|
tags.addProperty('og:site_name', seo.siteName);
|
|
@@ -102,7 +104,12 @@ export default function seoPlugin() {
|
|
|
102
104
|
if (seo.image) {
|
|
103
105
|
tags.addMeta('twitter:image', seo.image);
|
|
104
106
|
}
|
|
105
|
-
|
|
107
|
+
const schemaTags = buildSiteSchemas(config.seo).map((schema) => ({
|
|
108
|
+
tag: 'script',
|
|
109
|
+
attrs: { type: 'application/ld+json' },
|
|
110
|
+
children: serializeJsonLd(schema),
|
|
111
|
+
}));
|
|
112
|
+
return { html: nextHtml, tags: [...tags.list(), ...schemaTags] };
|
|
106
113
|
}
|
|
107
114
|
catch {
|
|
108
115
|
return html;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fimo-vite",
|
|
3
|
-
"version": "2.9.0-staging.
|
|
3
|
+
"version": "2.9.0-staging.6",
|
|
4
4
|
"description": "Framework-neutral Fimo Vite plugin. Pairs with the fimo package at the same version.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"oxc-parser": "^0.118.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@fimo/tsconfig": "2.9.0-staging.
|
|
34
|
+
"@fimo/tsconfig": "2.9.0-staging.6",
|
|
35
35
|
"@types/node": "22.18.6",
|
|
36
|
-
"fimo": "2.9.0-staging.
|
|
36
|
+
"fimo": "2.9.0-staging.6",
|
|
37
37
|
"typescript": "7.0.2",
|
|
38
38
|
"vite": "8.3.4",
|
|
39
39
|
"vitest": "5.0.4"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"fimo": "2.9.0-staging.
|
|
42
|
+
"fimo": "2.9.0-staging.6",
|
|
43
43
|
"vite": "^7.0.0 || ^8.0.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|