-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace_titles.cjs
More file actions
46 lines (39 loc) · 1.41 KB
/
replace_titles.cjs
File metadata and controls
46 lines (39 loc) · 1.41 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
43
44
45
46
const fs = require('fs');
const target = 'src/App.tsx';
let content = fs.readFileSync(target, 'utf-8');
const animatedTitleCode = `
const AnimatedTitle = ({ children }: any) => {
const [ref, isVisible] = useIntersectionObserver();
return (
<h2
ref={ref}
className="text-3xl font-bold text-neutral-900 dark:text-white mb-12 flex items-center gap-4 overflow-hidden"
>
<img src="/folder.png" alt="Folder" className="w-9 h-9 object-contain shrink-0 relative z-10" />
<span
className={\`transition-all duration-[600ms] ease-out origin-left inline-block \${
isVisible ? 'opacity-100 scale-x-100 translate-x-0 blur-none' : 'opacity-0 scale-x-0 -translate-x-8 blur-sm pointer-events-none'
}\`}
>
{children}
</span>
</h2>
);
};
// [ABOUT]`;
content = content.replace(`// [ABOUT]`, animatedTitleCode);
// Map of replacements
const titles = [
'ABOUT ME',
'SKILLS',
'EXPERIENCE',
'PROJECTS'
];
titles.forEach(title => {
const regex = new RegExp(
\`<h2 className="text-3xl font-bold text-neutral-900 dark:text-white mb-12 flex items-center gap-4">[\\\\s\\\\S]*?<img src="/folder.png" alt="Folder" className="w-9 h-9 object-contain" /> \${title}[\\\\s\\\\S]*?</h2>\`
);
content = content.replace(regex, \`<AnimatedTitle>\${title}</AnimatedTitle>\`);
});
fs.writeFileSync(target, content);
console.log('App.tsx titles replaced with AnimatedTitle');