Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrong committed Jun 28, 2024
1 parent 39145fc commit 07b8708
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/vue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
# with:
Expand Down
19 changes: 14 additions & 5 deletions tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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() {
Expand All @@ -178,6 +184,9 @@ async function main() {
case ".html":
await replaceHTML(file);
break;
case ".css":
await replaceStyle(file);
break;
default:
// replaceText(file);
break;
Expand Down
2 changes: 1 addition & 1 deletion vue/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion vue/replace-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

0 comments on commit 07b8708

Please sign in to comment.