cosmolo 0.3.6 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin.js +21 -16
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -24,6 +24,11 @@ export function cosmoloPlugin(userConfig = {}) {
|
|
|
24
24
|
const siteConfigAbsPath = path.resolve(process.cwd(), config.siteConfigPath);
|
|
25
25
|
return {
|
|
26
26
|
name: 'cosmolo',
|
|
27
|
+
config() {
|
|
28
|
+
return {
|
|
29
|
+
ssr: { noExternal: ['cosmolo'] },
|
|
30
|
+
};
|
|
31
|
+
},
|
|
27
32
|
resolveId(id) {
|
|
28
33
|
if (id === VIRTUAL_ID)
|
|
29
34
|
return RESOLVED_ID;
|
|
@@ -35,24 +40,24 @@ export function cosmoloPlugin(userConfig = {}) {
|
|
|
35
40
|
this.addWatchFile(siteConfigAbsPath);
|
|
36
41
|
const categoriesData = JSON.parse(fs.readFileSync(categoriesAbsPath, 'utf-8'));
|
|
37
42
|
const siteConfigData = JSON.parse(fs.readFileSync(siteConfigAbsPath, 'utf-8'));
|
|
43
|
+
const articlesDirAbs = path.resolve(process.cwd(), config.articlesDir.replace(/^\//, ''));
|
|
44
|
+
const pagesDirAbs = path.resolve(process.cwd(), config.pagesDir.replace(/^\//, ''));
|
|
45
|
+
const articlesExist = fs.existsSync(articlesDirAbs);
|
|
46
|
+
const pagesExist = fs.existsSync(pagesDirAbs);
|
|
47
|
+
const rawMdFilesExpr = articlesExist
|
|
48
|
+
? `import.meta.glob('${articlesDir}/*.md', { query: '?raw', import: 'default', eager: true })`
|
|
49
|
+
: '{}';
|
|
50
|
+
const svxModulesExpr = articlesExist
|
|
51
|
+
? `import.meta.glob('${articlesDir}/*.svx', { eager: true })`
|
|
52
|
+
: '{}';
|
|
53
|
+
const rawPageFilesExpr = pagesExist
|
|
54
|
+
? `import.meta.glob('${pagesDir}/*.md', { query: '?raw', import: 'default', eager: true })`
|
|
55
|
+
: '{}';
|
|
38
56
|
return `
|
|
39
|
-
export const rawMdFiles =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
export const svxModules = import.meta.glob(
|
|
45
|
-
'${articlesDir}/*.svx',
|
|
46
|
-
{ eager: true }
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export const rawPageFiles = import.meta.glob(
|
|
50
|
-
'${pagesDir}/*.md',
|
|
51
|
-
{ query: '?raw', import: 'default', eager: true }
|
|
52
|
-
);
|
|
53
|
-
|
|
57
|
+
export const rawMdFiles = ${rawMdFilesExpr};
|
|
58
|
+
export const svxModules = ${svxModulesExpr};
|
|
59
|
+
export const rawPageFiles = ${rawPageFilesExpr};
|
|
54
60
|
export const categoriesData = ${JSON.stringify(categoriesData)};
|
|
55
|
-
|
|
56
61
|
export const siteConfigData = ${JSON.stringify(siteConfigData)};
|
|
57
62
|
`.trim();
|
|
58
63
|
},
|