From cd5e69317e3f673cbde01d05174f33f623f1248a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E7=AB=B9?= Date: Fri, 3 Mar 2023 00:46:40 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=94=9F=E6=88=90=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gh-pages.yml | 1 + package.json | 4 ++++ sitemap.js | 15 +++++++++++++++ yarn.lock | 19 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 sitemap.js diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 504bee14..d3d6475a 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -12,6 +12,7 @@ jobs: - run: yarn install - run: yarn build - run: mv googled29fba422c357ff8.html docs/ + - run: node sitemap.js - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: diff --git a/package.json b/package.json index 961cc8eb..d9b97d2e 100644 --- a/package.json +++ b/package.json @@ -15,5 +15,9 @@ "serve": "^12.0.0", "typedoc": "^0.21.5", "typescript": "^4.3.5" + }, + "dependencies": { + "exec-sh": "^0.4.0", + "recursive-readdir": "^2.2.3" } } diff --git a/sitemap.js b/sitemap.js new file mode 100644 index 00000000..fa48b9fd --- /dev/null +++ b/sitemap.js @@ -0,0 +1,15 @@ +const fs = require("fs"); +const recursive = require("recursive-readdir"); +const execSh = require("exec-sh"); + +(async () =>{ + if (!fs.existsSync("./docs")) { + return; + } + const files = await recursive("./docs"); + const urls = files.filter(file => file.endsWith('.html')).map(file => { + return file.replace('docs/', 'https://vscode-api-cn.js.org/') + }) + fs.writeFileSync("./docs/urls.txt", urls.join("\n")); + execSh("npx sitemap < ./docs/urls.txt > ./docs/sitemap.xml"); +})() diff --git a/yarn.lock b/yarn.lock index 07183f01..20ae8eab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -267,6 +267,11 @@ escape-string-regexp@^1.0.5: resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= +exec-sh@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.4.0.tgz#0f4ae8c36d166bae80e5c69aba0793d80c3488d5" + integrity sha512-BgAFra+J+hK/wquyWchMiqgaxSv1ec2c+//DRSePlF3NLx/tBOmkIkJEc1hWrX4Yis3tzxgv1+FiFs/mmucs/g== + execa@^0.7.0: version "0.7.0" resolved "https://registry.nlark.com/execa/download/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" @@ -517,6 +522,13 @@ minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.4: dependencies: brace-expansion "^1.1.7" +minimatch@^3.0.5: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -671,6 +683,13 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" +recursive-readdir@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/recursive-readdir/-/recursive-readdir-2.2.3.tgz#e726f328c0d69153bcabd5c322d3195252379372" + integrity sha512-8HrF5ZsXk5FAH9dgsx3BlUer73nIhuj+9OrQwEbLTPOBzGkL1lsFCR01am+v+0m2Cmbs1nP12hLDl5FA7EszKA== + dependencies: + minimatch "^3.0.5" + registry-auth-token@3.3.2: version "3.3.2" resolved "https://registry.npm.taobao.org/registry-auth-token/download/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20"