@md-plugins/vite-md-plugin 0.1.0-alpha.1 → 0.1.0-alpha.5
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/LICENSE.md +1 -1
- package/README.md +17 -17
- package/dist/index.d.mts +4 -18
- package/dist/index.d.ts +4 -18
- package/dist/index.mjs +34 -26
- package/package.json +20 -14
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2024-present,
|
|
3
|
+
Copyright (c) 2024-present, MD-PLUGINS
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -47,16 +47,16 @@ pnpm add @md-plugins/vite-md-plugin
|
|
|
47
47
|
To use the `viteMdPlugin`, configure it in your Vite project:
|
|
48
48
|
|
|
49
49
|
```js
|
|
50
|
-
import { defineConfig } from 'vite'
|
|
51
|
-
import vue from '@vitejs/plugin-vue'
|
|
52
|
-
import { viteMdPlugin } from 'vite-md-plugin'
|
|
50
|
+
import { defineConfig } from 'vite'
|
|
51
|
+
import vue from '@vitejs/plugin-vue'
|
|
52
|
+
import { viteMdPlugin } from 'vite-md-plugin'
|
|
53
53
|
|
|
54
|
-
const menu = []
|
|
55
|
-
const basePath = '/docs'
|
|
54
|
+
const menu = [] // Define your navigation menu structure here
|
|
55
|
+
const basePath = '/docs' // Base path prefix
|
|
56
56
|
|
|
57
57
|
export default defineConfig({
|
|
58
58
|
plugins: [vue(), viteMdPlugin(basePath, menu)],
|
|
59
|
-
})
|
|
59
|
+
})
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## Quasar Framework Configuration
|
|
@@ -102,7 +102,7 @@ The `viteMdPlugin` allows you to define a navigation structure that can be updat
|
|
|
102
102
|
const menu = [
|
|
103
103
|
{ title: 'Home', path: '/home' },
|
|
104
104
|
{ title: 'About', path: '/about' },
|
|
105
|
-
]
|
|
105
|
+
]
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
This menu is passed as a parameter to the plugin and can be used to build a dynamic sidebar or navigation bar in your application.
|
|
@@ -122,16 +122,16 @@ The `menu` parameter should conform to the following structure:
|
|
|
122
122
|
|
|
123
123
|
```ts
|
|
124
124
|
export interface MenuItem {
|
|
125
|
-
name: string
|
|
126
|
-
path?: string
|
|
127
|
-
icon?: string
|
|
128
|
-
iconColor?: string
|
|
129
|
-
rightIcon?: string
|
|
130
|
-
rightIconColor?: string
|
|
131
|
-
badge?: string
|
|
132
|
-
children?: MenuItem[]
|
|
133
|
-
external?: boolean
|
|
134
|
-
expanded?: boolean
|
|
125
|
+
name: string
|
|
126
|
+
path?: string
|
|
127
|
+
icon?: string
|
|
128
|
+
iconColor?: string
|
|
129
|
+
rightIcon?: string
|
|
130
|
+
rightIconColor?: string
|
|
131
|
+
badge?: string
|
|
132
|
+
children?: MenuItem[]
|
|
133
|
+
external?: boolean
|
|
134
|
+
expanded?: boolean
|
|
135
135
|
}
|
|
136
136
|
```
|
|
137
137
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Plugin } from '/home/jeff/git/github/jeff/md-plugins/node_modules/.pnpm/vite@6.0.7_@types+node@22.10.5_jiti@2.4.2_sass-embedded@1.83.0_terser@5.37.0/node_modules/vite/dist/node/index.d.ts';
|
|
2
|
+
|
|
1
3
|
interface MenuItem {
|
|
2
4
|
name: string;
|
|
3
5
|
path?: string;
|
|
@@ -6,7 +8,7 @@ interface MenuItem {
|
|
|
6
8
|
rightIcon?: string;
|
|
7
9
|
rightIconColor?: string;
|
|
8
10
|
badge?: string;
|
|
9
|
-
children?: MenuItem[];
|
|
11
|
+
children?: MenuItem[] | undefined;
|
|
10
12
|
external?: boolean;
|
|
11
13
|
expanded?: boolean;
|
|
12
14
|
}
|
|
@@ -33,18 +35,6 @@ interface RelatedItem {
|
|
|
33
35
|
path: string;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
/**
|
|
37
|
-
* Transforms markdown content into Vue Single File Component (SFC) format.
|
|
38
|
-
*
|
|
39
|
-
* @param code - The markdown content to be transformed.
|
|
40
|
-
* @param id - The identifier (typically the file path) of the markdown file.
|
|
41
|
-
* @returns The transformed Vue SFC content, or null if the file is not a markdown file.
|
|
42
|
-
* @throws Will throw an error if the markdown transformation process fails.
|
|
43
|
-
*/
|
|
44
|
-
declare function transform(code: string, id: string): {
|
|
45
|
-
code: string;
|
|
46
|
-
map: null;
|
|
47
|
-
} | null;
|
|
48
38
|
/**
|
|
49
39
|
* Creates a Vite plugin for processing Markdown files.
|
|
50
40
|
* This plugin transforms Markdown content into Vue Single File Components (SFCs).
|
|
@@ -53,10 +43,6 @@ declare function transform(code: string, id: string): {
|
|
|
53
43
|
* @param menu - An array of MenuItem objects representing the navigation menu structure.
|
|
54
44
|
* @returns A Vite plugin object with pre-configured settings for Markdown processing.
|
|
55
45
|
*/
|
|
56
|
-
declare function viteMdPlugin(path: string, menu: MenuItem[]):
|
|
57
|
-
name: string;
|
|
58
|
-
enforce: string;
|
|
59
|
-
transform: typeof transform;
|
|
60
|
-
};
|
|
46
|
+
declare function viteMdPlugin(path: string, menu: MenuItem[]): Plugin;
|
|
61
47
|
|
|
62
48
|
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, viteMdPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Plugin } from '/home/jeff/git/github/jeff/md-plugins/node_modules/.pnpm/vite@6.0.7_@types+node@22.10.5_jiti@2.4.2_sass-embedded@1.83.0_terser@5.37.0/node_modules/vite/dist/node/index.d.ts';
|
|
2
|
+
|
|
1
3
|
interface MenuItem {
|
|
2
4
|
name: string;
|
|
3
5
|
path?: string;
|
|
@@ -6,7 +8,7 @@ interface MenuItem {
|
|
|
6
8
|
rightIcon?: string;
|
|
7
9
|
rightIconColor?: string;
|
|
8
10
|
badge?: string;
|
|
9
|
-
children?: MenuItem[];
|
|
11
|
+
children?: MenuItem[] | undefined;
|
|
10
12
|
external?: boolean;
|
|
11
13
|
expanded?: boolean;
|
|
12
14
|
}
|
|
@@ -33,18 +35,6 @@ interface RelatedItem {
|
|
|
33
35
|
path: string;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
/**
|
|
37
|
-
* Transforms markdown content into Vue Single File Component (SFC) format.
|
|
38
|
-
*
|
|
39
|
-
* @param code - The markdown content to be transformed.
|
|
40
|
-
* @param id - The identifier (typically the file path) of the markdown file.
|
|
41
|
-
* @returns The transformed Vue SFC content, or null if the file is not a markdown file.
|
|
42
|
-
* @throws Will throw an error if the markdown transformation process fails.
|
|
43
|
-
*/
|
|
44
|
-
declare function transform(code: string, id: string): {
|
|
45
|
-
code: string;
|
|
46
|
-
map: null;
|
|
47
|
-
} | null;
|
|
48
38
|
/**
|
|
49
39
|
* Creates a Vite plugin for processing Markdown files.
|
|
50
40
|
* This plugin transforms Markdown content into Vue Single File Components (SFCs).
|
|
@@ -53,10 +43,6 @@ declare function transform(code: string, id: string): {
|
|
|
53
43
|
* @param menu - An array of MenuItem objects representing the navigation menu structure.
|
|
54
44
|
* @returns A Vite plugin object with pre-configured settings for Markdown processing.
|
|
55
45
|
*/
|
|
56
|
-
declare function viteMdPlugin(path: string, menu: MenuItem[]):
|
|
57
|
-
name: string;
|
|
58
|
-
enforce: string;
|
|
59
|
-
transform: typeof transform;
|
|
60
|
-
};
|
|
46
|
+
declare function viteMdPlugin(path: string, menu: MenuItem[]): Plugin;
|
|
61
47
|
|
|
62
48
|
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, viteMdPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -55,7 +55,7 @@ function createMarkdownRenderer(options = {}) {
|
|
|
55
55
|
md2.use(containersPlugin, containers, createContainer);
|
|
56
56
|
md2.use(blockquotePlugin, { blockquoteClass: "markdown-note" });
|
|
57
57
|
md2.use(tablePlugin, {
|
|
58
|
-
tableClass: "markdown-
|
|
58
|
+
tableClass: "markdown-table",
|
|
59
59
|
tableHeaderClass: "text-left",
|
|
60
60
|
tableToken: "q-markup-table",
|
|
61
61
|
tableAttributes: [
|
|
@@ -209,18 +209,14 @@ function getVueComponent(rendered, code, id, prefix, menu) {
|
|
|
209
209
|
}
|
|
210
210
|
const frontmatter = rendered?.frontmatter || {};
|
|
211
211
|
if (frontmatter.editLink !== false) {
|
|
212
|
-
frontmatter.editLink = id.substring(
|
|
213
|
-
id.indexOf("src/pages/") + 10,
|
|
214
|
-
id.length - 3
|
|
215
|
-
);
|
|
212
|
+
frontmatter.editLink = id.substring(id.indexOf("src/pages/") + 10, id.length - 3);
|
|
216
213
|
}
|
|
217
214
|
const title = frontmatter.title || rendered.env.title || rendered.title || "Generic Page";
|
|
218
215
|
const desc = frontmatter.desc || false;
|
|
216
|
+
const fullscreen = frontmatter.fullscreen || false;
|
|
219
217
|
const overline = frontmatter.overline || false;
|
|
220
|
-
const heading = rendered.env.heading ||
|
|
221
|
-
const related = frontmatter.related && Array.isArray(frontmatter.related) && frontmatter.related.map(
|
|
222
|
-
(entry) => convertToRelated(prefix, flatMenu, entry, id)
|
|
223
|
-
) || false;
|
|
218
|
+
const heading = rendered.env.heading || false;
|
|
219
|
+
const related = frontmatter.related && Array.isArray(frontmatter.related) && frontmatter.related.map((entry) => convertToRelated(prefix, flatMenu, entry, id)) || false;
|
|
224
220
|
const nav = frontmatter.nav || false;
|
|
225
221
|
const badge = frontmatter.badge || false;
|
|
226
222
|
const toc = rendered.env.toc || false;
|
|
@@ -237,6 +233,7 @@ function getVueComponent(rendered, code, id, prefix, menu) {
|
|
|
237
233
|
<markdown-page
|
|
238
234
|
title="${title}"
|
|
239
235
|
${desc !== false ? `desc="${desc}"` : ""}
|
|
236
|
+
${fullscreen !== false ? "fullscreen" : ""}
|
|
240
237
|
${overline !== false ? `overline="${overline}"` : ""}
|
|
241
238
|
${badge !== false ? `badge="${badge}"` : ""}
|
|
242
239
|
${heading !== false ? "heading" : ""}
|
|
@@ -272,13 +269,9 @@ function mdParse(code, id, prefix, menu) {
|
|
|
272
269
|
},
|
|
273
270
|
pageScripts: /* @__PURE__ */ new Set()
|
|
274
271
|
};
|
|
275
|
-
env.pageScripts.add(
|
|
276
|
-
"import MarkdownPage from 'src/layouts/MarkdownPage.vue'"
|
|
277
|
-
);
|
|
272
|
+
env.pageScripts.add("import MarkdownPage from 'src/layouts/MarkdownPage.vue'");
|
|
278
273
|
if (markdownApiRE.test(code) === true) {
|
|
279
|
-
env.pageScripts.add(
|
|
280
|
-
"import MarkdownApi from 'components/md/MarkdownApi.vue'"
|
|
281
|
-
);
|
|
274
|
+
env.pageScripts.add("import MarkdownApi from 'components/md/MarkdownApi.vue'");
|
|
282
275
|
}
|
|
283
276
|
if (markdownInstallationRE.test(code) === true) {
|
|
284
277
|
env.pageScripts.add(
|
|
@@ -286,20 +279,14 @@ function mdParse(code, id, prefix, menu) {
|
|
|
286
279
|
);
|
|
287
280
|
}
|
|
288
281
|
if (markdownTreeRE.test(code) === true) {
|
|
289
|
-
env.pageScripts.add(
|
|
290
|
-
"import MarkdownTree from 'components/md/MarkdownTree.vue'"
|
|
291
|
-
);
|
|
282
|
+
env.pageScripts.add("import MarkdownTree from 'components/md/MarkdownTree.vue'");
|
|
292
283
|
}
|
|
293
284
|
const results = md.render(code, env);
|
|
294
285
|
if (env.frontmatter.examples !== void 0) {
|
|
295
|
-
env.pageScripts.add(
|
|
296
|
-
"import MarkdownExample from 'components/md/MarkdownExample.vue'"
|
|
297
|
-
);
|
|
286
|
+
env.pageScripts.add("import MarkdownExample from 'components/md/MarkdownExample.vue'");
|
|
298
287
|
}
|
|
299
288
|
if (markdownLinkRE.test(code) === true) {
|
|
300
|
-
env.pageScripts.add(
|
|
301
|
-
"import MarkdownLink from 'components/md/MarkdownLink.vue'"
|
|
302
|
-
);
|
|
289
|
+
env.pageScripts.add("import MarkdownLink from 'components/md/MarkdownLink.vue'");
|
|
303
290
|
}
|
|
304
291
|
const component = getVueComponent(results, code, id, prefix, menu);
|
|
305
292
|
return {
|
|
@@ -315,7 +302,8 @@ let globalPrefix = "";
|
|
|
315
302
|
function transform(code, id) {
|
|
316
303
|
if (!mdRE.test(id)) return null;
|
|
317
304
|
try {
|
|
318
|
-
|
|
305
|
+
const result = mdParse(code, id, globalPrefix, globalMenu);
|
|
306
|
+
return result.code;
|
|
319
307
|
} catch (err) {
|
|
320
308
|
console.error(`Error processing Markdown file: ${id}`, err);
|
|
321
309
|
throw new Error(
|
|
@@ -323,11 +311,31 @@ function transform(code, id) {
|
|
|
323
311
|
);
|
|
324
312
|
}
|
|
325
313
|
}
|
|
314
|
+
function hotUpdate({
|
|
315
|
+
file,
|
|
316
|
+
server,
|
|
317
|
+
modules,
|
|
318
|
+
timestamp
|
|
319
|
+
}) {
|
|
320
|
+
if (mdRE.test(file)) {
|
|
321
|
+
const invalidatedModules = /* @__PURE__ */ new Set();
|
|
322
|
+
for (const mod of modules) {
|
|
323
|
+
server.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
|
|
324
|
+
}
|
|
325
|
+
server.ws.send({
|
|
326
|
+
type: "full-reload",
|
|
327
|
+
path: "*"
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return [];
|
|
331
|
+
}
|
|
326
332
|
const mdPlugins = {
|
|
327
333
|
name: "md-plugins:vitePlugin",
|
|
328
334
|
enforce: "pre",
|
|
329
335
|
// before vue
|
|
330
|
-
transform
|
|
336
|
+
transform,
|
|
337
|
+
// handleHotUpdate,
|
|
338
|
+
hotUpdate
|
|
331
339
|
};
|
|
332
340
|
function viteMdPlugin(path, menu) {
|
|
333
341
|
globalMenu = menu;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/vite-md-plugin",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "A very opinionated Vite plugin for @md-plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -34,27 +34,33 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"./dist"
|
|
36
36
|
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.5",
|
|
39
|
+
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.5",
|
|
40
|
+
"@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.5",
|
|
41
|
+
"@md-plugins/md-plugin-headers": "0.1.0-alpha.5",
|
|
42
|
+
"@md-plugins/md-plugin-image": "0.1.0-alpha.5",
|
|
43
|
+
"@md-plugins/md-plugin-containers": "0.1.0-alpha.5",
|
|
44
|
+
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.5",
|
|
45
|
+
"@md-plugins/md-plugin-imports": "0.1.0-alpha.5",
|
|
46
|
+
"@md-plugins/md-plugin-link": "0.1.0-alpha.5",
|
|
47
|
+
"@md-plugins/md-plugin-table": "0.1.0-alpha.5",
|
|
48
|
+
"@md-plugins/shared": "0.1.0-alpha.5",
|
|
49
|
+
"@md-plugins/md-plugin-title": "0.1.0-alpha.5"
|
|
50
|
+
},
|
|
37
51
|
"devDependencies": {
|
|
38
52
|
"@types/markdown-it": "^14.1.2",
|
|
39
53
|
"markdown-it": "^14.1.0",
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.1",
|
|
45
|
-
"@md-plugins/md-plugin-imports": "0.1.0-alpha.1",
|
|
46
|
-
"@md-plugins/md-plugin-table": "0.1.0-alpha.1",
|
|
47
|
-
"@md-plugins/md-plugin-title": "0.1.0-alpha.1",
|
|
48
|
-
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.1",
|
|
49
|
-
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.1",
|
|
50
|
-
"@md-plugins/md-plugin-image": "0.1.0-alpha.1",
|
|
51
|
-
"@md-plugins/md-plugin-link": "0.1.0-alpha.1"
|
|
54
|
+
"vite": "^6.0.7"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"markdown-it": "^14.1.0"
|
|
52
58
|
},
|
|
53
59
|
"publishConfig": {
|
|
54
60
|
"access": "public"
|
|
55
61
|
},
|
|
56
62
|
"scripts": {
|
|
57
63
|
"build": "unbuild",
|
|
58
|
-
"clean": "rm -rf dist"
|
|
64
|
+
"clean": "rm -rf dist/ node_modules/"
|
|
59
65
|
}
|
|
60
66
|
}
|