Skip to content

Commit e986cda

Browse files
committed
Add automatic CNAME script
1 parent 54a2ba6 commit e986cda

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
"script:gen-articles-index": "node ./scripts/generateArticlesIndex.js",
1212
"script:gen-sitemap": "node ./scripts/generateSitemap.js",
1313
"script:gen-robots": "node ./scripts/generateRobots.js",
14+
"script:gen-cname": "node ./scripts/generateCName.js",
1415

1516
"build": "next build && next export",
16-
"postbuild": "npm run script:gen-sitemap && npm run script:gen-robots"
17+
"postbuild": "npm run script:gen-sitemap && npm run script:gen-robots && npm run script:gen-cname"
1718
},
1819
"dependencies": {
1920
"@headlessui/react": "^1.7.13",

public/CNAME

-1
This file was deleted.

public/robots.txt

-4
This file was deleted.

scripts/generateCName.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const path = require("path");
2+
const fs = require("fs/promises");
3+
4+
const dotenv = require("dotenv");
5+
dotenv.config({ path: path.resolve(__dirname, "../.env") });
6+
dotenv.config({ path: path.resolve(__dirname, "../.env.local"), override: true });
7+
8+
const run = async () => {
9+
const outDir = path.resolve(__dirname, "../out");
10+
const url = new URL(process.env.NEXT_PUBLIC_FRONTEND_URL)
11+
fs.writeFile(path.join(outDir, "CNAME"), url.host);
12+
};
13+
14+
run();

0 commit comments

Comments
 (0)