@md-plugins/quasar-app-extension-q-press 0.1.0-alpha.10
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 +21 -0
- package/README.md +230 -0
- package/old/prompts.js +44 -0
- package/old/uninstall.js +9 -0
- package/package.json +60 -0
- package/scripts/build.js +33 -0
- package/src/index.js +63 -0
- package/src/install.js +49 -0
- package/src/templates/.gitkeep +0 -0
- package/src/templates/init/src/_q-press/.gitkeep +0 -0
- package/src/templates/init/src/_q-press/api/components/DarkModeToggle.json +37 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownApi.json +67 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCardLink.json +28 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCode.json +37 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCodepen.json +21 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownExample.json +22 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeader.json +28 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownInstallation.json +33 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownLayout.json +52 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownLink.json +23 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPage.json +71 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPageToc.json +17 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownPrerender.json +25 -0
- package/src/templates/init/src/_q-press/api/components/MarkdownTree.json +27 -0
- package/src/templates/init/src/_q-press/api/composables/dark.json +29 -0
- package/src/templates/init/src/_q-press/api/composables/scroll.json +34 -0
- package/src/templates/init/src/_q-press/assets/get-meta.ts +29 -0
- package/src/templates/init/src/_q-press/components/DarkModeToggle.vue +105 -0
- package/src/templates/init/src/_q-press/components/MarkdownApi.vue +588 -0
- package/src/templates/init/src/_q-press/components/MarkdownApiEntry.ts +594 -0
- package/src/templates/init/src/_q-press/components/MarkdownCardLink.vue +25 -0
- package/src/templates/init/src/_q-press/components/MarkdownCardTitle.vue +21 -0
- package/src/templates/init/src/_q-press/components/MarkdownCode.vue +25 -0
- package/src/templates/init/src/_q-press/components/MarkdownCodePrism.ts +36 -0
- package/src/templates/init/src/_q-press/components/MarkdownCodepen.vue +183 -0
- package/src/templates/init/src/_q-press/components/MarkdownCopyButton.vue +104 -0
- package/src/templates/init/src/_q-press/components/MarkdownExample.vue +221 -0
- package/src/templates/init/src/_q-press/components/MarkdownInstallation.vue +166 -0
- package/src/templates/init/src/_q-press/components/MarkdownLink.vue +38 -0
- package/src/templates/init/src/_q-press/components/MarkdownPrerender.ts +82 -0
- package/src/templates/init/src/_q-press/components/MarkdownTree.vue +105 -0
- package/src/templates/init/src/_q-press/components/markdown-utils.ts +105 -0
- package/src/templates/init/src/_q-press/composables/dark.ts +39 -0
- package/src/templates/init/src/_q-press/composables/scroll.ts +115 -0
- package/src/templates/init/src/_q-press/css/app.scss +662 -0
- package/src/templates/init/src/_q-press/css/fonts.scss +100 -0
- package/src/templates/init/src/_q-press/css/prism-theme.scss +298 -0
- package/src/templates/init/src/_q-press/css/themes/default.scss +68 -0
- package/src/templates/init/src/_q-press/css/themes/newspaper.scss +69 -0
- package/src/templates/init/src/_q-press/css/themes/sunrise.scss +67 -0
- package/src/templates/init/src/_q-press/css/themes/tawny.scss +69 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeader.vue +412 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownLayout.vue +239 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPage.vue +307 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
- package/src/templates/init/src/_q-press/layouts/MarkdownSearch.vue +449 -0
- package/src/templates/init/src/_q-press/stores/markdown.ts +101 -0
- package/src/templates/init/src/components/LandingPage/LandingPage.vue +341 -0
- package/src/templates/init/src/components/Releases/PackageReleases.vue +164 -0
- package/src/templates/init/src/components/Releases/PublicReleases.vue +149 -0
- package/src/templates/init/src/components/Releases/ReleasesAvailable.vue +74 -0
- package/src/templates/init/src/examples/QAvatar/BasicExample.vue +11 -0
- package/src/templates/init/src/markdown/__elements.md +548 -0
- package/src/templates/init/src/markdown/__elements2.md +347 -0
- package/src/templates/init/src/markdown/faq/best-practices.md +0 -0
- package/src/templates/init/src/markdown/faq/general.md +0 -0
- package/src/templates/init/src/markdown/faq/troubleshooting.md +0 -0
- package/src/templates/init/src/markdown/getting-started/introduction.md +67 -0
- package/src/templates/init/src/markdown/guides/contributing.md +101 -0
- package/src/templates/init/src/markdown/guides/faq.md +115 -0
- package/src/templates/init/src/markdown/guides/release-notes.md +0 -0
- package/src/templates/init/src/markdown/guides/style-guide.md +0 -0
- package/src/templates/init/src/markdown/landing-page.md +11 -0
- package/src/templates/init/src/markdown/listing.ts +3 -0
- package/src/templates/init/src/markdown/md-plugins/blockquote/advanced.md +83 -0
- package/src/templates/init/src/markdown/md-plugins/blockquote/overview.md +183 -0
- package/src/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +210 -0
- package/src/templates/init/src/markdown/md-plugins/codeblocks/overview.md +616 -0
- package/src/templates/init/src/markdown/md-plugins/containers/advanced.md +301 -0
- package/src/templates/init/src/markdown/md-plugins/containers/overview.md +206 -0
- package/src/templates/init/src/markdown/md-plugins/frontmatter/advanced.md +164 -0
- package/src/templates/init/src/markdown/md-plugins/frontmatter/overview.md +131 -0
- package/src/templates/init/src/markdown/md-plugins/headers/advanced.md +236 -0
- package/src/templates/init/src/markdown/md-plugins/headers/overview.md +134 -0
- package/src/templates/init/src/markdown/md-plugins/image/advanced.md +114 -0
- package/src/templates/init/src/markdown/md-plugins/image/overview.md +124 -0
- package/src/templates/init/src/markdown/md-plugins/imports/advanced.md +105 -0
- package/src/templates/init/src/markdown/md-plugins/imports/overview.md +80 -0
- package/src/templates/init/src/markdown/md-plugins/inline-code/advanced.md +133 -0
- package/src/templates/init/src/markdown/md-plugins/inline-code/overview.md +101 -0
- package/src/templates/init/src/markdown/md-plugins/link/advanced.md +157 -0
- package/src/templates/init/src/markdown/md-plugins/link/overview.md +126 -0
- package/src/templates/init/src/markdown/md-plugins/shared/overview.md +175 -0
- package/src/templates/init/src/markdown/md-plugins/table/advanced.md +190 -0
- package/src/templates/init/src/markdown/md-plugins/table/overview.md +186 -0
- package/src/templates/init/src/markdown/md-plugins/title/advanced.md +88 -0
- package/src/templates/init/src/markdown/md-plugins/title/overview.md +99 -0
- package/src/templates/init/src/markdown/other/release-notes.md +12 -0
- package/src/templates/init/src/markdown/privacy-policy.md +12 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +101 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +69 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +254 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +4 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/advanced.md +4 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/overview.md +103 -0
- package/src/templates/init/src/markdown/vite-plugins/index.md +6 -0
- package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/advanced.md +138 -0
- package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/overview.md +88 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/advanced.md +226 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/index.md +6 -0
- package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/overview.md +166 -0
- package/src/templates/init/src/q-press.globals.d.ts +36 -0
- package/src/templates/init/src/siteConfig/index.ts +440 -0
- package/src/templates/update/src/_q-press/.gitkeep +0 -0
- package/src/templates/update/src/_q-press/api/components/DarkModeToggle.json +37 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownApi.json +67 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCardLink.json +28 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCode.json +37 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCodepen.json +21 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownExample.json +22 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeader.json +28 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownInstallation.json +33 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownLayout.json +52 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownLink.json +23 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPage.json +71 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPageToc.json +17 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownPrerender.json +25 -0
- package/src/templates/update/src/_q-press/api/components/MarkdownTree.json +27 -0
- package/src/templates/update/src/_q-press/api/composables/dark.json +29 -0
- package/src/templates/update/src/_q-press/api/composables/scroll.json +34 -0
- package/src/templates/update/src/_q-press/assets/get-meta.ts +29 -0
- package/src/templates/update/src/_q-press/components/DarkModeToggle.vue +105 -0
- package/src/templates/update/src/_q-press/components/MarkdownApi.vue +588 -0
- package/src/templates/update/src/_q-press/components/MarkdownApiEntry.ts +594 -0
- package/src/templates/update/src/_q-press/components/MarkdownCardLink.vue +25 -0
- package/src/templates/update/src/_q-press/components/MarkdownCardTitle.vue +21 -0
- package/src/templates/update/src/_q-press/components/MarkdownCode.vue +25 -0
- package/src/templates/update/src/_q-press/components/MarkdownCodePrism.ts +36 -0
- package/src/templates/update/src/_q-press/components/MarkdownCodepen.vue +183 -0
- package/src/templates/update/src/_q-press/components/MarkdownCopyButton.vue +104 -0
- package/src/templates/update/src/_q-press/components/MarkdownExample.vue +221 -0
- package/src/templates/update/src/_q-press/components/MarkdownInstallation.vue +166 -0
- package/src/templates/update/src/_q-press/components/MarkdownLink.vue +38 -0
- package/src/templates/update/src/_q-press/components/MarkdownPrerender.ts +82 -0
- package/src/templates/update/src/_q-press/components/MarkdownTree.vue +105 -0
- package/src/templates/update/src/_q-press/components/markdown-utils.ts +105 -0
- package/src/templates/update/src/_q-press/composables/dark.ts +39 -0
- package/src/templates/update/src/_q-press/composables/scroll.ts +115 -0
- package/src/templates/update/src/_q-press/css/app.scss +662 -0
- package/src/templates/update/src/_q-press/css/fonts.scss +100 -0
- package/src/templates/update/src/_q-press/css/prism-theme.scss +298 -0
- package/src/templates/update/src/_q-press/css/themes/default.scss +68 -0
- package/src/templates/update/src/_q-press/css/themes/newspaper.scss +69 -0
- package/src/templates/update/src/_q-press/css/themes/sunrise.scss +67 -0
- package/src/templates/update/src/_q-press/css/themes/tawny.scss +69 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeader.vue +412 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownLayout.vue +239 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPage.vue +307 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
- package/src/templates/update/src/_q-press/layouts/MarkdownSearch.vue +449 -0
- package/src/templates/update/src/_q-press/stores/markdown.ts +101 -0
- package/src/templates/update/src/q-press.globals.d.ts +36 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ViteMdPluginAppExt App Extension
|
|
3
|
+
desc: Overview of the ViteMdPluginAppExt for Quasar.
|
|
4
|
+
related:
|
|
5
|
+
- vite-plugins/vitemdplugin/overview
|
|
6
|
+
- quasar-app-extensions/qpress/overview
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
The `viteMdPluginAppExt` is a [Quasar App Extension](https://quasar.dev/app-extensions/introduction) that integrates the `viteMdPlugin` into your Quasar project. This extension allows you to use Markdown files as Vue components, enabling a seamless integration of Markdown content into your Quasar application.
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
|
|
13
|
+
- **Markdown as Vue Components**: Transform Markdown files into Vue components, allowing you to write and manage content in Markdown while leveraging the power of Vue and Quasar.
|
|
14
|
+
- **Automatic Configuration**: Automatically configures your Quasar project to handle Markdown files, reducing the need for manual setup.
|
|
15
|
+
- **Seamless Integration**: Integrates with Quasar's build system and Vue Router, ensuring smooth navigation and rendering of Markdown content.
|
|
16
|
+
- **Customizable**: Provides options to customize the integration, allowing you to tailor the behavior to your specific needs.
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
The `viteMdPluginAppExt` extension leverages the `viteMdPlugin` to transform Markdown content into Vue components. It automatically updates your Quasar configuration to include the necessary settings for handling Markdown files.
|
|
21
|
+
|
|
22
|
+
### Automatic Configuration
|
|
23
|
+
|
|
24
|
+
When you install and configure the `viteMdPluginAppExt` extension, it makes the following changes to your Quasar configuration:
|
|
25
|
+
|
|
26
|
+
- **Vue Router Mode**: Sets the `vueRouterMode` to `'history'` to ensure proper hash link handling.
|
|
27
|
+
- **Vite Plugin Options**: Includes Markdown files in the `viteVuePluginOptions.include` array to ensure they are transpiled correctly.
|
|
28
|
+
- **Auto Import Extensions**: Adds `'md'` and `'vue'` to the `framework.autoImportVueExtensions` array to enable auto-import for Markdown extensions.
|
|
29
|
+
|
|
30
|
+
### Example Configuration
|
|
31
|
+
|
|
32
|
+
Here is an example of how the `viteMdPluginAppExt` extension updates your Quasar configuration:
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
build: {
|
|
36
|
+
vueRouterMode: 'history', // Required for proper hash link handling
|
|
37
|
+
viteVuePluginOptions.include: [/\.(vue|md)$/], // Include Markdown files
|
|
38
|
+
},
|
|
39
|
+
framework: {
|
|
40
|
+
framework.autoImportVueExtensions: ['md', 'vue'], // Include Markdown files
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
To install the `viteMdPluginAppExt` extension, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pnpm add @md-plugins/vite-md-plugin-app-ext
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
After installing the extension, you need to configure it in your Quasar project. Here are the steps to get started:
|
|
55
|
+
|
|
56
|
+
1. **Import `@md-plugins/vite-md-plugin`:**
|
|
57
|
+
|
|
58
|
+
Update your `quasar.config.js` or `quasar.config.ts` to include the `@md-plugins/vite-md-plugin` extension:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { viteMdPlugin, type MenuItem } from '@md-plugins/vite-md-plugin'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Import Your Sidebar Menu:**
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import siteConfig from './src/siteConfig'
|
|
68
|
+
const { sidebar } = siteConfig
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. **Add the `viteMdPlugin` to the `vitePlugins` array:**
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
vitePlugins: [
|
|
75
|
+
viteMdPlugin(ctx.appPaths.srcDir + '/markdown', sidebar as MenuItem[]),
|
|
76
|
+
// ...
|
|
77
|
+
]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## MenuItem Interface
|
|
81
|
+
|
|
82
|
+
The `MenuItem` interface defines the structure of the sidebar menu items. It includes the following properties:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
interface MenuItem {
|
|
86
|
+
name: string
|
|
87
|
+
path?: string
|
|
88
|
+
icon?: string
|
|
89
|
+
iconColor?: string
|
|
90
|
+
rightIcon?: string
|
|
91
|
+
rightIconColor?: string
|
|
92
|
+
badge?: string
|
|
93
|
+
children?: MenuItem[] | undefined
|
|
94
|
+
external?: boolean
|
|
95
|
+
expanded?: boolean
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Conclusion
|
|
100
|
+
|
|
101
|
+
The `viteMdPluginAppExt` extension provides a convenient way to integrate Markdown content into your Quasar project. By transforming Markdown files into Vue components and automatically configuring your project, it simplifies the process of managing and rendering Markdown content. Whether you're building a documentation site, a blog, or any other content-rich application, the `viteMdPluginAppExt` extension offers a powerful and flexible solution.
|
|
102
|
+
|
|
103
|
+
Happy coding!
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ViteExamplesPlugin Advanced Topics
|
|
3
|
+
desc: ViteExamplesPlugin advanced topics for Vite.
|
|
4
|
+
related:
|
|
5
|
+
- vite-plugins/vitemdplugin/advanced
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ViteExamplesPlugin
|
|
9
|
+
|
|
10
|
+
The `viteExamplesPlugin` is a powerful tool for integrating example code snippets and demos into your Vite project. This section will cover how the plugin works, the available options for customization, and examples of how to use it effectively with both Vite and Quasar with Vite.
|
|
11
|
+
|
|
12
|
+
### Type Information
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { Plugin } from 'vite'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a Vite plugin for handling Markdown examples.
|
|
19
|
+
*
|
|
20
|
+
* This function sets up the target folder for example files and returns a function
|
|
21
|
+
* that creates the actual Vite plugin. The returned plugin resolves and loads
|
|
22
|
+
* example code based on the production or development environment.
|
|
23
|
+
*
|
|
24
|
+
* @param isProd - A boolean indicating whether the Vite build is in production mode.
|
|
25
|
+
* This parameter determines whether the plugin will use the `prodLoad` or `devLoad` function for loading example code.
|
|
26
|
+
*
|
|
27
|
+
* @param path - The path to the directory containing the example files.
|
|
28
|
+
* This path will be used as the target folder for resolving examples.
|
|
29
|
+
* The `targetFolder` variable is set to this value before creating the Vite plugin.
|
|
30
|
+
*
|
|
31
|
+
* @returns A function that creates a Vite plugin.
|
|
32
|
+
* The returned function takes a boolean parameter `isProd` and returns a Vite plugin object.
|
|
33
|
+
* The plugin object has a `name`, `enforce`, `resolveId`, and `load` property.
|
|
34
|
+
* The `resolveId` property resolves module IDs starting with "examples:" and returns a resolved ID.
|
|
35
|
+
* The `load` property loads example code based on the production or development environment.
|
|
36
|
+
*/
|
|
37
|
+
declare function viteExamplesPlugin({ isProd, path }: { isProd: boolean; path: string }): Plugin
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A function to determine the manual chunk name for a given module ID.
|
|
41
|
+
*
|
|
42
|
+
* @param id - The module ID to analyze.
|
|
43
|
+
* @returns A string representing the chunk name or `undefined`.
|
|
44
|
+
*/
|
|
45
|
+
declare function viteManualChunks(id: string): string | undefined
|
|
46
|
+
|
|
47
|
+
export { viteExamplesPlugin, viteManualChunks }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### How It Works
|
|
51
|
+
|
|
52
|
+
The `viteExamplesPlugin` processes example code snippets and demos in your Vite project, transforming them into interactive components. It supports various features to enhance the development and presentation of example code.
|
|
53
|
+
|
|
54
|
+
### Plugin Options
|
|
55
|
+
|
|
56
|
+
The `viteExamplesPlugin` provides several options for customization. Here are the available options and their descriptions:
|
|
57
|
+
|
|
58
|
+
#### `isProd`
|
|
59
|
+
|
|
60
|
+
- **Type**: `boolean`
|
|
61
|
+
- **Description**: A flag indicating whether the build is for production. This parameter determines whether the plugin will use the `prodLoad` or `devLoad` function for loading example code.
|
|
62
|
+
|
|
63
|
+
#### `path`
|
|
64
|
+
|
|
65
|
+
- **Type**: `string`
|
|
66
|
+
- **Description**: The absolute path to the directory containing example code snippets and demos.
|
|
67
|
+
|
|
68
|
+
### Vite Configuration
|
|
69
|
+
|
|
70
|
+
Here is an example of how you can configure the `viteExamplesPlugin` with custom options:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { defineConfig } from 'vite'
|
|
74
|
+
import vue from '@vitejs/plugin-vue'
|
|
75
|
+
import { viteExamplesPlugin } from 'vite-examples-plugin'
|
|
76
|
+
|
|
77
|
+
export default defineConfig(({ mode }) => {
|
|
78
|
+
const isProduction = mode === 'production'
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
plugins: [
|
|
82
|
+
vue(),
|
|
83
|
+
viteExamplesPlugin({ isProd: isProduction, path: '/absolute/path/to/examples' }),
|
|
84
|
+
],
|
|
85
|
+
build: {
|
|
86
|
+
chunkSizeWarningLimit: 650,
|
|
87
|
+
rollupOptions: {
|
|
88
|
+
output: {
|
|
89
|
+
manualChunks: {
|
|
90
|
+
vendor: ['vue', 'vite'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Quasar Framework Configuration
|
|
100
|
+
|
|
101
|
+
If you’re using the Quasar Framework with Vite, additional configuration is needed to enable support for example code snippets and demos:
|
|
102
|
+
|
|
103
|
+
1. **Update `quasar.config.(js|ts)`**:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { viteExamplesPlugin } from 'vite-examples-plugin'
|
|
107
|
+
|
|
108
|
+
export default defineConfig(({ mode }) => {
|
|
109
|
+
const isProduction = mode === 'production'
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
build: {
|
|
113
|
+
vueRouterMode: 'history', // Required for proper hash link handling
|
|
114
|
+
|
|
115
|
+
viteVuePluginOptions: {
|
|
116
|
+
include: [/\.(vue|md)$/], // Include Markdown files
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
vitePlugins: [
|
|
120
|
+
viteExamplesPlugin({ isProd: isProduction, path: '/absolute/path/to/examples' }),
|
|
121
|
+
// ...
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
framework: {
|
|
126
|
+
autoImportVueExtensions: ['vue', 'md'], // Enable auto-import for Markdown extensions
|
|
127
|
+
},
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
2. **Ensure that your routes and hash links are compatible with Vue Router's history mode.**
|
|
133
|
+
|
|
134
|
+
### Conclusion
|
|
135
|
+
|
|
136
|
+
The `viteExamplesPlugin` is a versatile tool for integrating example code snippets and demos into your Vite project. By customizing the plugin options, including the `isProd` flag, you can tailor the behavior of the plugin to fit your specific needs. Whether you are using Vite or Quasar with Vite, the `viteExamplesPlugin` provides a flexible and powerful solution for handling example code. Experiment with different configurations and find the one that works best for you.
|
|
137
|
+
|
|
138
|
+
Happy coding!
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vite Examples Plugin
|
|
3
|
+
desc: Vite Examples plugin for enhanced functionality.
|
|
4
|
+
related:
|
|
5
|
+
- vite-plugins/vitemdplugin/overview
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Welcome to the Vite Examples Plugin documentation! This guide will provide you with an overview of the Vite Examples plugins and their features.
|
|
9
|
+
|
|
10
|
+
## What is the Vite Examples Plugins?
|
|
11
|
+
|
|
12
|
+
The Vite Examples Plugin is a powerful tool that enhances the standard Vite functionality by providing custom chunking and example file handling. They integrate seamlessly with Vite to provide a flexible and customizable way to manage your Vite build process.
|
|
13
|
+
|
|
14
|
+
## Key Features
|
|
15
|
+
|
|
16
|
+
- **Manual Chunking**: Customize the chunking strategy for your Vite build.
|
|
17
|
+
- **Example Handling**: Easily include and manage examples in your Vite project.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
You can install the Vite Examples plugin using npm, yarn, or pnpm. Choose your preferred method below:
|
|
22
|
+
|
|
23
|
+
```tabs
|
|
24
|
+
<<| bash npm |>>
|
|
25
|
+
npm install @md-plugins/vite-examples-plugin
|
|
26
|
+
<<| bash yarn |>>
|
|
27
|
+
yarn add @md-plugins/vite-examples-plugin
|
|
28
|
+
<<| bash pnpm |>>
|
|
29
|
+
pnpm add @md-plugins/vite-examples-plugin
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quasar Configuration
|
|
33
|
+
|
|
34
|
+
To use the Vite Examples plugin with Quasar, you can extend the Vite configuration as follows:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { viteExamplesPlugin, viteManualChunks } from '@md-plugins/vite-examples-plugin'
|
|
38
|
+
|
|
39
|
+
extendViteConf(viteConf, { isClient }) {
|
|
40
|
+
if (ctx.prod && isClient) {
|
|
41
|
+
viteConf.build = viteConf.build || {}
|
|
42
|
+
viteConf.build.chunkSizeWarningLimit = 650
|
|
43
|
+
viteConf.build.rollupOptions = {
|
|
44
|
+
output: { manualChunks: viteManualChunks },
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
vitePlugins: [
|
|
50
|
+
viteExamplesPlugin({ isProd: ctx.prod, path: ctx.appPaths.srcDir + '/examples' }),
|
|
51
|
+
// other plugins...
|
|
52
|
+
]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Vite Configuration
|
|
56
|
+
|
|
57
|
+
To use the Vite Examples plugin with Vite, you can configure it as follows:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { defineConfig } from 'vite'
|
|
61
|
+
import vue from '@vitejs/plugin-vue'
|
|
62
|
+
import { viteExamplesPlugin, viteManualChunks } from 'vite-examples-plugin'
|
|
63
|
+
|
|
64
|
+
export default defineConfig(({ mode }) => {
|
|
65
|
+
const isProduction = mode === 'production'
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
plugins: [
|
|
69
|
+
vue(),
|
|
70
|
+
viteExamplesPlugin({ isProd: isProduction, path: '/absolute/path/to/examples' }),
|
|
71
|
+
],
|
|
72
|
+
build: {
|
|
73
|
+
chunkSizeWarningLimit: 650,
|
|
74
|
+
rollupOptions: {
|
|
75
|
+
output: {
|
|
76
|
+
manualChunks: viteManualChunks,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Support
|
|
85
|
+
|
|
86
|
+
If you have any questions or need assistance, please refer to the FAQ or reach out to our support team.
|
|
87
|
+
|
|
88
|
+
Happy coding!
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ViteMdPlugin Advanced Topics
|
|
3
|
+
desc: ViteMdPlugin advanced topics for Markdown.
|
|
4
|
+
related:
|
|
5
|
+
- vite-plugins/viteexamplesplugin/advanced
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
The `viteMdPlugin` is a powerful tool for integrating Markdown processing into your Vite project. This section will cover how the plugin works, the available options for customization, and examples of how to use it effectively with both Vite and Quasar with Vite.
|
|
9
|
+
|
|
10
|
+
### Type Information
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { Plugin } from 'vite'
|
|
14
|
+
|
|
15
|
+
interface MenuItem {
|
|
16
|
+
name: string
|
|
17
|
+
path?: string
|
|
18
|
+
icon?: string
|
|
19
|
+
iconColor?: string
|
|
20
|
+
rightIcon?: string
|
|
21
|
+
rightIconColor?: string
|
|
22
|
+
badge?: string
|
|
23
|
+
children?: MenuItem[] | undefined
|
|
24
|
+
external?: boolean
|
|
25
|
+
expanded?: boolean
|
|
26
|
+
}
|
|
27
|
+
interface MenuNode {
|
|
28
|
+
name: string
|
|
29
|
+
path?: string
|
|
30
|
+
external?: boolean
|
|
31
|
+
children?: MenuNode[]
|
|
32
|
+
}
|
|
33
|
+
interface FlatMenuEntry {
|
|
34
|
+
name: string
|
|
35
|
+
category: string | null
|
|
36
|
+
path: string
|
|
37
|
+
prev?: FlatMenuEntry
|
|
38
|
+
next?: FlatMenuEntry
|
|
39
|
+
}
|
|
40
|
+
type FlatMenu = Record<string, FlatMenuEntry>
|
|
41
|
+
interface NavItem extends FlatMenuEntry {
|
|
42
|
+
classes: string
|
|
43
|
+
}
|
|
44
|
+
interface RelatedItem {
|
|
45
|
+
name: string
|
|
46
|
+
category: string
|
|
47
|
+
path: string
|
|
48
|
+
}
|
|
49
|
+
interface UserConfig {
|
|
50
|
+
path: string
|
|
51
|
+
menu: MenuItem[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a Vite plugin for processing Markdown files based on the provided user configuration.
|
|
56
|
+
* This function configures and returns a plugin that transforms Markdown content into Vue Single File Components (SFCs).
|
|
57
|
+
*
|
|
58
|
+
* @param userConfig - The configuration object for the Vite Markdown plugin.
|
|
59
|
+
* @param userConfig.path - The base path prefix to be used for routing or file resolution.
|
|
60
|
+
* @param userConfig.menu - An array of MenuItem objects representing the navigation menu structure.
|
|
61
|
+
* @returns A Vite Plugin object pre-configured with the provided settings for Markdown processing.
|
|
62
|
+
*/
|
|
63
|
+
declare function viteMdPlugin(userConfig: UserConfig): Plugin
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
type FlatMenu,
|
|
67
|
+
type FlatMenuEntry,
|
|
68
|
+
type MenuItem,
|
|
69
|
+
type MenuNode,
|
|
70
|
+
type NavItem,
|
|
71
|
+
type RelatedItem,
|
|
72
|
+
type UserConfig,
|
|
73
|
+
viteMdPlugin,
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### How It Works
|
|
78
|
+
|
|
79
|
+
The `viteMdPlugin` processes Markdown files in your Vite project, transforming them into Vue Single File Components (SFCs). It supports various plugins to enhance the Markdown content, such as handling frontmatter, headers, containers, code blocks, and more.
|
|
80
|
+
|
|
81
|
+
### Default Behavior
|
|
82
|
+
|
|
83
|
+
By default, the `viteMdPlugin` processes Markdown files and applies the configured plugins to enhance the content. Here is an example of a basic configuration:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { defineConfig } from 'vite'
|
|
87
|
+
import vue from '@vitejs/plugin-vue'
|
|
88
|
+
import { viteMdPlugin, type MenuItem } from '@md-plugins/vite-md-plugin'
|
|
89
|
+
|
|
90
|
+
const menu = [] // Define your navigation menu structure here
|
|
91
|
+
const basePath = '/docs' // Base path prefix
|
|
92
|
+
|
|
93
|
+
export default defineConfig({
|
|
94
|
+
plugins: [vue(), viteMdPlugin({ path: basePath, menu })],
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Quasar Framework Configuration
|
|
99
|
+
|
|
100
|
+
If you’re using the Quasar Framework with Vite, additional configuration is needed to enable support for `.md` files:
|
|
101
|
+
|
|
102
|
+
1. Update `quasar.config.(js|ts)`:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { viteMdPlugin } from '@md-plugins/vite-md-plugin';
|
|
106
|
+
import { menu } from './src/assets/menu'; // be sure to create this file
|
|
107
|
+
|
|
108
|
+
export default defineConfig((ctx) => {
|
|
109
|
+
// ...
|
|
110
|
+
build: {
|
|
111
|
+
vueRouterMode: 'history', // Required for proper hash link handling
|
|
112
|
+
|
|
113
|
+
viteVuePluginOptions: {
|
|
114
|
+
include: [/\.(vue|md)$/], // Include Markdown files
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
vitePlugins: [
|
|
118
|
+
[
|
|
119
|
+
viteMdPlugin,
|
|
120
|
+
{
|
|
121
|
+
path: ctx.appPaths.srcDir + '/markdown',
|
|
122
|
+
menu: sidebar as MenuItem[],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
// ...
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
framework: {
|
|
130
|
+
autoImportVueExtensions: ['vue', 'md'], // Enable auto-import for Markdown extensions
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
2. Ensure that your routes and hash links are compatible with Vue Router's history mode.
|
|
136
|
+
|
|
137
|
+
### Navigation Menu Integration
|
|
138
|
+
|
|
139
|
+
The `viteMdPlugin` allows you to define a navigation structure that can be updated dynamically based on the Markdown files in your project:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
const menu = [
|
|
143
|
+
{ title: 'Home', path: '/home' },
|
|
144
|
+
{ title: 'About', path: '/about' },
|
|
145
|
+
]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
### Plugin Options
|
|
151
|
+
|
|
152
|
+
The `viteMdPlugin` provides several options for customization. Here are the available options and their descriptions:
|
|
153
|
+
|
|
154
|
+
#### `path`
|
|
155
|
+
|
|
156
|
+
- **Type**: `string`
|
|
157
|
+
- **Description**: The base path prefix to be used for routing or file resolution.
|
|
158
|
+
|
|
159
|
+
#### `menu`
|
|
160
|
+
|
|
161
|
+
- **Type**: `MenuItem[]`
|
|
162
|
+
- **Description**: An array of `MenuItem` objects representing the navigation menu structure.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
export interface MenuItem {
|
|
166
|
+
name: string
|
|
167
|
+
path?: string
|
|
168
|
+
icon?: string
|
|
169
|
+
iconColor?: string
|
|
170
|
+
rightIcon?: string
|
|
171
|
+
rightIconColor?: string
|
|
172
|
+
badge?: string
|
|
173
|
+
children?: MenuItem[] | undefined
|
|
174
|
+
external?: boolean
|
|
175
|
+
expanded?: boolean
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Example Configuration
|
|
180
|
+
|
|
181
|
+
Here is an example of how you can configure the `viteMdPlugin` with custom options:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { defineConfig } from 'vite'
|
|
185
|
+
import vue from '@vitejs/plugin-vue'
|
|
186
|
+
import { viteMdPlugin } from '@md-plugins/vite-md-plugin'
|
|
187
|
+
|
|
188
|
+
const menu = [
|
|
189
|
+
{ title: 'Home', path: '/' },
|
|
190
|
+
{ title: 'Guide', path: '/guide/' },
|
|
191
|
+
{ title: 'API', path: '/api/' },
|
|
192
|
+
]
|
|
193
|
+
const basePath = '/docs'
|
|
194
|
+
|
|
195
|
+
export default defineConfig({
|
|
196
|
+
plugins: [vue(), viteMdPlugin(basePath, menu)],
|
|
197
|
+
})
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Using the Plugin
|
|
201
|
+
|
|
202
|
+
Once the `viteMdPlugin` is configured, you can use it to process Markdown files in your Vite project. Here is an example of a Markdown file:
|
|
203
|
+
|
|
204
|
+
```markdown
|
|
205
|
+
---
|
|
206
|
+
title: My Awesome Post
|
|
207
|
+
date: 2023-10-01
|
|
208
|
+
tags: [vite, markdown, plugin]
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
# My Awesome Post
|
|
212
|
+
|
|
213
|
+
This is the content of my awesome post.
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
When you build your project, the `viteMdPlugin` will process this Markdown file and generate a Vue Single File Component (SFC) that can be used in your application.
|
|
217
|
+
|
|
218
|
+
## Advanced
|
|
219
|
+
|
|
220
|
+
If you need to change the behavior of `viteMdPlugin`, you can create your own Vite plugin and use that instead. Look at the source to see how it can be done.
|
|
221
|
+
|
|
222
|
+
## Conclusion
|
|
223
|
+
|
|
224
|
+
The `viteMdPlugin` is a versatile tool for integrating Markdown processing into your Vite project. By customizing the plugins and options, you can tailor the Markdown content to fit your specific needs. Whether you are using Vite or Quasar with Vite, the `viteMdPlugin` provides a flexible and powerful solution for handling Markdown files. Experiment with different configurations and find the one that works best for you.
|
|
225
|
+
|
|
226
|
+
Happy coding!
|