@sugarat/theme 0.1.36-beta.0 → 0.1.36-beta.1

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.
Files changed (2) hide show
  1. package/node.js +79 -20
  2. package/package.json +4 -4
package/node.js CHANGED
@@ -115,10 +115,10 @@ var ruleBlockTabs = (state, startLine, endLine, silent) => {
115
115
  var tabBreakRE = /^\s*::(.+)$/;
116
116
  var forbiddenCharsInSlotNames = /[ '"]/;
117
117
  var parseTabBreakLine = (line) => {
118
- const m = line.match(tabBreakRE);
119
- if (!m)
118
+ const m2 = line.match(tabBreakRE);
119
+ if (!m2)
120
120
  return null;
121
- const trimmed = m[1].trim();
121
+ const trimmed = m2[1].trim();
122
122
  if (forbiddenCharsInSlotNames.test(trimmed)) {
123
123
  throw new Error(
124
124
  `contains forbidden chars in slot names (space and quotes) (${JSON.stringify(
@@ -206,27 +206,86 @@ var tabsPlugin = (md) => {
206
206
  };
207
207
  };
208
208
 
209
- // src/node.ts
210
- var import_vitepress_plugin_mermaid = require("vitepress-plugin-mermaid");
209
+ // ../../node_modules/.pnpm/vitepress-plugin-mermaid@2.0.13_mermaid@10.2.4_vitepress@1.0.0-beta.2/node_modules/vitepress-plugin-mermaid/dist/vitepress-plugin-mermaid.es.mjs
210
+ var m = (e) => {
211
+ const r = e.renderer.rules.fence.bind(e.renderer.rules);
212
+ e.renderer.rules.fence = (a, i, t, s, o) => {
213
+ const n = a[i];
214
+ if (n.info.trim() === "mermaid")
215
+ try {
216
+ return `
217
+ <Suspense>
218
+ <template #default>
219
+ <Mermaid id="mermaid-${i}" graph="${encodeURIComponent(
220
+ n.content
221
+ )}"></Mermaid>
222
+ </template>
223
+ <!-- loading state via #fallback slot -->
224
+ <template #fallback>
225
+ Loading...
226
+ </template>
227
+ </Suspense>`;
228
+ } catch (l) {
229
+ return `<pre>${l}</pre>`;
230
+ }
231
+ return n.info.trim() === "mmd" && (a[i].info = "mermaid"), r(a, i, t, s, o);
232
+ };
233
+ };
234
+ var d = {
235
+ securityLevel: "loose",
236
+ startOnLoad: false
237
+ };
238
+ function p(e) {
239
+ const r = {
240
+ ...d,
241
+ ...e
242
+ }, a = "virtual:mermaid-config", i = "\0" + a;
243
+ return {
244
+ name: "vite-plugin-mermaid",
245
+ enforce: "post",
246
+ transform(t, s) {
247
+ if (s.includes("vitepress/dist/client/app/index.js"))
248
+ return t = `
249
+ import Mermaid from 'vitepress-plugin-mermaid/Mermaid.vue';
250
+ ` + t, t = t.replace(
251
+ "// install global components",
252
+ `// install global components
253
+ app.component('Mermaid', Mermaid);
254
+ `
255
+ ), {
256
+ code: t,
257
+ map: null
258
+ };
259
+ },
260
+ async resolveId(t) {
261
+ if (t === a)
262
+ return i;
263
+ },
264
+ async load(t) {
265
+ if (t === i)
266
+ return `export default ${JSON.stringify(r)};`;
267
+ }
268
+ };
269
+ }
211
270
 
212
271
  // src/utils/index.ts
213
- function formatDate(d, fmt = "yyyy-MM-dd hh:mm:ss") {
214
- if (!(d instanceof Date)) {
215
- d = new Date(d);
272
+ function formatDate(d2, fmt = "yyyy-MM-dd hh:mm:ss") {
273
+ if (!(d2 instanceof Date)) {
274
+ d2 = new Date(d2);
216
275
  }
217
276
  const o = {
218
- "M+": d.getMonth() + 1,
219
- "d+": d.getDate(),
220
- "h+": d.getHours(),
221
- "m+": d.getMinutes(),
222
- "s+": d.getSeconds(),
223
- "q+": Math.floor((d.getMonth() + 3) / 3),
224
- S: d.getMilliseconds()
277
+ "M+": d2.getMonth() + 1,
278
+ "d+": d2.getDate(),
279
+ "h+": d2.getHours(),
280
+ "m+": d2.getMinutes(),
281
+ "s+": d2.getSeconds(),
282
+ "q+": Math.floor((d2.getMonth() + 3) / 3),
283
+ S: d2.getMilliseconds()
225
284
  };
226
285
  if (/(y+)/.test(fmt)) {
227
286
  fmt = fmt.replace(
228
287
  RegExp.$1,
229
- `${d.getFullYear()}`.substr(4 - RegExp.$1.length)
288
+ `${d2.getFullYear()}`.substr(4 - RegExp.$1.length)
230
289
  );
231
290
  }
232
291
  for (const k in o) {
@@ -355,7 +414,7 @@ function getThemeConfig(cfg) {
355
414
  cfg.mermaid = cfg?.mermaid ?? false;
356
415
  }
357
416
  if (cfg?.mermaid !== false) {
358
- markdownPlugin.push(import_vitepress_plugin_mermaid.MermaidMarkdown);
417
+ markdownPlugin.push(m);
359
418
  }
360
419
  if (markdownPlugin.length) {
361
420
  extraConfig.markdown = {
@@ -425,8 +484,8 @@ function getGitTimestamp(file) {
425
484
  return new Promise((resolve, reject) => {
426
485
  const child = (0, import_child_process.spawn)("git", ["log", "-1", '--pretty="%ci"', file]);
427
486
  let output = "";
428
- child.stdout.on("data", (d) => {
429
- output += String(d);
487
+ child.stdout.on("data", (d2) => {
488
+ output += String(d2);
430
489
  });
431
490
  child.on("close", () => {
432
491
  resolve(+new Date(output));
@@ -444,7 +503,7 @@ function assignMermaid(config) {
444
503
  config.vite = {};
445
504
  if (!config.vite.plugins)
446
505
  config.vite.plugins = [];
447
- config.vite.plugins.push((0, import_vitepress_plugin_mermaid.MermaidPlugin)(config.mermaid));
506
+ config.vite.plugins.push(p(config.mermaid));
448
507
  if (!config.vite.optimizeDeps)
449
508
  config.vite.optimizeDeps = {};
450
509
  config.vite.optimizeDeps = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.36-beta.0",
3
+ "version": "0.1.36-beta.1",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -34,17 +34,17 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@mdit-vue/shared": "^0.12.0",
37
- "@mermaid-js/mermaid-mindmap": "^9.3.0",
38
37
  "@vue/shared": "^3.2.45",
39
38
  "@vueuse/core": "^9.6.0",
40
39
  "fast-glob": "^3.2.12",
41
40
  "gray-matter": "^4.0.3",
42
41
  "highlight.js": "^11.7.0",
43
- "mermaid": "^10.2.4",
44
- "vitepress-plugin-mermaid": "^2.0.13",
45
42
  "vue-command-palette": "^0.1.4"
46
43
  },
47
44
  "devDependencies": {
45
+ "@mermaid-js/mermaid-mindmap": "^9.3.0",
46
+ "mermaid": "^10.2.4",
47
+ "vitepress-plugin-mermaid": "^2.0.13",
48
48
  "@element-plus/icons-vue": "^2.1.0",
49
49
  "element-plus": "^2.3.4",
50
50
  "sass": "^1.56.1",