diff --git a/package.json b/package.json
index 27b47bd..a72d013 100644
--- a/package.json
+++ b/package.json
@@ -4,12 +4,19 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
- "lint": "next lint"
+ "lint": "next lint",
+ "postbuild": "NODE_OPTIONS='--experimental-json-modules' node ./scripts/generate-sitemap.mjs"
},
"dependencies": {
"next": "12.1.0",
+ "prop-types": "^15.8.1",
"react": "17.0.2",
- "react-dom": "17.0.2"
+ "react-dom": "17.0.2",
+ "react-feather": "^2.0.10",
+ "react-parallax": "^3.5.1",
+ "styled-components": "^5.3.5",
+ "prettier": "^2.5.1",
+ "globby": "13.1.2"
},
"devDependencies": {
"eslint": "8.9.0",
diff --git a/public/sitemap.xml b/public/sitemap.xml
new file mode 100644
index 0000000..74f553f
--- /dev/null
+++ b/public/sitemap.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/scripts/generate-sitemap.mjs b/scripts/generate-sitemap.mjs
new file mode 100644
index 0000000..c253042
--- /dev/null
+++ b/scripts/generate-sitemap.mjs
@@ -0,0 +1,47 @@
+import { writeFileSync } from 'fs'
+
+import { globby } from 'globby'
+import prettier from 'prettier'
+
+async function generate() {
+ const prettierConfig = await prettier.resolveConfig('./.prettierrc.js')
+ const pages = await globby([
+ 'pages/*.tsx',
+ 'data/**/*.mdx',
+ '!data/*.mdx',
+ '!pages/_*.tsx',
+ '!pages/api',
+ '!pages/404.tsx',
+ ])
+
+ const sitemap = `
+
+
+ ${pages
+ .map(page => {
+ const path = page
+ .replace('pages', '')
+ .replace('data', '')
+ .replace('.tsx', '')
+ .replace('.mdx', '')
+ const route = path === '/index' ? '' : path
+ return `
+
+ ${`https://cretu.dev${route}`}
+
+ `
+ })
+ .join('')}
+
+ `
+
+ const formatted = prettier.format(sitemap, {
+ ...prettierConfig,
+ parser: 'html',
+ })
+
+ // eslint-disable-next-line no-sync
+ writeFileSync('public/sitemap.xml', formatted)
+}
+
+generate()