Last active
March 25, 2022 03:21
-
-
Save ygkn/954f34992aa13211f2b6277805ef2521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S deno run | |
const dirs = | |
`members/[memberId]/reflections/[reflectionId]/categories/[categoryId]`.split( | |
'/' | |
); | |
const toUpperCamelCase = (str: string) => | |
`${str[0].toUpperCase()}${str.slice(1)}`; | |
for (const i of dirs.keys()) { | |
const pageComponentName = `${toUpperCamelCase( | |
dirs[i][0] === '[' ? dirs[i].slice(1, -3) : `${dirs[i]}List` | |
)}Page`; | |
const title = `${toUpperCamelCase( | |
dirs[i][0] === '[' ? dirs[i].slice(1, -3) : `${dirs[i]} 一覧` | |
)}`; | |
const path = dirs | |
.slice(0, i + 1) | |
.concat('index.page.tsx') | |
.join('/'); | |
const content = `import type { NextPage } from 'next'; | |
import { ContentLayout } from '@/components/Layout/ContentLayout'; | |
const ${pageComponentName}: NextPage = () => { | |
return ( | |
<ContentLayout title="${title}"> | |
<div></div> | |
</ContentLayout> | |
); | |
}; | |
export default ${pageComponentName}; | |
`; | |
Deno.writeTextFileSync(path, content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment