@usethrottle/builder-react 0.5.0 → 0.5.1

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/server.cjs CHANGED
@@ -71,7 +71,9 @@ var isRec = (value) => typeof value === "object" && value !== null && !Array.isA
71
71
  function sitemapRulesOf(settings) {
72
72
  const seo = isRec(settings.seo) ? settings.seo : {};
73
73
  const rules = isRec(seo.sitemap) ? seo.sitemap : {};
74
- return { pages: rules.pages !== false, exclude: Array.isArray(rules.exclude) ? rules.exclude.filter((x) => typeof x === "string") : [] };
74
+ const on = (key) => rules[key] !== false;
75
+ const toggles = { pages: on("pages"), products: on("products"), collections: on("collections"), categories: on("categories"), tags: on("tags") };
76
+ return { pages: toggles.pages, exclude: Array.isArray(rules.exclude) ? rules.exclude.filter((x) => typeof x === "string") : [], toggles };
75
77
  }
76
78
  function excluded(rules, pathname, slug) {
77
79
  return rules.some((rule) => {
@@ -103,7 +105,7 @@ async function builderSitemapParts(options, extras = {}) {
103
105
  const seen = new Set(entries.map((entry) => entry.url));
104
106
  for (const contributor of _nullishCoalesce(extras.contributors, () => ( []))) {
105
107
  try {
106
- for await (const item of contributor()) {
108
+ for await (const item of contributor({ toggles: rules.toggles })) {
107
109
  const loc = typeof item.loc === "string" ? safeLoc(item.loc, origin) : null;
108
110
  if (loc === null || seen.has(loc)) continue;
109
111
  if (excluded(rules.exclude, pathnameOf(loc))) continue;
package/dist/server.d.cts CHANGED
@@ -102,8 +102,23 @@ type BuilderSitemapOptions = ClientOptions & {
102
102
  };
103
103
  /** URLs per sitemap file (the sitemaps.org limit). */
104
104
  declare const SITEMAP_MAX_URLS = 50000;
105
- /** A source of extra URLs (the catalog pack's products, collections, ...). `loc` is an absolute URL on the store's origin. */
106
- type SitemapContributor = () => AsyncIterable<{
105
+ /** The site's `seo.sitemap` toggles, resolved: each kind is `true` unless the site set it to `false`. */
106
+ type SitemapToggles = {
107
+ pages: boolean;
108
+ products: boolean;
109
+ collections: boolean;
110
+ categories: boolean;
111
+ tags: boolean;
112
+ };
113
+ /** What a contributor is called with: the site's resolved toggles, so it can skip a kind that is switched off. */
114
+ type SitemapContributorContext = {
115
+ toggles: SitemapToggles;
116
+ };
117
+ /**
118
+ * A source of extra URLs (the catalog pack's products, collections, ...). `loc` is an absolute URL on the store's origin.
119
+ * It is called with `{ toggles }`; a contributor that takes no argument still works.
120
+ */
121
+ type SitemapContributor = (context: SitemapContributorContext) => AsyncIterable<{
107
122
  loc: string;
108
123
  lastmod?: Date | string | undefined;
109
124
  }>;
@@ -256,4 +271,4 @@ type BuilderStaticParamsOptions = ClientOptions & {
256
271
  */
257
272
  declare function builderStaticParams(options: BuilderStaticParamsOptions): Promise<Record<string, string>[]>;
258
273
 
259
- export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapEntry, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
274
+ export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
package/dist/server.d.ts CHANGED
@@ -102,8 +102,23 @@ type BuilderSitemapOptions = ClientOptions & {
102
102
  };
103
103
  /** URLs per sitemap file (the sitemaps.org limit). */
104
104
  declare const SITEMAP_MAX_URLS = 50000;
105
- /** A source of extra URLs (the catalog pack's products, collections, ...). `loc` is an absolute URL on the store's origin. */
106
- type SitemapContributor = () => AsyncIterable<{
105
+ /** The site's `seo.sitemap` toggles, resolved: each kind is `true` unless the site set it to `false`. */
106
+ type SitemapToggles = {
107
+ pages: boolean;
108
+ products: boolean;
109
+ collections: boolean;
110
+ categories: boolean;
111
+ tags: boolean;
112
+ };
113
+ /** What a contributor is called with: the site's resolved toggles, so it can skip a kind that is switched off. */
114
+ type SitemapContributorContext = {
115
+ toggles: SitemapToggles;
116
+ };
117
+ /**
118
+ * A source of extra URLs (the catalog pack's products, collections, ...). `loc` is an absolute URL on the store's origin.
119
+ * It is called with `{ toggles }`; a contributor that takes no argument still works.
120
+ */
121
+ type SitemapContributor = (context: SitemapContributorContext) => AsyncIterable<{
107
122
  loc: string;
108
123
  lastmod?: Date | string | undefined;
109
124
  }>;
@@ -256,4 +271,4 @@ type BuilderStaticParamsOptions = ClientOptions & {
256
271
  */
257
272
  declare function builderStaticParams(options: BuilderStaticParamsOptions): Promise<Record<string, string>[]>;
258
273
 
259
- export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapEntry, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
274
+ export { type BuilderSitemapExtras, type BuilderSitemapOptions, type BuilderStaticParamsOptions, DEFAULT_ROBOTS_DISALLOW, type JsonLd, type LoadBuilderPageOptions, type LoadBuilderTemplateOptions, type LoadSiteOptions, LoadedPage, LoadedRedirect, LoadedSite, SITEMAP_MAX_URLS, type SeoSite, type SeoSiteOptions, type SitemapContributor, type SitemapContributorContext, type SitemapEntry, type SitemapToggles, breadcrumbJsonLd, builderRobots, builderRobotsResponse, builderSitemap, builderSitemapParts, builderStaticParams, faqJsonLd, isOwnPath, jsonLdString, loadBuilderPage, loadBuilderPageByPath, loadBuilderTemplate, loadOwnPagePaths, loadSite, localBusinessJsonLd, organizationJsonLd, siteOriginOf, webSiteJsonLd };
package/dist/server.js CHANGED
@@ -71,7 +71,9 @@ var isRec = (value) => typeof value === "object" && value !== null && !Array.isA
71
71
  function sitemapRulesOf(settings) {
72
72
  const seo = isRec(settings.seo) ? settings.seo : {};
73
73
  const rules = isRec(seo.sitemap) ? seo.sitemap : {};
74
- return { pages: rules.pages !== false, exclude: Array.isArray(rules.exclude) ? rules.exclude.filter((x) => typeof x === "string") : [] };
74
+ const on = (key) => rules[key] !== false;
75
+ const toggles = { pages: on("pages"), products: on("products"), collections: on("collections"), categories: on("categories"), tags: on("tags") };
76
+ return { pages: toggles.pages, exclude: Array.isArray(rules.exclude) ? rules.exclude.filter((x) => typeof x === "string") : [], toggles };
75
77
  }
76
78
  function excluded(rules, pathname, slug) {
77
79
  return rules.some((rule) => {
@@ -103,7 +105,7 @@ async function builderSitemapParts(options, extras = {}) {
103
105
  const seen = new Set(entries.map((entry) => entry.url));
104
106
  for (const contributor of extras.contributors ?? []) {
105
107
  try {
106
- for await (const item of contributor()) {
108
+ for await (const item of contributor({ toggles: rules.toggles })) {
107
109
  const loc = typeof item.loc === "string" ? safeLoc(item.loc, origin) : null;
108
110
  if (loc === null || seen.has(loc)) continue;
109
111
  if (excluded(rules.exclude, pathnameOf(loc))) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usethrottle/builder-react",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Renders a published Throttle Builder page document as React in a merchant's store: responsive CSS, header, footer, slots and the site design provider.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,9 +57,9 @@
57
57
  "nextjs"
58
58
  ],
59
59
  "dependencies": {
60
+ "@usethrottle/builder": "^0.6.0",
60
61
  "@usethrottle/builder-schema": "^0.4.0",
61
- "@usethrottle/ui": "^0.1.3",
62
- "@usethrottle/builder": "^0.6.0"
62
+ "@usethrottle/ui": "^0.1.3"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "next": ">=15",