hd-garden 0.5.17 → 0.6.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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * vinext, like Next.js, stops a static export (`output: "export"`) when a
3
+ * dynamic route's generateStaticParams() returns an empty array. A garden site
4
+ * can legitimately have no thoughts, no columns or no admin pages to export, so
5
+ * an empty list becomes one placeholder entry instead. The prerender counts a
6
+ * notFound() page as a failed route, so the page renders nothing for the
7
+ * placeholder (isStaticPlaceholder) and the build step
8
+ * scripts/static-placeholders.mjs deletes what the export wrote for it.
9
+ */
10
+ export const STATIC_PLACEHOLDER = "__garden_static_placeholder__";
11
+
12
+ /**
13
+ * @template T
14
+ * @param {T[]} params what the route really has
15
+ * @param {T} placeholder the same shape with every value set to STATIC_PLACEHOLDER
16
+ * @returns {T[]}
17
+ */
18
+ export function staticParams(params, placeholder) {
19
+ return params.length === 0 && process.env.STATIC_EXPORT === "1" ? [placeholder] : params;
20
+ }
21
+
22
+ /** True for the placeholder value, or a catch-all path that starts with it. */
23
+ export function isStaticPlaceholder(value) {
24
+ return value === STATIC_PLACEHOLDER || (Array.isArray(value) && value[0] === STATIC_PLACEHOLDER);
25
+ }