@cmssy/next 0.5.0 → 0.5.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/dist/index.cjs CHANGED
@@ -288,9 +288,13 @@ function createCmssyRobots(config, options = {}) {
288
288
  };
289
289
  };
290
290
  }
291
+ function normalizeSlug(slug) {
292
+ if (slug === "/" || slug === "") return "/";
293
+ return slug.startsWith("/") ? slug : `/${slug}`;
294
+ }
291
295
  function localizedPath(slug, locale, defaultLocale) {
292
- const base = slug === "/" ? "" : slug;
293
- return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
296
+ const normalized = slug === "/" ? "" : slug;
297
+ return locale === defaultLocale ? normalized || "/" : `/${locale}${normalized}`;
294
298
  }
295
299
  function createCmssySitemap(config, options = {}) {
296
300
  const clientConfig = {
@@ -307,10 +311,17 @@ function createCmssySitemap(config, options = {}) {
307
311
  }
308
312
  pages = [];
309
313
  }
314
+ let notFoundPageId = null;
315
+ try {
316
+ notFoundPageId = (await react.fetchSiteConfig(clientConfig))?.notFoundPageId ?? null;
317
+ } catch {
318
+ notFoundPageId = null;
319
+ }
310
320
  const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
311
321
  const defaultLocale = config.defaultLocale ?? "en";
312
322
  const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : [defaultLocale];
313
- const entries = pages.map((page) => {
323
+ const excluded = new Set((options.excludeSlugs ?? []).map(normalizeSlug));
324
+ const entries = pages.map((page) => ({ ...page, slug: normalizeSlug(page.slug) })).filter((page) => page.id !== notFoundPageId && !excluded.has(page.slug)).map((page) => {
314
325
  const lastModified = page.updatedAt ?? page.publishedAt ?? void 0;
315
326
  const entry = {
316
327
  url: `${baseUrl}${localizedPath(page.slug, defaultLocale, defaultLocale)}`,
package/dist/index.d.cts CHANGED
@@ -92,6 +92,12 @@ declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmss
92
92
  interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
93
93
  /** Extra static entries appended to the generated page list. */
94
94
  extra?: MetadataRoute.Sitemap;
95
+ /**
96
+ * Additional page slugs to omit. The workspace's configured 404 page
97
+ * (Settings → 404 page) is excluded automatically via its id, so this is
98
+ * only for extra slugs you never want indexed.
99
+ */
100
+ excludeSlugs?: string[];
95
101
  }
96
102
  /**
97
103
  * Builds the default export for Next's `app/sitemap.ts` from the workspace's
package/dist/index.d.ts CHANGED
@@ -92,6 +92,12 @@ declare function createCmssyRobots(config: CmssyNextConfig, options?: CreateCmss
92
92
  interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
93
93
  /** Extra static entries appended to the generated page list. */
94
94
  extra?: MetadataRoute.Sitemap;
95
+ /**
96
+ * Additional page slugs to omit. The workspace's configured 404 page
97
+ * (Settings → 404 page) is excluded automatically via its id, so this is
98
+ * only for extra slugs you never want indexed.
99
+ */
100
+ excludeSlugs?: string[];
95
101
  }
96
102
  /**
97
103
  * Builds the default export for Next's `app/sitemap.ts` from the workspace's
package/dist/index.js CHANGED
@@ -286,9 +286,13 @@ function createCmssyRobots(config, options = {}) {
286
286
  };
287
287
  };
288
288
  }
289
+ function normalizeSlug(slug) {
290
+ if (slug === "/" || slug === "") return "/";
291
+ return slug.startsWith("/") ? slug : `/${slug}`;
292
+ }
289
293
  function localizedPath(slug, locale, defaultLocale) {
290
- const base = slug === "/" ? "" : slug;
291
- return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
294
+ const normalized = slug === "/" ? "" : slug;
295
+ return locale === defaultLocale ? normalized || "/" : `/${locale}${normalized}`;
292
296
  }
293
297
  function createCmssySitemap(config, options = {}) {
294
298
  const clientConfig = {
@@ -305,10 +309,17 @@ function createCmssySitemap(config, options = {}) {
305
309
  }
306
310
  pages = [];
307
311
  }
312
+ let notFoundPageId = null;
313
+ try {
314
+ notFoundPageId = (await fetchSiteConfig(clientConfig))?.notFoundPageId ?? null;
315
+ } catch {
316
+ notFoundPageId = null;
317
+ }
308
318
  const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
309
319
  const defaultLocale = config.defaultLocale ?? "en";
310
320
  const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : [defaultLocale];
311
- const entries = pages.map((page) => {
321
+ const excluded = new Set((options.excludeSlugs ?? []).map(normalizeSlug));
322
+ const entries = pages.map((page) => ({ ...page, slug: normalizeSlug(page.slug) })).filter((page) => page.id !== notFoundPageId && !excluded.has(page.slug)).map((page) => {
312
323
  const lastModified = page.updatedAt ?? page.publishedAt ?? void 0;
313
324
  const entry = {
314
325
  url: `${baseUrl}${localizedPath(page.slug, defaultLocale, defaultLocale)}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -41,7 +41,7 @@
41
41
  "dist"
42
42
  ],
43
43
  "peerDependencies": {
44
- "@cmssy/react": "^0.5.0",
44
+ "@cmssy/react": "^0.5.2",
45
45
  "next": ">=15",
46
46
  "react": "^18.2.0 || ^19.0.0",
47
47
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -54,7 +54,7 @@
54
54
  "tsup": "^8.3.0",
55
55
  "typescript": "^5.6.0",
56
56
  "vitest": "^2.1.0",
57
- "@cmssy/react": "0.5.0"
57
+ "@cmssy/react": "0.5.2"
58
58
  },
59
59
  "dependencies": {
60
60
  "jose": "^6.2.3"