@@ -2,6 +2,7 @@ import yaml from '@rollup/plugin-yaml'
22import type { NuxtConfig } from '@nuxt/schema'
33import pkg from './package.json'
44import { getCnRoutes , getCnApiReferenceRoutes } from './scripts/extract-routes.mjs'
5+ import remarkReplaceDomains from './scripts/remark-replace-domains.mjs'
56
67const cnRoutes = getCnRoutes ( )
78const cnApiRoutes = getCnApiReferenceRoutes ( )
@@ -15,12 +16,15 @@ const envConfig = await import(`./envConfig/config.${env}.ts`).then(m => m.defau
1516 }
1617} )
1718
19+ const staticCdnUrl = envConfig . staticCdnUrl || 'https://statics.memtensor.com.cn'
20+ const cdnUrl = envConfig . cdnUrl || 'https://cdn.memtensor.com.cn'
21+
1822const config : NuxtConfig = {
1923 app : {
2024 head : {
2125 script : [
22- { src : 'https://cdn.memtensor.com.cn/ file/js-cookie-3.0.5.min.js' , type : 'text/javascript' } ,
23- { src : 'https://cdn.memtensor.com.cn/ file/locale.1.1.2.min.js' , type : 'text/javascript' }
26+ { src : ` ${ cdnUrl } / file/js-cookie-3.0.5.min.js` , type : 'text/javascript' } ,
27+ { src : ` ${ cdnUrl } / file/locale.1.1.2.min.js` , type : 'text/javascript' }
2428 ]
2529 }
2630 } ,
@@ -37,7 +41,9 @@ const config: NuxtConfig = {
3741 public : {
3842 ...envConfig ,
3943 version : pkg . version ,
40- apiBase : 'https://apigw.memtensor.cn'
44+ apiBase : 'https://apigw.memtensor.cn' ,
45+ staticCdnUrl,
46+ cdnUrl
4147 }
4248 } ,
4349
@@ -72,6 +78,11 @@ const config: NuxtConfig = {
7278 ] ,
7379 optimizeDeps : {
7480 include : [ 'debug' ]
81+ } ,
82+ build : {
83+ rollupOptions : {
84+ external : [ 'remark-replace-domains' ]
85+ }
7586 }
7687 } ,
7788
@@ -87,6 +98,22 @@ const config: NuxtConfig = {
8798 content : {
8899 build : {
89100 markdown : {
101+ remarkPlugins : {
102+ 'remark-replace-domains' : {
103+ instance : remarkReplaceDomains ,
104+ options : {
105+ imageDomains : {
106+ 'https://cdn.memtensor.com.cn' : cdnUrl ,
107+ 'https://statics.memtensor.com.cn' : staticCdnUrl
108+ } ,
109+ linkDomains : {
110+ 'https://memos-playground.openmem.net' : envConfig . playgroundUrl ,
111+ 'https://memos-dashboard.openmem.net' : envConfig . dashboardUrl ,
112+ 'https://memos.openmem.net' : envConfig . homeDomain
113+ }
114+ }
115+ }
116+ } ,
90117 highlight : {
91118 langs : [ 'bash' , 'shell' , 'ts' , 'typescript' , 'diff' , 'vue' , 'json' , 'yml' , 'css' , 'mdc' , 'python' , 'py' , 'mermaid' , 'markdown' , 'md' ]
92119 }
0 commit comments