@umituz/web-seo 2.5.0 → 2.7.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.
@@ -18,7 +18,7 @@ const JsonLdComponent = ({ data, strategy = "afterInteractive", id }) => {
18
18
  const script = document.createElement("script");
19
19
  script.type = SCRIPT_TYPE;
20
20
  script.textContent = JSON.stringify(items[index]);
21
- script.setAttribute("data-seo-id", dataIds[index]);
21
+ script.setAttribute("data-seo-id", dataIds[index] ?? "");
22
22
  script.setAttribute("data-seo-strategy", strategy);
23
23
  document.head.appendChild(script);
24
24
  if (index === 0)
@@ -21,7 +21,7 @@ export const useJsonLd = (data, options) => {
21
21
  const script = document.createElement("script");
22
22
  script.type = SCRIPT_TYPE;
23
23
  script.textContent = JSON.stringify(item);
24
- script.setAttribute("data-seo-id", ids[index]);
24
+ script.setAttribute("data-seo-id", ids[index] ?? "");
25
25
  script.setAttribute("data-seo-strategy", strategy);
26
26
  document.head.appendChild(script);
27
27
  });
@@ -10,7 +10,7 @@ const joinTags = (ctx) => ({
10
10
  });
11
11
  const findTitle = (meta) => {
12
12
  const match = meta.match(/<title>([\s\S]*?)<\/title>/);
13
- return match ? match[1] : "";
13
+ return match ? match[1] ?? "" : "";
14
14
  };
15
15
  const stripTitle = (meta) => meta.replace(/<title>[\s\S]*?<\/title>\n?/, "");
16
16
  export const renderSEO = (options) => {
@@ -57,7 +57,7 @@ export const injectRouteMeta = (htmlTemplate, meta, siteUrl, routePath) => {
57
57
  const htmlTagRegex = /<html([^>]*)>/i;
58
58
  const match = html.match(htmlTagRegex);
59
59
  if (match) {
60
- let attrs = match[1];
60
+ let attrs = match[1] ?? "";
61
61
  if (/lang=["'][^"']*["']/i.test(attrs)) {
62
62
  attrs = attrs.replace(/lang=["'][^"']*["']/i, `lang="${escapeHtml(meta.lang)}"`);
63
63
  }
@@ -6,7 +6,10 @@ const saasDisallow = ["/api/", "/auth/"];
6
6
  const withRoutes = (routes) => ["/", ...(routes ?? [])];
7
7
  export const saasSEOOptions = (siteUrl, opts = {}) => ({
8
8
  siteUrl,
9
- routes: ["/", ...(opts.landing ?? [])],
9
+ routes: [
10
+ "/",
11
+ ...(opts.landing ?? Object.keys(opts.prerender ?? { "/": {} }).filter((r) => r !== "/")),
12
+ ],
10
13
  sitemap: { filename: "sitemap.xml" },
11
14
  robotsTxt: {
12
15
  filename: "robots.txt",
@@ -34,4 +34,21 @@ describe('saasSEOOptions', () => {
34
34
  const options = saasSEOOptions('https://demo.test.dev', { prerender: {} });
35
35
  expect(options.prerender?.fallbackMeta).toEqual({});
36
36
  });
37
+ it('derives sitemap routes from the prerender map when landing is absent', () => {
38
+ const options = saasSEOOptions('https://demo.test.dev', {
39
+ prerender: {
40
+ '/': { title: 'Home' },
41
+ '/features': { title: 'Features' },
42
+ '/about': { title: 'About' },
43
+ },
44
+ });
45
+ expect(options.routes).toEqual(['/', '/features', '/about']);
46
+ });
47
+ it('prefers explicit landing routes over the prerender map', () => {
48
+ const options = saasSEOOptions('https://demo.test.dev', {
49
+ landing: ['/pricing'],
50
+ prerender: { '/': {}, '/features': {} },
51
+ });
52
+ expect(options.routes).toEqual(['/', '/pricing']);
53
+ });
37
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-seo",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "Comprehensive SEO solution for React Vite applications with structured data, performance hints, and build-time optimization",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,8 @@
11
11
  "lint": "eslint .",
12
12
  "typecheck": "tsc --noEmit",
13
13
  "prepublishOnly": "npm run build",
14
- "test": "vitest run"
14
+ "test": "vitest run",
15
+ "version:minor": "npm version minor -m 'chore: release v%s'"
15
16
  },
16
17
  "exports": {
17
18
  ".": {