@cmssy/next 0.5.1 → 0.5.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/index.cjs CHANGED
@@ -284,11 +284,10 @@ function createCmssyRobots(config, options = {}) {
284
284
  return {
285
285
  rules,
286
286
  ...includeSitemap ? { sitemap: `${baseUrl}/sitemap.xml` } : {},
287
- ...baseUrl ? { host: baseUrl } : {}
287
+ ...options.host && baseUrl ? { host: baseUrl } : {}
288
288
  };
289
289
  };
290
290
  }
291
- var DEFAULT_EXCLUDED_SLUGS = ["/not-found", "/404"];
292
291
  function normalizeSlug(slug) {
293
292
  if (slug === "/" || slug === "") return "/";
294
293
  return slug.startsWith("/") ? slug : `/${slug}`;
@@ -312,13 +311,17 @@ function createCmssySitemap(config, options = {}) {
312
311
  }
313
312
  pages = [];
314
313
  }
314
+ let notFoundPageId = null;
315
+ try {
316
+ notFoundPageId = (await react.fetchSiteConfig(clientConfig))?.notFoundPageId ?? null;
317
+ } catch {
318
+ notFoundPageId = null;
319
+ }
315
320
  const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
316
321
  const defaultLocale = config.defaultLocale ?? "en";
317
322
  const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : [defaultLocale];
318
- const excluded = new Set(
319
- (options.excludeSlugs ?? DEFAULT_EXCLUDED_SLUGS).map(normalizeSlug)
320
- );
321
- const entries = pages.map((page) => ({ ...page, slug: normalizeSlug(page.slug) })).filter((page) => !excluded.has(page.slug)).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) => {
322
325
  const lastModified = page.updatedAt ?? page.publishedAt ?? void 0;
323
326
  const entry = {
324
327
  url: `${baseUrl}${localizedPath(page.slug, defaultLocale, defaultLocale)}`,
package/dist/index.d.cts CHANGED
@@ -80,10 +80,16 @@ interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
80
80
  rules?: MetadataRoute.Robots["rules"];
81
81
  /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
82
82
  sitemap?: boolean;
83
+ /**
84
+ * Emit the non-standard `Host:` directive (a Yandex extension). Google
85
+ * ignores it and reports a warning in Search Console, so it is off by
86
+ * default. Enable only when targeting Yandex.
87
+ */
88
+ host?: boolean;
83
89
  }
84
90
  /**
85
- * Builds the default export for Next's `app/robots.ts`. Allows crawling, points
86
- * to the sitemap, and reports the canonical host. Drop in as:
91
+ * Builds the default export for Next's `app/robots.ts`. Allows crawling and
92
+ * points to the sitemap. Drop in as:
87
93
  *
88
94
  * export default createCmssyRobots(cmssy);
89
95
  */
@@ -93,8 +99,9 @@ interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
93
99
  /** Extra static entries appended to the generated page list. */
94
100
  extra?: MetadataRoute.Sitemap;
95
101
  /**
96
- * Page slugs to omit (e.g. the 404 content page). Defaults to the reserved
97
- * not-found slugs so a published 404 page is never advertised as indexable.
102
+ * Additional page slugs to omit. The workspace's configured 404 page
103
+ * (Settings 404 page) is excluded automatically via its id, so this is
104
+ * only for extra slugs you never want indexed.
98
105
  */
99
106
  excludeSlugs?: string[];
100
107
  }
package/dist/index.d.ts CHANGED
@@ -80,10 +80,16 @@ interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
80
80
  rules?: MetadataRoute.Robots["rules"];
81
81
  /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
82
82
  sitemap?: boolean;
83
+ /**
84
+ * Emit the non-standard `Host:` directive (a Yandex extension). Google
85
+ * ignores it and reports a warning in Search Console, so it is off by
86
+ * default. Enable only when targeting Yandex.
87
+ */
88
+ host?: boolean;
83
89
  }
84
90
  /**
85
- * Builds the default export for Next's `app/robots.ts`. Allows crawling, points
86
- * to the sitemap, and reports the canonical host. Drop in as:
91
+ * Builds the default export for Next's `app/robots.ts`. Allows crawling and
92
+ * points to the sitemap. Drop in as:
87
93
  *
88
94
  * export default createCmssyRobots(cmssy);
89
95
  */
@@ -93,8 +99,9 @@ interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
93
99
  /** Extra static entries appended to the generated page list. */
94
100
  extra?: MetadataRoute.Sitemap;
95
101
  /**
96
- * Page slugs to omit (e.g. the 404 content page). Defaults to the reserved
97
- * not-found slugs so a published 404 page is never advertised as indexable.
102
+ * Additional page slugs to omit. The workspace's configured 404 page
103
+ * (Settings 404 page) is excluded automatically via its id, so this is
104
+ * only for extra slugs you never want indexed.
98
105
  */
99
106
  excludeSlugs?: string[];
100
107
  }
package/dist/index.js CHANGED
@@ -282,11 +282,10 @@ function createCmssyRobots(config, options = {}) {
282
282
  return {
283
283
  rules,
284
284
  ...includeSitemap ? { sitemap: `${baseUrl}/sitemap.xml` } : {},
285
- ...baseUrl ? { host: baseUrl } : {}
285
+ ...options.host && baseUrl ? { host: baseUrl } : {}
286
286
  };
287
287
  };
288
288
  }
289
- var DEFAULT_EXCLUDED_SLUGS = ["/not-found", "/404"];
290
289
  function normalizeSlug(slug) {
291
290
  if (slug === "/" || slug === "") return "/";
292
291
  return slug.startsWith("/") ? slug : `/${slug}`;
@@ -310,13 +309,17 @@ function createCmssySitemap(config, options = {}) {
310
309
  }
311
310
  pages = [];
312
311
  }
312
+ let notFoundPageId = null;
313
+ try {
314
+ notFoundPageId = (await fetchSiteConfig(clientConfig))?.notFoundPageId ?? null;
315
+ } catch {
316
+ notFoundPageId = null;
317
+ }
313
318
  const baseUrl = await resolveSeoBaseUrl(config, options.baseUrl);
314
319
  const defaultLocale = config.defaultLocale ?? "en";
315
320
  const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : [defaultLocale];
316
- const excluded = new Set(
317
- (options.excludeSlugs ?? DEFAULT_EXCLUDED_SLUGS).map(normalizeSlug)
318
- );
319
- const entries = pages.map((page) => ({ ...page, slug: normalizeSlug(page.slug) })).filter((page) => !excluded.has(page.slug)).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) => {
320
323
  const lastModified = page.updatedAt ?? page.publishedAt ?? void 0;
321
324
  const entry = {
322
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.1",
3
+ "version": "0.5.3",
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.1",
44
+ "@cmssy/react": "^0.5.3",
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.1"
57
+ "@cmssy/react": "0.5.3"
58
58
  },
59
59
  "dependencies": {
60
60
  "jose": "^6.2.3"