@majordigital/create-acorn 1.3.4 → 1.3.6
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/bin/create-acorn.mjs
CHANGED
|
@@ -234,10 +234,8 @@ async function setupStoryblok(projectName) {
|
|
|
234
234
|
// Install Storyblok dependencies
|
|
235
235
|
console.log('Installing Storyblok dependencies...');
|
|
236
236
|
await runCommand('npm', ['install', '--legacy-peer-deps',
|
|
237
|
-
'@storyblok/react', '@storyblok/js', 'storyblok-js-client'
|
|
238
|
-
|
|
239
|
-
await runCommand('npm', ['install', '--save-dev', '--legacy-peer-deps',
|
|
240
|
-
'storyblok', 'storyblok-generate-ts'
|
|
237
|
+
'@storyblok/react', '@storyblok/js', 'storyblok-js-client',
|
|
238
|
+
'storyblok', 'storyblok-generate-ts', 'storyblok-rich-text-react-renderer'
|
|
241
239
|
]);
|
|
242
240
|
console.log('');
|
|
243
241
|
|
package/package.json
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
import type { ICustomSbStoriesParams } from '../types';
|
|
1
|
+
import type { PageStoryblok } from ".storyblok/types/338885/storyblok-components";
|
|
2
|
+
import { getStoryblokApi } from "@/lib/storyblok";
|
|
3
|
+
import snapshot from "@/snapshot/icons.json";
|
|
4
|
+
import type { PageIcon } from "@/types/components";
|
|
5
|
+
import type { ICustomSbStoriesParams, StoryblokServiceStory } from "../types";
|
|
8
6
|
import {
|
|
9
7
|
DEFAULT_EXCLUDING_FIELDS,
|
|
10
8
|
DEFAULT_REVALIDATE,
|
|
11
9
|
MAX_STORIES_PER_PAGE,
|
|
12
|
-
} from
|
|
13
|
-
|
|
14
|
-
import type { PageStoryblok } from '.storyblok/types/338885/storyblok-components';
|
|
10
|
+
} from "./config";
|
|
15
11
|
|
|
16
12
|
/**
|
|
17
13
|
* Maps Storyblok icon stories to PageIcon objects for UI use.
|
|
18
14
|
*/
|
|
19
15
|
export const mapIcons = (
|
|
20
|
-
icons: ReadonlyArray<
|
|
16
|
+
icons: ReadonlyArray<StoryblokServiceStory<PageStoryblok>>,
|
|
21
17
|
): PageIcon[] => {
|
|
22
18
|
if (!icons || icons.length === 0) return [];
|
|
23
19
|
|
|
@@ -35,7 +31,7 @@ export const mapIcons = (
|
|
|
35
31
|
id: String(id),
|
|
36
32
|
url: filename,
|
|
37
33
|
url_small: filenameSmall,
|
|
38
|
-
alt: alt || title ||
|
|
34
|
+
alt: alt || title || "",
|
|
39
35
|
slug,
|
|
40
36
|
};
|
|
41
37
|
})
|
|
@@ -47,14 +43,14 @@ export const mapIcons = (
|
|
|
47
43
|
*/
|
|
48
44
|
export const fetchIcons = async (): Promise<PageIcon[]> => {
|
|
49
45
|
// 1) Production build → static snapshot (fast, zero API hits)
|
|
50
|
-
if (process.env.NODE_ENV ===
|
|
46
|
+
if (process.env.NODE_ENV === "production") {
|
|
51
47
|
return snapshot as PageIcon[];
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
// 2) Filter for icons that actually have an image set
|
|
55
|
-
const filter_query: NonNullable<ICustomSbStoriesParams[
|
|
56
|
-
hide_from_search: { in:
|
|
57
|
-
|
|
51
|
+
const filter_query: NonNullable<ICustomSbStoriesParams["filter_query"]> = {
|
|
52
|
+
hide_from_search: { in: "false" },
|
|
53
|
+
"icon.filename": { is: "not_empty" },
|
|
58
54
|
};
|
|
59
55
|
|
|
60
56
|
// 3) Build base params (published, with cv)
|
|
@@ -62,8 +58,8 @@ export const fetchIcons = async (): Promise<PageIcon[]> => {
|
|
|
62
58
|
const storyblokApi = getStoryblokApi();
|
|
63
59
|
|
|
64
60
|
const baseParams = {
|
|
65
|
-
version:
|
|
66
|
-
content_type:
|
|
61
|
+
version: "published" as const,
|
|
62
|
+
content_type: "page",
|
|
67
63
|
filter_query,
|
|
68
64
|
excluding_fields: DEFAULT_EXCLUDING_FIELDS,
|
|
69
65
|
per_page,
|
|
@@ -71,7 +67,7 @@ export const fetchIcons = async (): Promise<PageIcon[]> => {
|
|
|
71
67
|
|
|
72
68
|
// 4) First page (direct API call)
|
|
73
69
|
const firstParams = { ...baseParams, page: 1 };
|
|
74
|
-
const first = await storyblokApi.get(
|
|
70
|
+
const first = await storyblokApi.get("cdn/stories", firstParams, {
|
|
75
71
|
next: {
|
|
76
72
|
revalidate: DEFAULT_REVALIDATE,
|
|
77
73
|
},
|
|
@@ -88,21 +84,20 @@ export const fetchIcons = async (): Promise<PageIcon[]> => {
|
|
|
88
84
|
: await Promise.all(
|
|
89
85
|
Array.from({ length: maxPage - 1 }, (_, idx) => {
|
|
90
86
|
const pageParams = { ...baseParams, page: 2 + idx };
|
|
91
|
-
return storyblokApi.get(
|
|
87
|
+
return storyblokApi.get("cdn/stories", pageParams, {
|
|
92
88
|
next: {
|
|
93
89
|
revalidate: DEFAULT_REVALIDATE,
|
|
94
90
|
},
|
|
95
91
|
});
|
|
96
|
-
})
|
|
92
|
+
}),
|
|
97
93
|
);
|
|
98
94
|
|
|
99
95
|
// 6) Combine and map to PageIcon[]
|
|
100
96
|
const allStoriesRaw = [
|
|
101
97
|
firstStories,
|
|
102
|
-
...rest.flatMap(r => r.data?.stories ?? []),
|
|
98
|
+
...rest.flatMap((r) => r.data?.stories ?? []),
|
|
103
99
|
];
|
|
104
|
-
const iconStories =
|
|
105
|
-
allStoriesRaw as unknown as StoryblokStory<PageStoryblok>[];
|
|
100
|
+
const iconStories = allStoriesRaw as unknown as StoryblokServiceStory<PageStoryblok>[];
|
|
106
101
|
|
|
107
102
|
return mapIcons(iconStories);
|
|
108
103
|
};
|
package/template/tsconfig.json
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
// Next.js Project Configuration
|
|
47
|
-
"jsx": "
|
|
47
|
+
"jsx": "react-jsx",
|
|
48
48
|
"incremental": true,
|
|
49
49
|
"noEmit": true,
|
|
50
50
|
"outDir": "out",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"**/*.tsx",
|
|
65
65
|
".storybook/*.ts",
|
|
66
66
|
".next/types/**/*.ts",
|
|
67
|
+
".next/dev/types/**/*.ts",
|
|
67
68
|
"**/*.mts"
|
|
68
69
|
]
|
|
69
70
|
}
|