Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
frostime committed Jun 23, 2023
2 parents 727f835 + 4e79d61 commit 4c0b9e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"make-link": "node ./scripts/make_dev_link.js",
"replace-plugin": "node ./scripts/replace_plugin.js",
"dev": "vite build --watch",
"build": "vite build && node ./scripts/replace-dist-imgbed.js",
"build": "vite build",
"sync-to-pr": "git checkout main && git pull origin main && git branch -f dev main && git checkout dev"
},
"devDependencies": {
Expand Down
37 changes: 0 additions & 37 deletions scripts/replace-dist-imgbed.js

This file was deleted.

22 changes: 22 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ const distDir = isWatch ? devDistDir : "./dist"
console.log("isWatch=>", isWatch)
console.log("distDir=>", distDir)

const imgbedPrefix = 'https://gitlab.com/ypz.open/siyuan/siyuan-dailynote-today/-/raw/main';
/**
* 更换图片链接
*/
function transformMdFile(content: string, filename: string, prefix: string=imgbedPrefix): string {
//如果不是md文件,或者是watch模式,不做处理
if (isWatch || !filename.endsWith(".md")) {
return content;
}

console.log("transform=>", filename);
let imgPat = /!\[.*?\]\(\.?\/?(.*?)\)/g
let imgurl = `${prefix}/$1`
let newReadme = content.replace(imgPat, `![](${imgurl})`);
// await fs.promises.writeFile(readmePath, newReadme)
return newReadme;
}


export default defineConfig({
resolve: {
alias: {
Expand All @@ -30,6 +49,8 @@ export default defineConfig({
{
src: "./README*.md",
dest: "./",
// 更换图片链接
transform: transformMdFile
},
{
src: "./icon.png",
Expand All @@ -46,6 +67,7 @@ export default defineConfig({
{
src: "./src/i18n/**",
dest: "./i18n/",
transform: transformMdFile
},
],
}),
Expand Down

0 comments on commit 4c0b9e4

Please sign in to comment.