Skip to content

Commit 607b313

Browse files
authored
feat: cp markdown to public (#606)
1 parent 81af906 commit 607b313

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

gatsby/cp-markdown.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import path from "path";
2+
import fs from "fs-extra";
3+
4+
export const cpMarkdown = (
5+
filepath: string,
6+
destpath: string,
7+
filename: string
8+
) => {
9+
if (!filename) {
10+
return;
11+
}
12+
const sourceDir = path.resolve(
13+
__dirname,
14+
`../docs/markdown-pages/${filepath}`
15+
);
16+
const destDir = path.resolve(
17+
__dirname,
18+
`../public/${destpath}/${filename}.md`
19+
);
20+
fs.copy(sourceDir, destDir).catch((e) => console.warn(e.toString()));
21+
};

gatsby/create-pages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
generateDocHomeUrl,
1212
} from "./path";
1313
import { docs as DOCS_CONFIG } from "../docs/docs.json";
14+
import { cpMarkdown } from "./cp-markdown";
1415

1516
interface PageQueryData {
1617
allMdx: {
@@ -106,6 +107,7 @@ export const createDocs = async ({
106107
)
107108
.filter(Boolean);
108109

110+
cpMarkdown(`${node.slug}.md`, path, name);
109111
createPage({
110112
path,
111113
component: template,

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@
7575
"@prantlf/railroad-diagrams": "^1.0.1",
7676
"@ti-fe/cli": "^0.12.0",
7777
"@ti-fe/prettier-config": "^1.0.3",
78+
"@types/fs-extra": "^11.0.4",
7879
"@types/mdx-js__react": "^1.5.5",
7980
"@types/node": "^17.0.21",
8081
"@types/react-dom": "^18.0.5",
8182
"@types/signale": "^1.4.3",
8283
"anafanafo": "^1.0.0",
8384
"bulma": "^0.9.3",
85+
"fs-extra": "^11.3.0",
8486
"gatsby-plugin-dts-css-modules": "^3.0.0",
8587
"gatsby-plugin-root-import": "^2.0.8",
8688
"husky": "^7.0.4",

yarn.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,6 +3757,14 @@
37573757
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50"
37583758
integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==
37593759

3760+
"@types/fs-extra@^11.0.4":
3761+
version "11.0.4"
3762+
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.4.tgz#e16a863bb8843fba8c5004362b5a73e17becca45"
3763+
integrity sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==
3764+
dependencies:
3765+
"@types/jsonfile" "*"
3766+
"@types/node" "*"
3767+
37603768
"@types/get-port@^3.2.0":
37613769
version "3.2.0"
37623770
resolved "https://registry.yarnpkg.com/@types/get-port/-/get-port-3.2.0.tgz#f9e0a11443cc21336470185eae3dfba4495d29bc"
@@ -3830,6 +3838,13 @@
38303838
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
38313839
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
38323840

3841+
"@types/jsonfile@*":
3842+
version "6.1.4"
3843+
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.4.tgz#614afec1a1164e7d670b4a7ad64df3e7beb7b702"
3844+
integrity sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==
3845+
dependencies:
3846+
"@types/node" "*"
3847+
38333848
"@types/katex@^0.11.0":
38343849
version "0.11.1"
38353850
resolved "https://registry.npmmirror.com/@types/katex/-/katex-0.11.1.tgz#34de04477dcf79e2ef6c8d23b41a3d81f9ebeaf5"
@@ -7920,6 +7935,15 @@ fs-extra@^10.0.1, fs-extra@^10.1.0:
79207935
jsonfile "^6.0.1"
79217936
universalify "^2.0.0"
79227937

7938+
fs-extra@^11.3.0:
7939+
version "11.3.0"
7940+
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.3.0.tgz#0daced136bbaf65a555a326719af931adc7a314d"
7941+
integrity sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==
7942+
dependencies:
7943+
graceful-fs "^4.2.0"
7944+
jsonfile "^6.0.1"
7945+
universalify "^2.0.0"
7946+
79237947
fs-extra@^7.0.0:
79247948
version "7.0.1"
79257949
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"

0 commit comments

Comments
 (0)