@majordigital/create-acorn 1.3.2 → 1.3.4
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 +30 -42
- package/package.json +1 -1
package/bin/create-acorn.mjs
CHANGED
|
@@ -281,43 +281,6 @@ async function setupStoryblok(projectName) {
|
|
|
281
281
|
cpSync(join(storyblokSrcDir, 'ui', 'FallbackComponent.tsx'), join(targetUiDir, 'FallbackComponent.tsx'));
|
|
282
282
|
console.log('Copied FallbackComponent (ui/FallbackComponent.tsx).');
|
|
283
283
|
|
|
284
|
-
// Create StoryblokProvider
|
|
285
|
-
const componentsDir = join(process.cwd(), 'src', 'components');
|
|
286
|
-
mkdirSync(componentsDir, { recursive: true });
|
|
287
|
-
writeFileSync(join(componentsDir, 'StoryblokProvider.tsx'), `'use client';
|
|
288
|
-
|
|
289
|
-
import { getStoryblokApi } from '@/lib/storyblok';
|
|
290
|
-
import type { PropsWithChildren } from 'react';
|
|
291
|
-
|
|
292
|
-
export default function StoryblokProvider({ children }: PropsWithChildren) {
|
|
293
|
-
getStoryblokApi();
|
|
294
|
-
return children;
|
|
295
|
-
}
|
|
296
|
-
`);
|
|
297
|
-
console.log('Created StoryblokProvider component.');
|
|
298
|
-
|
|
299
|
-
// Update layout.tsx to wrap with StoryblokProvider
|
|
300
|
-
const layoutPath = join(process.cwd(), 'src', 'app', 'layout.tsx');
|
|
301
|
-
try {
|
|
302
|
-
let layout = readFileSync(layoutPath, 'utf-8');
|
|
303
|
-
layout = layout.replace(
|
|
304
|
-
"import '@/styles/globals.css';",
|
|
305
|
-
"import '@/styles/globals.css';\n\nimport StoryblokProvider from '@/components/StoryblokProvider';"
|
|
306
|
-
);
|
|
307
|
-
layout = layout.replace(
|
|
308
|
-
'<html lang="en"',
|
|
309
|
-
'<StoryblokProvider>\n\t\t<html lang="en"'
|
|
310
|
-
);
|
|
311
|
-
layout = layout.replace(
|
|
312
|
-
'</html>',
|
|
313
|
-
'</html>\n\t\t</StoryblokProvider>'
|
|
314
|
-
);
|
|
315
|
-
writeFileSync(layoutPath, layout);
|
|
316
|
-
console.log('Updated layout.tsx with StoryblokProvider.');
|
|
317
|
-
} catch {
|
|
318
|
-
console.log('Warning: Could not update layout.tsx with StoryblokProvider.');
|
|
319
|
-
}
|
|
320
|
-
|
|
321
284
|
// Update package.json scripts for Storyblok
|
|
322
285
|
const pkgPath = join(process.cwd(), 'package.json');
|
|
323
286
|
try {
|
|
@@ -433,12 +396,15 @@ This website is built using the [NextJS](https://nextjs.org/) framework, utilisi
|
|
|
433
396
|
|
|
434
397
|
2. **Set up environment variables**
|
|
435
398
|
|
|
436
|
-
|
|
399
|
+
Copy \`.env.example\` to \`.env.local\` and fill in your values:
|
|
437
400
|
|
|
438
401
|
\`\`\`env
|
|
439
|
-
NEXT_PUBLIC_STORYBLOK_ACCESS_TOKEN=your_preview_token
|
|
440
402
|
STORYBLOK_SPACE_ID=your_space_id
|
|
441
|
-
|
|
403
|
+
STORYBLOK_PREVIEW_TOKEN=your_preview_token
|
|
404
|
+
STORYBLOK_PERSONAL_ACCESS_TOKEN=your_personal_access_token
|
|
405
|
+
STORYBLOK_IS_PREVIEW=true
|
|
406
|
+
NEXT_PUBLIC_STORYBLOK_PUBLIC_TOKEN=your_public_token
|
|
407
|
+
NEXT_PUBLIC_STORYBLOK_TOKEN_VERSION=draft
|
|
442
408
|
\`\`\`
|
|
443
409
|
|
|
444
410
|
3. **Start the development server**
|
|
@@ -447,15 +413,36 @@ This website is built using the [NextJS](https://nextjs.org/) framework, utilisi
|
|
|
447
413
|
npm run dev
|
|
448
414
|
\`\`\`
|
|
449
415
|
|
|
450
|
-
The site will be available at \`
|
|
416
|
+
The site will be available at \`https://localhost:3000\` (HTTPS via self-signed certificate)
|
|
417
|
+
|
|
418
|
+
4. **Generate TypeScript types**
|
|
419
|
+
|
|
420
|
+
\`\`\`bash
|
|
421
|
+
npm run generate-types
|
|
422
|
+
\`\`\`
|
|
423
|
+
|
|
424
|
+
5. **Register blok components**
|
|
451
425
|
|
|
452
|
-
|
|
426
|
+
Add your Storyblok components to \`src/lib/storyblok/bloks.ts\`
|
|
427
|
+
|
|
428
|
+
6. **Run Storybook** (optional)
|
|
453
429
|
|
|
454
430
|
\`\`\`bash
|
|
455
431
|
npm run storybook
|
|
456
432
|
\`\`\`
|
|
457
433
|
|
|
458
434
|
Storybook will be available at \`http://localhost:6006\`
|
|
435
|
+
|
|
436
|
+
## Environment Variables 🔒
|
|
437
|
+
|
|
438
|
+
The required variables are:
|
|
439
|
+
|
|
440
|
+
- **STORYBLOK_SPACE_ID**: Your Storyblok space ID
|
|
441
|
+
- **STORYBLOK_PREVIEW_TOKEN**: Preview/draft access token from your Storyblok space settings
|
|
442
|
+
- **STORYBLOK_PERSONAL_ACCESS_TOKEN**: Personal access token from your Storyblok account
|
|
443
|
+
- **STORYBLOK_IS_PREVIEW**: Set to \`true\` for draft content, \`false\` for published
|
|
444
|
+
- **NEXT_PUBLIC_STORYBLOK_PUBLIC_TOKEN**: Public token for client-side usage
|
|
445
|
+
- **NEXT_PUBLIC_STORYBLOK_TOKEN_VERSION**: \`draft\` or \`published\`
|
|
459
446
|
`;
|
|
460
447
|
|
|
461
448
|
const dato = `
|
|
@@ -562,6 +549,7 @@ SITE_URL=
|
|
|
562
549
|
storyblok: `STORYBLOK_SPACE_ID=
|
|
563
550
|
STORYBLOK_PREVIEW_TOKEN=
|
|
564
551
|
STORYBLOK_PERSONAL_ACCESS_TOKEN=
|
|
552
|
+
STORYBLOK_IS_PREVIEW=true
|
|
565
553
|
NEXT_PUBLIC_STORYBLOK_PUBLIC_TOKEN=
|
|
566
554
|
NEXT_PUBLIC_STORYBLOK_TOKEN_VERSION="draft"
|
|
567
555
|
STORYBLOK_WEBHOOK_TOKEN=
|
package/package.json
CHANGED