@md-plugins/vite-md-plugin 0.1.0-alpha.6 → 0.1.0-alpha.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/README.md +9 -3
- package/dist/index.d.mts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.mjs +18 -16
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ const menu = [] // Define your navigation menu structure here
|
|
|
55
55
|
const basePath = '/docs' // Base path prefix
|
|
56
56
|
|
|
57
57
|
export default defineConfig({
|
|
58
|
-
plugins: [vue(), viteMdPlugin(basePath, menu)],
|
|
58
|
+
plugins: [vue(), viteMdPlugin({ path: basePath, menu })],
|
|
59
59
|
})
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -67,7 +67,7 @@ If you’re using the Quasar Framework, additional configuration is needed to en
|
|
|
67
67
|
|
|
68
68
|
```js
|
|
69
69
|
import { viteMdPlugin } from '@md-plugins/vite-md-plugin';
|
|
70
|
-
import { menu } from './src/assets/menu'; // be sure to create this file
|
|
70
|
+
import { menu } from './src/.q-press/assets/menu'; // be sure to create this file
|
|
71
71
|
|
|
72
72
|
export default defineConfig((ctx) => {
|
|
73
73
|
// ...
|
|
@@ -82,7 +82,13 @@ build: {
|
|
|
82
82
|
},
|
|
83
83
|
|
|
84
84
|
vitePlugins: [
|
|
85
|
-
|
|
85
|
+
[
|
|
86
|
+
viteMdPlugin,
|
|
87
|
+
{
|
|
88
|
+
path: ctx.appPaths.srcDir + '/markdown',
|
|
89
|
+
menu: sidebar as MenuItem[],
|
|
90
|
+
},
|
|
91
|
+
],
|
|
86
92
|
// ...
|
|
87
93
|
],
|
|
88
94
|
},
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface MenuItem {
|
|
4
4
|
name: string;
|
|
@@ -34,15 +34,20 @@ interface RelatedItem {
|
|
|
34
34
|
category: string;
|
|
35
35
|
path: string;
|
|
36
36
|
}
|
|
37
|
+
interface UserConfig {
|
|
38
|
+
path: string;
|
|
39
|
+
menu: MenuItem[];
|
|
40
|
+
}
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
|
-
* Creates a Vite plugin for processing Markdown files.
|
|
40
|
-
* This plugin transforms Markdown content into Vue Single File Components (SFCs).
|
|
43
|
+
* Creates a Vite plugin for processing Markdown files based on the provided user configuration.
|
|
44
|
+
* This function configures and returns a plugin that transforms Markdown content into Vue Single File Components (SFCs).
|
|
41
45
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
46
|
+
* @param userConfig - The configuration object for the Vite Markdown plugin.
|
|
47
|
+
* @param userConfig.path - The base path prefix to be used for routing or file resolution.
|
|
48
|
+
* @param userConfig.menu - An array of MenuItem objects representing the navigation menu structure.
|
|
49
|
+
* @returns A Vite Plugin object pre-configured with the provided settings for Markdown processing.
|
|
45
50
|
*/
|
|
46
|
-
declare function viteMdPlugin(
|
|
51
|
+
declare function viteMdPlugin(userConfig: UserConfig): Plugin;
|
|
47
52
|
|
|
48
|
-
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, viteMdPlugin };
|
|
53
|
+
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, type UserConfig, viteMdPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface MenuItem {
|
|
4
4
|
name: string;
|
|
@@ -34,15 +34,20 @@ interface RelatedItem {
|
|
|
34
34
|
category: string;
|
|
35
35
|
path: string;
|
|
36
36
|
}
|
|
37
|
+
interface UserConfig {
|
|
38
|
+
path: string;
|
|
39
|
+
menu: MenuItem[];
|
|
40
|
+
}
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
|
-
* Creates a Vite plugin for processing Markdown files.
|
|
40
|
-
* This plugin transforms Markdown content into Vue Single File Components (SFCs).
|
|
43
|
+
* Creates a Vite plugin for processing Markdown files based on the provided user configuration.
|
|
44
|
+
* This function configures and returns a plugin that transforms Markdown content into Vue Single File Components (SFCs).
|
|
41
45
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
46
|
+
* @param userConfig - The configuration object for the Vite Markdown plugin.
|
|
47
|
+
* @param userConfig.path - The base path prefix to be used for routing or file resolution.
|
|
48
|
+
* @param userConfig.menu - An array of MenuItem objects representing the navigation menu structure.
|
|
49
|
+
* @returns A Vite Plugin object pre-configured with the provided settings for Markdown processing.
|
|
45
50
|
*/
|
|
46
|
-
declare function viteMdPlugin(
|
|
51
|
+
declare function viteMdPlugin(userConfig: UserConfig): Plugin;
|
|
47
52
|
|
|
48
|
-
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, viteMdPlugin };
|
|
53
|
+
export { type FlatMenu, type FlatMenuEntry, type MenuItem, type MenuNode, type NavItem, type RelatedItem, type UserConfig, viteMdPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -68,8 +68,8 @@ function createMarkdownRenderer(options = {}) {
|
|
|
68
68
|
containerComponent: "MarkdownPrerender",
|
|
69
69
|
copyButtonComponent: "MarkdownCopyButton",
|
|
70
70
|
pageScripts: [
|
|
71
|
-
"import MarkdownPrerender from 'components/
|
|
72
|
-
"import MarkdownCopyButton from 'components/
|
|
71
|
+
"import MarkdownPrerender from 'src/.q-press/components/MarkdownPrerender'",
|
|
72
|
+
"import MarkdownCopyButton from 'src/.q-press/components/MarkdownCopyButton.vue'"
|
|
73
73
|
]
|
|
74
74
|
});
|
|
75
75
|
md2.use(linkPlugin);
|
|
@@ -209,7 +209,7 @@ 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(id.indexOf("src/
|
|
212
|
+
frontmatter.editLink = id.substring(id.indexOf("src/markdown/") + 13, id.length - 3);
|
|
213
213
|
}
|
|
214
214
|
const title = frontmatter.title || rendered.env.title || rendered.title || "Generic Page";
|
|
215
215
|
const desc = frontmatter.desc || false;
|
|
@@ -221,7 +221,6 @@ function getVueComponent(rendered, code, id, prefix, menu) {
|
|
|
221
221
|
const badge = frontmatter.badge || false;
|
|
222
222
|
const toc = rendered.env.toc || false;
|
|
223
223
|
const editLink = frontmatter.editLink || false;
|
|
224
|
-
frontmatter.components || false;
|
|
225
224
|
const scope = frontmatter.scope || false;
|
|
226
225
|
const examples = frontmatter.examples || false;
|
|
227
226
|
const { mdContent, userScripts } = splitRenderedContent(rendered.html);
|
|
@@ -243,7 +242,7 @@ function getVueComponent(rendered, code, id, prefix, menu) {
|
|
|
243
242
|
${nav !== false ? ':nav="nav"' : ""}>${mdContent}</markdown-page>
|
|
244
243
|
</template>
|
|
245
244
|
<script setup>
|
|
246
|
-
import { copyHeading } from 'components/
|
|
245
|
+
import { copyHeading } from 'src/.q-press/components/markdown-utils'
|
|
247
246
|
${examples !== false ? `
|
|
248
247
|
import { provide } from 'vue'
|
|
249
248
|
provide('_markdown_examples_', process.env.CLIENT
|
|
@@ -269,24 +268,26 @@ function mdParse(code, id, prefix, menu) {
|
|
|
269
268
|
},
|
|
270
269
|
pageScripts: /* @__PURE__ */ new Set()
|
|
271
270
|
};
|
|
272
|
-
env.pageScripts.add("import MarkdownPage from 'src/layouts/
|
|
271
|
+
env.pageScripts.add("import MarkdownPage from 'src/.q-press/layouts/MarkdownPage.vue'");
|
|
273
272
|
if (markdownApiRE.test(code) === true) {
|
|
274
|
-
env.pageScripts.add("import MarkdownApi from 'components/
|
|
273
|
+
env.pageScripts.add("import MarkdownApi from 'src/.q-press/components/MarkdownApi.vue'");
|
|
275
274
|
}
|
|
276
275
|
if (markdownInstallationRE.test(code) === true) {
|
|
277
276
|
env.pageScripts.add(
|
|
278
|
-
"import MarkdownInstallation from 'components/
|
|
277
|
+
"import MarkdownInstallation from 'src/.q-press/components/MarkdownInstallation.vue'"
|
|
279
278
|
);
|
|
280
279
|
}
|
|
281
280
|
if (markdownTreeRE.test(code) === true) {
|
|
282
|
-
env.pageScripts.add("import MarkdownTree from 'components/
|
|
281
|
+
env.pageScripts.add("import MarkdownTree from 'src/.q-press/components/MarkdownTree.vue'");
|
|
283
282
|
}
|
|
284
283
|
const results = md.render(code, env);
|
|
285
284
|
if (env.frontmatter.examples !== void 0) {
|
|
286
|
-
env.pageScripts.add(
|
|
285
|
+
env.pageScripts.add(
|
|
286
|
+
"import MarkdownExample from 'src/.q-press/components/MarkdownExample.vue'"
|
|
287
|
+
);
|
|
287
288
|
}
|
|
288
289
|
if (markdownLinkRE.test(code) === true) {
|
|
289
|
-
env.pageScripts.add("import MarkdownLink from 'components/
|
|
290
|
+
env.pageScripts.add("import MarkdownLink from 'src/.q-press/components/MarkdownLink.vue'");
|
|
290
291
|
}
|
|
291
292
|
const component = getVueComponent(results, code, id, prefix, menu);
|
|
292
293
|
return {
|
|
@@ -324,23 +325,24 @@ function hotUpdate({
|
|
|
324
325
|
}
|
|
325
326
|
server.ws.send({
|
|
326
327
|
type: "full-reload",
|
|
327
|
-
path:
|
|
328
|
+
path: file
|
|
328
329
|
});
|
|
329
330
|
}
|
|
330
331
|
return [];
|
|
331
332
|
}
|
|
332
333
|
const mdPlugins = {
|
|
333
|
-
name: "md-plugins
|
|
334
|
+
name: "@md-plugins/vite-md-plugin",
|
|
334
335
|
enforce: "pre",
|
|
335
|
-
// before vue
|
|
336
336
|
transform,
|
|
337
|
-
// handleHotUpdate,
|
|
338
337
|
hotUpdate
|
|
339
338
|
};
|
|
340
|
-
function
|
|
339
|
+
function viteMdPlugin2(path, menu) {
|
|
341
340
|
globalMenu = menu;
|
|
342
341
|
globalPrefix = path;
|
|
343
342
|
return mdPlugins;
|
|
344
343
|
}
|
|
344
|
+
function viteMdPlugin(userConfig) {
|
|
345
|
+
return viteMdPlugin2(userConfig.path, userConfig.menu);
|
|
346
|
+
}
|
|
345
347
|
|
|
346
348
|
export { viteMdPlugin };
|
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.8",
|
|
4
4
|
"description": "A very opinionated Vite plugin for @md-plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"./dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@md-plugins/md-plugin-
|
|
39
|
-
"@md-plugins/md-plugin-
|
|
40
|
-
"@md-plugins/md-plugin-containers": "0.1.0-alpha.
|
|
41
|
-
"@md-plugins/md-plugin-
|
|
42
|
-
"@md-plugins/md-plugin-
|
|
43
|
-
"@md-plugins/md-plugin-
|
|
44
|
-
"@md-plugins/md-plugin-
|
|
45
|
-
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.
|
|
46
|
-
"@md-plugins/md-plugin-link": "0.1.0-alpha.
|
|
47
|
-
"@md-plugins/md-plugin-table": "0.1.0-alpha.
|
|
48
|
-
"@md-plugins/
|
|
49
|
-
"@md-plugins/
|
|
38
|
+
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.8",
|
|
39
|
+
"@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.8",
|
|
40
|
+
"@md-plugins/md-plugin-containers": "0.1.0-alpha.8",
|
|
41
|
+
"@md-plugins/md-plugin-image": "0.1.0-alpha.8",
|
|
42
|
+
"@md-plugins/md-plugin-headers": "0.1.0-alpha.8",
|
|
43
|
+
"@md-plugins/md-plugin-imports": "0.1.0-alpha.8",
|
|
44
|
+
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.8",
|
|
45
|
+
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.8",
|
|
46
|
+
"@md-plugins/md-plugin-link": "0.1.0-alpha.8",
|
|
47
|
+
"@md-plugins/md-plugin-table": "0.1.0-alpha.8",
|
|
48
|
+
"@md-plugins/shared": "0.1.0-alpha.8",
|
|
49
|
+
"@md-plugins/md-plugin-title": "0.1.0-alpha.8"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/markdown-it": "^14.1.2",
|