From 07b87080d22c6be42a0dfe30fe8feb14dc91066a Mon Sep 17 00:00:00 2001 From: ikrong Date: Fri, 28 Jun 2024 16:30:04 +0800 Subject: [PATCH] fix --- .github/workflows/vue.yml | 2 ++ tools/index.js | 19 ++++++++++++++----- vue/Dockerfile | 2 +- vue/replace-3.js | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/vue.yml b/.github/workflows/vue.yml index 1f9441f..19a33df 100644 --- a/.github/workflows/vue.yml +++ b/.github/workflows/vue.yml @@ -116,6 +116,8 @@ jobs: push: true tags: | registry.cn-beijing.aliyuncs.com/ikrong/docworld:vue3 + build-args: | + DOCWORLD_SOURCE=${{ env.DOCWORLD_SOURCE }} # - name: Build Vue zh doc # uses: docker/build-push-action@v4.0.0 # with: diff --git a/tools/index.js b/tools/index.js index 13e1393..f98f2c6 100644 --- a/tools/index.js +++ b/tools/index.js @@ -126,9 +126,15 @@ async function replaceHTML(file) { } const src = formatUrl(el.attribs.src); if (src) { - if (['www.googletagmanager.com', 'cdn.usefathom.com'].some(u => src.includes(u))) { + // script标签来自这些主机地址,则删除,因为这个是广告性质的,与文档内容无关 + if ([ + 'www.googletagmanager.com', + 'cdn.usefathom.com', + 'vueschool.io/banner.js' + ].some(u => src.includes(u)) + ) { $(el).remove(); - return; + continue; } el.attribs.src = await cacheUrl(src); } @@ -163,9 +169,9 @@ async function replaceHTML(file) { fs.writeFileSync(file, $.html()); } -function replaceText(file) { - // const content = fs.readFileSync(file).toString(); - // fs.writeFileSync(file, replaceHost(content)); +async function replaceStyle(file) { + const content = fs.readFileSync(file).toString(); + fs.writeFileSync(file, await replaceCssContent('', content)); } async function main() { @@ -178,6 +184,9 @@ async function main() { case ".html": await replaceHTML(file); break; + case ".css": + await replaceStyle(file); + break; default: // replaceText(file); break; diff --git a/vue/Dockerfile b/vue/Dockerfile index 4ef7c5f..5134235 100644 --- a/vue/Dockerfile +++ b/vue/Dockerfile @@ -27,7 +27,7 @@ RUN cd /app/source/ && \ RUN NODE_PATH=$(npm root --quiet -g) node /app/tools/index.js /app/source/.vitepress/dist -RUN NODE_PATH=$(npm root --quiet -g) node /app/after-3.js /app/source/.vuepress/dist +RUN NODE_PATH=$(npm root --quiet -g) node /app/after-3.js /app/source/.vitepress/dist FROM ikrong/mini-http:latest diff --git a/vue/replace-3.js b/vue/replace-3.js index 65ac890..c81f782 100644 --- a/vue/replace-3.js +++ b/vue/replace-3.js @@ -18,7 +18,7 @@ for (let file of files) { const sponsors = path.join(HOST_DIR, ".vitepress/theme/components/sponsors.ts"); fs.writeFileSync(sponsors, fs.readFileSync(sponsors).toString().split('\n').map(line => { if (line.startsWith('export const base ')) { - return `export const base = '/sponsors.vuejs.org/data.json'`; + return `export const base = '/sponsors.vuejs.org'`; } return line; }).join('\n')) \ No newline at end of file