Skip to content

Commit 99f1f5c

Browse files
committed
docs: copy cname after build
1 parent a9b402b commit 99f1f5c

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leaflet-geosearch.meijer.works

gatsby-node.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const path = require('path');
3+
const fs = require('fs');
4+
5+
const statics = ['CNAME'];
6+
7+
const findRepoRoot = (dir) => {
8+
const gitDir = path.join(dir || process.cwd(), '.git');
9+
10+
if (fs.existsSync(gitDir)) {
11+
return dir;
12+
}
13+
14+
const parentDir = path.dirname(dir);
15+
if (parentDir === dir) {
16+
return null;
17+
}
18+
19+
return findRepoRoot(parentDir);
20+
};
21+
22+
const root = findRepoRoot();
23+
const dist = path.join(root, '.docz/dist');
24+
25+
exports.onPostBuild = ({ reporter }) => {
26+
for (const file of statics) {
27+
const src = path.resolve(root, file);
28+
const dest = path.resolve(dist, file);
29+
30+
if (!fs.existsSync(src)) {
31+
reporter.info(`File ${file} not found`);
32+
continue;
33+
}
34+
35+
fs.copyFileSync(src, dest);
36+
reporter.info(`Copied ${src}${dest}`);
37+
}
38+
};
339

440
exports.onCreateWebpackConfig = ({ actions, stage, loaders }) => {
541
if (stage === 'build-html' || stage === 'develop-html') {

0 commit comments

Comments
 (0)