-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_components.js
More file actions
42 lines (34 loc) · 2.21 KB
/
Copy pathsplit_components.js
File metadata and controls
42 lines (34 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require('fs');
const pagePath = 'frontend/app/dashboard/components/page.tsx';
let page = fs.readFileSync(pagePath, 'utf8');
// Replace synchronous imports with dynamic imports
const syncImports = [
'import { AnimatedPremiumButton } from "@/components/landing/animated-premium-button"',
'import DigitalHoverButton from "@/components/buttons/digital-hover-button"',
'import AestheticGlossButton from "@/components/buttons/aesthetic-gloss-button"',
'import NeoSlideButton from "@/components/buttons/neo-slide-button"',
'import HapticPressButton from "@/components/buttons/haptic-press-button"',
'import CyberRockerToggle from "@/components/buttons/cyber-rocker-toggle"',
'import LiquidMetalButton from "@/components/buttons/liquid-metal-button"',
'import AsciiGlitchRipple from "@/components/motion/ascii-glitch-ripple"'
];
const dynamicImports = `import dynamic from 'next/dynamic';
const AnimatedPremiumButton = dynamic(() => import('@/components/landing/animated-premium-button').then(mod => mod.AnimatedPremiumButton), { ssr: false });
const DigitalHoverButton = dynamic(() => import('@/components/buttons/digital-hover-button'));
const AestheticGlossButton = dynamic(() => import('@/components/buttons/aesthetic-gloss-button'));
const NeoSlideButton = dynamic(() => import('@/components/buttons/neo-slide-button'));
const HapticPressButton = dynamic(() => import('@/components/buttons/haptic-press-button'));
const CyberRockerToggle = dynamic(() => import('@/components/buttons/cyber-rocker-toggle'));
const LiquidMetalButton = dynamic(() => import('@/components/buttons/liquid-metal-button'), { ssr: false });
const AsciiGlitchRipple = dynamic(() => import('@/components/motion/ascii-glitch-ripple'), { ssr: false });
`;
// Remove old imports
syncImports.forEach(imp => {
page = page.replace(imp, '');
});
// Add dynamic imports after imports block
page = page.replace(/import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"\nimport { oneDark } from "react-syntax-highlighter\/dist\/esm\/styles\/prism"/,
`import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"
import { oneDark } from "react-syntax-highlighter/dist/esm/styles/prism"
${dynamicImports}`);
fs.writeFileSync(pagePath, page);