diff --git a/gulpfile.ts b/gulpfile.ts index 0cdd016fd7f71af05cc602a5db57839d7c659a5c..771a5c0e322d98da6554e2c15033ff0eb411aadd 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -77,17 +77,9 @@ gulp.task('cleanall', gulp.parallel('clean', cb => rimraf('./node_modules', cb) )); -gulp.task('copy:docs', () => - gulp.src([ - './src/docs/**/*', - ]) - .pipe(gulp.dest('./built/assets/docs/')) -); - gulp.task('build', gulp.parallel( 'build:ts', 'build:copy', - 'copy:docs', )); gulp.task('default', gulp.task('build')); diff --git a/src/client/pages/doc.vue b/src/client/pages/doc.vue index 3379a5fe680e9cfbc7defba0204d4eb0c4e35c9b..ed4eae4d02e3e0ab3f7f38a63faeec6207e95e47 100644 --- a/src/client/pages/doc.vue +++ b/src/client/pages/doc.vue @@ -60,7 +60,7 @@ export default defineComponent({ methods: { fetchDoc() { - fetch(`${url}/assets/docs/${lang}/${this.doc}.md`).then(res => res.text()).then(md => { + fetch(`${url}/doc-assets/${lang}/${this.doc}.md`).then(res => res.text()).then(md => { this.parse(md); }); }, diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 7b0b82eedff4f3fe12bc4d6761abfb1e3fefaece..c1f879f913748752c0f09fdfaea9db1a7271d52e 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -29,6 +29,7 @@ const markdown = MarkdownIt({ }); const staticAssets = `${__dirname}/../../../assets/`; +const docAssets = `${__dirname}/../../../src/docs/`; const assets = `${__dirname}/../../assets/`; // Init app @@ -65,6 +66,13 @@ router.get('/static-assets/(.*)', async ctx => { }); }); +router.get('/doc-assets/(.*)', async ctx => { + await send(ctx as any, ctx.path.replace('/doc-assets/', ''), { + root: docAssets, + maxage: ms('7 days'), + }); +}); + router.get('/assets/(.*)', async ctx => { await send(ctx as any, ctx.path.replace('/assets/', ''), { root: assets,