@md-plugins/vite-md-plugin 0.1.0-alpha.2 → 0.1.0-alpha.21

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 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
- viteMdPlugin(ctx.appPaths.srcDir + '/pages', menu),
85
+ [
86
+ viteMdPlugin,
87
+ {
88
+ path: ctx.appPaths.srcDir + '/markdown',
89
+ menu: sidebar as MenuItem[],
90
+ },
91
+ ],
86
92
  // ...
87
93
  ],
88
94
  },
@@ -143,6 +149,10 @@ To run the tests for this plugin, use the following command:
143
149
  pnpm test
144
150
  ```
145
151
 
152
+ ## Documentation
153
+
154
+ In case this README falls out of date, please refer to the [documentation](https://md-plugins.netlify.app/vite-plugins/vitemdplugin/overview) for the latest information.
155
+
146
156
  ## License
147
157
 
148
158
  This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
package/dist/index.d.mts CHANGED
@@ -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 path - The base path prefix to be used for routing or file resolution.
43
- * @param menu - An array of MenuItem objects representing the navigation menu structure.
44
- * @returns A Vite plugin object with pre-configured settings for Markdown processing.
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(path: string, menu: MenuItem[]): Plugin;
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
@@ -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 path - The base path prefix to be used for routing or file resolution.
43
- * @param menu - An array of MenuItem objects representing the navigation menu structure.
44
- * @returns A Vite plugin object with pre-configured settings for Markdown processing.
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(path: string, menu: MenuItem[]): Plugin;
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/md/MarkdownPrerender'",
72
- "import MarkdownCopyButton from 'components/md/MarkdownCopyButton.vue'"
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);
@@ -164,12 +164,12 @@ function createNav(id, env, flatMenu) {
164
164
  if (flatMenu) {
165
165
  const menuItem = flatMenu[id];
166
166
  const nav = [];
167
- if (menuItem !== void 0) {
167
+ if (menuItem !== undefined) {
168
168
  const { prev, next } = menuItem;
169
- if (prev !== void 0) {
169
+ if (prev !== undefined) {
170
170
  nav.push({ ...prev, classes: "markdown-page__related--left" });
171
171
  }
172
- if (next !== void 0) {
172
+ if (next !== undefined) {
173
173
  nav.push({ ...next, classes: "markdown-page__related--right" });
174
174
  }
175
175
  }
@@ -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/pages/") + 10, id.length - 3);
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/md/markdown-utils'
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
@@ -260,7 +259,6 @@ ${pageScripts}
260
259
 
261
260
  const markdownLinkRE = /<MarkdownLink /;
262
261
  const markdownApiRE = /<MarkdownApi /;
263
- const markdownInstallationRE = /<MarkdownInstallation /;
264
262
  const markdownTreeRE = /<MarkdownTree /;
265
263
  function mdParse(code, id, prefix, menu) {
266
264
  const env = {
@@ -269,24 +267,21 @@ function mdParse(code, id, prefix, menu) {
269
267
  },
270
268
  pageScripts: /* @__PURE__ */ new Set()
271
269
  };
272
- env.pageScripts.add("import MarkdownPage from 'src/layouts/MarkdownPage.vue'");
270
+ env.pageScripts.add("import MarkdownPage from 'src/.q-press/layouts/MarkdownPage.vue'");
273
271
  if (markdownApiRE.test(code) === true) {
274
- env.pageScripts.add("import MarkdownApi from 'components/md/MarkdownApi.vue'");
275
- }
276
- if (markdownInstallationRE.test(code) === true) {
277
- env.pageScripts.add(
278
- "import MarkdownInstallation from 'components/md/MarkdownInstallation.vue'"
279
- );
272
+ env.pageScripts.add("import MarkdownApi from 'src/.q-press/components/MarkdownApi.vue'");
280
273
  }
281
274
  if (markdownTreeRE.test(code) === true) {
282
- env.pageScripts.add("import MarkdownTree from 'components/md/MarkdownTree.vue'");
275
+ env.pageScripts.add("import MarkdownTree from 'src/.q-press/components/MarkdownTree.vue'");
283
276
  }
284
277
  const results = md.render(code, env);
285
- if (env.frontmatter.examples !== void 0) {
286
- env.pageScripts.add("import MarkdownExample from 'components/md/MarkdownExample.vue'");
278
+ if (env.frontmatter.examples !== undefined) {
279
+ env.pageScripts.add(
280
+ "import MarkdownExample from 'src/.q-press/components/MarkdownExample.vue'"
281
+ );
287
282
  }
288
283
  if (markdownLinkRE.test(code) === true) {
289
- env.pageScripts.add("import MarkdownLink from 'components/md/MarkdownLink.vue'");
284
+ env.pageScripts.add("import MarkdownLink from 'src/.q-press/components/MarkdownLink.vue'");
290
285
  }
291
286
  const component = getVueComponent(results, code, id, prefix, menu);
292
287
  return {
@@ -324,23 +319,24 @@ function hotUpdate({
324
319
  }
325
320
  server.ws.send({
326
321
  type: "full-reload",
327
- path: "*"
322
+ path: file
328
323
  });
329
324
  }
330
325
  return [];
331
326
  }
332
327
  const mdPlugins = {
333
- name: "md-plugins:vitePlugin",
328
+ name: "@md-plugins/vite-md-plugin",
334
329
  enforce: "pre",
335
- // before vue
336
330
  transform,
337
- // handleHotUpdate,
338
331
  hotUpdate
339
332
  };
340
- function viteMdPlugin(path, menu) {
333
+ function viteMdPlugin2(path, menu) {
341
334
  globalMenu = menu;
342
335
  globalPrefix = path;
343
336
  return mdPlugins;
344
337
  }
338
+ function viteMdPlugin(userConfig) {
339
+ return viteMdPlugin2(userConfig.path, userConfig.menu);
340
+ }
345
341
 
346
342
  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.2",
3
+ "version": "0.1.0-alpha.21",
4
4
  "description": "A very opinionated Vite plugin for @md-plugins.",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -35,21 +35,26 @@
35
35
  "./dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@types/markdown-it": "^14.1.2",
39
38
  "markdown-it": "^14.1.0",
40
- "vite": "^6.0.6",
41
- "@md-plugins/md-plugin-blockquote": "0.1.0-alpha.2",
42
- "@md-plugins/md-plugin-containers": "0.1.0-alpha.2",
43
- "@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.2",
44
- "@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.2",
45
- "@md-plugins/md-plugin-imports": "0.1.0-alpha.2",
46
- "@md-plugins/md-plugin-image": "0.1.0-alpha.2",
47
- "@md-plugins/md-plugin-headers": "0.1.0-alpha.2",
48
- "@md-plugins/md-plugin-link": "0.1.0-alpha.2",
49
- "@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.2",
50
- "@md-plugins/md-plugin-table": "0.1.0-alpha.2",
51
- "@md-plugins/md-plugin-title": "0.1.0-alpha.2",
52
- "@md-plugins/shared": "0.1.0-alpha.2"
39
+ "@md-plugins/md-plugin-blockquote": "0.1.0-alpha.21",
40
+ "@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.21",
41
+ "@md-plugins/md-plugin-containers": "0.1.0-alpha.21",
42
+ "@md-plugins/md-plugin-headers": "0.1.0-alpha.21",
43
+ "@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.21",
44
+ "@md-plugins/md-plugin-image": "0.1.0-alpha.21",
45
+ "@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.21",
46
+ "@md-plugins/md-plugin-imports": "0.1.0-alpha.21",
47
+ "@md-plugins/md-plugin-link": "0.1.0-alpha.21",
48
+ "@md-plugins/md-plugin-table": "0.1.0-alpha.21",
49
+ "@md-plugins/md-plugin-title": "0.1.0-alpha.21",
50
+ "@md-plugins/shared": "0.1.0-alpha.21"
51
+ },
52
+ "devDependencies": {
53
+ "@types/markdown-it": "^14.1.2",
54
+ "vite": "^6.0.7"
55
+ },
56
+ "peerDependencies": {
57
+ "markdown-it": "^14.1.0"
53
58
  },
54
59
  "publishConfig": {
55
60
  "access": "public"