@md-plugins/quasar-app-extension-q-press 0.1.0-alpha.26 → 0.1.0-alpha.28
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 +69 -73
- package/package.json +14 -14
- package/src/templates/init/src/markdown/md-plugins/containers/advanced.md +23 -2
- package/src/templates/init/src/markdown/md-plugins/headers/advanced.md +17 -163
- package/src/templates/init/src/markdown/md-plugins/headers/overview.md +6 -0
- package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +2 -1
- package/src/templates/init/src/markdown/vite-plugins/vite-md-plugin/advanced.md +69 -3
- package/src/templates/init/src/markdown/vite-plugins/vite-md-plugin/overview.md +1 -0
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The Ultimate Markdown Solution for the Quasar Framework.
|
|
4
4
|
|
|
5
|
+
See the [documentation](https://md-plugins.netlify.app/quasar-app-extensions/qpress/overview) for more information.
|
|
6
|
+
|
|
5
7
|
## Features
|
|
6
8
|
|
|
7
9
|
- **Markdown**
|
|
@@ -63,25 +65,25 @@ The Ultimate Markdown Solution for the Quasar Framework.
|
|
|
63
65
|
3. Modify your `quasar.config.ts`
|
|
64
66
|
|
|
65
67
|
- ```ts
|
|
66
|
-
import { viteMdPlugin, type MenuItem } from '@md-plugins/vite-md-plugin'
|
|
67
|
-
|
|
68
|
+
import { viteMdPlugin, type MenuItem, type MarkdownOptions } from '@md-plugins/vite-md-plugin'
|
|
68
69
|
|
|
69
70
|
export default defineConfig(async (ctx) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
// Dynamically import siteConfig
|
|
72
|
+
const siteConfig = await import('./src/siteConfig')
|
|
73
|
+
const { sidebar } = siteConfig
|
|
74
|
+
return {
|
|
75
|
+
build: {
|
|
76
|
+
vitePlugins: [
|
|
77
|
+
// add this plugin
|
|
78
|
+
[
|
|
79
|
+
viteMdPlugin,
|
|
80
|
+
{
|
|
81
|
+
path: ctx.appPaths.srcDir + '/markdown',
|
|
82
|
+
menu: sidebar as MenuItem[],
|
|
83
|
+
// options: myOptions as MarkdownOptions
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
// ...
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
4. Modify your `src/routes/routes.ts`
|
|
@@ -89,59 +91,54 @@ The Ultimate Markdown Solution for the Quasar Framework.
|
|
|
89
91
|
- ```ts
|
|
90
92
|
import type { RouteRecordRaw } from 'vue-router'
|
|
91
93
|
import mdPageList from 'src/markdown/listing'
|
|
94
|
+
const routes = [
|
|
95
|
+
{
|
|
96
|
+
path: '/',
|
|
97
|
+
component: () => import('src/.q-press/layouts/MarkdownLayout.vue'),
|
|
98
|
+
children: [
|
|
99
|
+
// Include the Landing Page route first
|
|
100
|
+
...Object.entries(mdPageList)
|
|
101
|
+
.filter(([key]) => key.includes('landing-page.md'))
|
|
102
|
+
.map(([_key, component]) => ({
|
|
103
|
+
path: '',
|
|
104
|
+
name: 'Landing Page',
|
|
105
|
+
component,
|
|
106
|
+
meta: { fullscreen: true, dark: true },
|
|
107
|
+
})),
|
|
108
|
+
|
|
109
|
+
// Now include all other routes, excluding the landing-page
|
|
110
|
+
...Object.keys(mdPageList)
|
|
111
|
+
.filter((key) => !key.includes('landing-page.md')) // Exclude duplicates
|
|
112
|
+
.map((key) => {
|
|
113
|
+
const acc = {
|
|
114
|
+
path: '',
|
|
115
|
+
component: mdPageList[key],
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (acc.path === '') {
|
|
119
|
+
// Remove '.md' from the end of the filename
|
|
120
|
+
const parts = key.substring(1, key.length - 3).split('/')
|
|
121
|
+
const len = parts.length
|
|
122
|
+
const path = parts[len - 2] === parts[len - 1] ? parts.slice(0, len - 1) : parts
|
|
123
|
+
|
|
124
|
+
acc.path = path.join('/')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return acc
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
// Always leave this as last one,
|
|
132
|
+
// but you can also remove it
|
|
133
|
+
{
|
|
134
|
+
path: '/:catchAll(._)_',
|
|
135
|
+
component: () => import('pages/ErrorNotFound.vue'),
|
|
136
|
+
},
|
|
137
|
+
] as RouteRecordRaw[]
|
|
138
|
+
|
|
139
|
+
export default routes
|
|
92
140
|
```
|
|
93
141
|
|
|
94
|
-
const routes = [
|
|
95
|
-
{
|
|
96
|
-
path: '/',
|
|
97
|
-
component: () => import('src/.q-press/layouts/MarkdownLayout.vue'),
|
|
98
|
-
children: [
|
|
99
|
-
// Include the Landing Page route first
|
|
100
|
-
...Object.entries(mdPageList)
|
|
101
|
-
.filter(([key]) => key.includes('landing-page.md'))
|
|
102
|
-
.map(([_key, component]) => ({
|
|
103
|
-
path: '',
|
|
104
|
-
name: 'Landing Page',
|
|
105
|
-
component,
|
|
106
|
-
meta: { fullscreen: true, dark: true },
|
|
107
|
-
})),
|
|
108
|
-
|
|
109
|
-
// Now include all other routes, excluding the landing-page
|
|
110
|
-
...Object.keys(mdPageList)
|
|
111
|
-
.filter((key) => !key.includes('landing-page.md')) // Exclude duplicates
|
|
112
|
-
.map((key) => {
|
|
113
|
-
const acc = {
|
|
114
|
-
path: '',
|
|
115
|
-
component: mdPageList[key],
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (acc.path === '') {
|
|
119
|
-
// Remove '.md' from the end of the filename
|
|
120
|
-
const parts = key.substring(1, key.length - 3).split('/')
|
|
121
|
-
const len = parts.length
|
|
122
|
-
const path = parts[len - 2] === parts[len - 1] ? parts.slice(0, len - 1) : parts
|
|
123
|
-
|
|
124
|
-
acc.path = path.join('/')
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return acc
|
|
128
|
-
}),
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
// Always leave this as last one,
|
|
134
|
-
// but you can also remove it
|
|
135
|
-
{
|
|
136
|
-
path: '/:catchAll(._)_',
|
|
137
|
-
component: () => import('pages/ErrorNotFound.vue'),
|
|
138
|
-
},
|
|
139
|
-
] as RouteRecordRaw[]
|
|
140
|
-
|
|
141
|
-
export default routes
|
|
142
|
-
|
|
143
|
-
````
|
|
144
|
-
|
|
145
142
|
5. Set up for Dark mode support, update your App.vue
|
|
146
143
|
|
|
147
144
|
- ```ts
|
|
@@ -149,13 +146,12 @@ export default routes
|
|
|
149
146
|
<router-view />
|
|
150
147
|
</template>
|
|
151
148
|
|
|
152
|
-
|
|
153
149
|
<script setup lang="ts">
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
import { useDark } from 'src/.q-press/composables/dark'
|
|
151
|
+
const { initDark } = useDark()
|
|
152
|
+
initDark()
|
|
157
153
|
</script>
|
|
158
|
-
|
|
154
|
+
```
|
|
159
155
|
|
|
160
156
|
## Running the App
|
|
161
157
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@md-plugins/quasar-app-extension-q-press",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.28",
|
|
4
4
|
"description": "QPress - The Ultimate Markdown Solution for Quasar Framework",
|
|
5
5
|
"author": "hawkeye64 <galbraith64@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -29,19 +29,19 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/markdown-it": "^14.1.2",
|
|
31
31
|
"markdown-it": "^14.1.0",
|
|
32
|
-
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.
|
|
33
|
-
"@md-plugins/md-plugin-
|
|
34
|
-
"@md-plugins/md-plugin-
|
|
35
|
-
"@md-plugins/md-plugin-
|
|
36
|
-
"@md-plugins/md-plugin-
|
|
37
|
-
"@md-plugins/md-plugin-
|
|
38
|
-
"@md-plugins/md-plugin-
|
|
39
|
-
"@md-plugins/md-plugin-
|
|
40
|
-
"@md-plugins/md-plugin-link": "0.1.0-alpha.
|
|
41
|
-
"@md-plugins/md-plugin-
|
|
42
|
-
"@md-plugins/md-plugin-
|
|
43
|
-
"@md-plugins/
|
|
44
|
-
"@md-plugins/
|
|
32
|
+
"@md-plugins/md-plugin-blockquote": "0.1.0-alpha.28",
|
|
33
|
+
"@md-plugins/md-plugin-containers": "0.1.0-alpha.28",
|
|
34
|
+
"@md-plugins/md-plugin-headers": "0.1.0-alpha.28",
|
|
35
|
+
"@md-plugins/md-plugin-imports": "0.1.0-alpha.28",
|
|
36
|
+
"@md-plugins/md-plugin-frontmatter": "0.1.0-alpha.28",
|
|
37
|
+
"@md-plugins/md-plugin-image": "0.1.0-alpha.28",
|
|
38
|
+
"@md-plugins/md-plugin-inlinecode": "0.1.0-alpha.28",
|
|
39
|
+
"@md-plugins/md-plugin-table": "0.1.0-alpha.28",
|
|
40
|
+
"@md-plugins/md-plugin-link": "0.1.0-alpha.28",
|
|
41
|
+
"@md-plugins/md-plugin-title": "0.1.0-alpha.28",
|
|
42
|
+
"@md-plugins/md-plugin-codeblocks": "0.1.0-alpha.28",
|
|
43
|
+
"@md-plugins/vite-md-plugin": "0.1.0-alpha.28",
|
|
44
|
+
"@md-plugins/shared": "0.1.0-alpha.28"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/markdown-it": "^14.1.2",
|
|
@@ -118,9 +118,10 @@ The following classes are in SCSS format.
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
&:not(.markdown-note--tip, .markdown-note--warning, .markdown-note--danger) {
|
|
121
|
-
|
|
121
|
+
color: $brand-light-text;
|
|
122
|
+
background-color: $brand-light-bg;
|
|
122
123
|
border-color: $separator-color;
|
|
123
|
-
.markdown-note__title,
|
|
124
|
+
// .markdown-note__title,
|
|
124
125
|
.markdown-link,
|
|
125
126
|
.markdown-token {
|
|
126
127
|
color: $brand-primary;
|
|
@@ -128,9 +129,14 @@ The following classes are in SCSS format.
|
|
|
128
129
|
.markdown-token {
|
|
129
130
|
border-color: $brand-primary;
|
|
130
131
|
}
|
|
132
|
+
& strong {
|
|
133
|
+
font-weight: 700;
|
|
134
|
+
color: scale-color($brand-light-text, $lightness: 90%);
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
&--tip {
|
|
139
|
+
color: scale-color($positive, $lightness: -40%) !important;
|
|
134
140
|
background-color: scale-color($positive, $lightness: 85%);
|
|
135
141
|
border-color: $positive;
|
|
136
142
|
.markdown-note__title,
|
|
@@ -141,9 +147,14 @@ The following classes are in SCSS format.
|
|
|
141
147
|
.markdown-token {
|
|
142
148
|
border-color: scale-color($positive, $lightness: -40%);
|
|
143
149
|
}
|
|
150
|
+
& strong {
|
|
151
|
+
font-weight: 700;
|
|
152
|
+
color: scale-color($positive, $lightness: 90%);
|
|
153
|
+
}
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
&--warning {
|
|
157
|
+
color: scale-color($warning, $lightness: -40%);
|
|
147
158
|
background-color: scale-color($warning, $lightness: 85%);
|
|
148
159
|
border-color: scale-color($warning, $lightness: -30%);
|
|
149
160
|
.markdown-note__title,
|
|
@@ -154,9 +165,14 @@ The following classes are in SCSS format.
|
|
|
154
165
|
.markdown-token {
|
|
155
166
|
border-color: scale-color($warning, $lightness: -40%);
|
|
156
167
|
}
|
|
168
|
+
& strong {
|
|
169
|
+
font-weight: 700;
|
|
170
|
+
color: scale-color($warning, $lightness: 90%);
|
|
171
|
+
}
|
|
157
172
|
}
|
|
158
173
|
|
|
159
174
|
&--danger {
|
|
175
|
+
color: scale-color($negative, $lightness: -40%);
|
|
160
176
|
background-color: scale-color($negative, $lightness: 90%);
|
|
161
177
|
border-color: $negative;
|
|
162
178
|
.markdown-note__title,
|
|
@@ -167,6 +183,11 @@ The following classes are in SCSS format.
|
|
|
167
183
|
.markdown-token {
|
|
168
184
|
border-color: $negative;
|
|
169
185
|
}
|
|
186
|
+
|
|
187
|
+
& strong {
|
|
188
|
+
font-weight: 700;
|
|
189
|
+
color: scale-color($negative, $lightness: 90%);
|
|
190
|
+
}
|
|
170
191
|
}
|
|
171
192
|
|
|
172
193
|
&--details {
|
|
@@ -7,7 +7,7 @@ desc: Headers plugin advanced topics for Markdown.
|
|
|
7
7
|
|
|
8
8
|
The `headers` plugin allows you to add custom classes to headers and generate a table of contents (TOC) in your Markdown content. This section will cover how the plugin works, the available options for customization, and examples of how to use it effectively.
|
|
9
9
|
|
|
10
|
-
### Type
|
|
10
|
+
### Type Information
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
import { PluginWithOptions } from 'markdown-it'
|
|
@@ -44,6 +44,22 @@ interface HeadersPluginOptions {
|
|
|
44
44
|
* @default false
|
|
45
45
|
*/
|
|
46
46
|
shouldAllowNested?: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Should allow API headers
|
|
49
|
+
*
|
|
50
|
+
* If set to `true`, headers for `<MarkdownAPI>` title would also be extracted.
|
|
51
|
+
*
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
shouldAllowApi?: boolean
|
|
55
|
+
/**
|
|
56
|
+
* Should allow Example headers
|
|
57
|
+
*
|
|
58
|
+
* If set to `true`, headers for `<MarkdownExample>` title would also be extracted.
|
|
59
|
+
*
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
shouldAllowExample?: boolean
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
interface TocItem {
|
|
@@ -67,168 +83,6 @@ declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>
|
|
|
67
83
|
export { type HeadersPluginOptions, type TocItem, headersPlugin }
|
|
68
84
|
```
|
|
69
85
|
|
|
70
|
-
### How It Works
|
|
71
|
-
|
|
72
|
-
The `headers` plugin processes headers in your Markdown content, adding custom classes and generating a TOC. The TOC is stored in the `env` object passed to the Markdown renderer.
|
|
73
|
-
|
|
74
|
-
### Default Behavior
|
|
75
|
-
|
|
76
|
-
By default, the `headers` plugin adds custom classes to headers and generates a TOC for headers at levels 2 and 3. Here is an example of a Markdown file with headers:
|
|
77
|
-
|
|
78
|
-
```markdown
|
|
79
|
-
# My Awesome Post
|
|
80
|
-
|
|
81
|
-
## Introduction
|
|
82
|
-
|
|
83
|
-
## Details
|
|
84
|
-
|
|
85
|
-
### Subsection
|
|
86
|
-
|
|
87
|
-
## Conclusion
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Plugin Options
|
|
91
|
-
|
|
92
|
-
The `headers` plugin provides several options for customization. Here are the available options and their descriptions:
|
|
93
|
-
|
|
94
|
-
#### `level`
|
|
95
|
-
|
|
96
|
-
- **Type**: `number[]`
|
|
97
|
-
- **Default**: `[2, 3]`
|
|
98
|
-
- **Description**: The levels of headers to include in the TOC.
|
|
99
|
-
|
|
100
|
-
#### `slugify`
|
|
101
|
-
|
|
102
|
-
- **Type**: `function`
|
|
103
|
-
- **Default**: `defaultSlugify`
|
|
104
|
-
- **Description**: A custom function to generate slugs for the headers.
|
|
105
|
-
|
|
106
|
-
#### `format`
|
|
107
|
-
|
|
108
|
-
- **Type**: `function`
|
|
109
|
-
- **Description**: A custom function to format the header titles.
|
|
110
|
-
|
|
111
|
-
### Example Configuration
|
|
112
|
-
|
|
113
|
-
Here is an example of how you can configure the `headers` plugin with custom options:
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
import MarkdownIt from 'markdown-it'
|
|
117
|
-
import { headersPlugin } from '@md-plugins/md-plugin-headers'
|
|
118
|
-
import { slugify as customSlugify } from './custom-slugify'
|
|
119
|
-
|
|
120
|
-
const md = new MarkdownIt()
|
|
121
|
-
|
|
122
|
-
md.use(headersPlugin, {
|
|
123
|
-
level: [2, 3, 4],
|
|
124
|
-
slugify: customSlugify,
|
|
125
|
-
format: (str) => str.toUpperCase(),
|
|
126
|
-
})
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Using the TOC
|
|
130
|
-
|
|
131
|
-
Once the TOC is generated, it is stored in the `env` object. How you handle this data and send it to the front-end is up to you. Here is an example of how to use the TOC in a Vue component:
|
|
132
|
-
|
|
133
|
-
```vue
|
|
134
|
-
<template>
|
|
135
|
-
<div>
|
|
136
|
-
<h1>Table of Contents</h1>
|
|
137
|
-
<ul>
|
|
138
|
-
<li v-for="item in toc" :key="item.id">
|
|
139
|
-
<a :href="'#' + item.id">{{ item.title }}</a>
|
|
140
|
-
<ul v-if="item.sub">
|
|
141
|
-
<li v-for="subItem in item.sub" :key="subItem.id">
|
|
142
|
-
<a :href="'#' + subItem.id">{{ subItem.title }}</a>
|
|
143
|
-
</li>
|
|
144
|
-
</ul>
|
|
145
|
-
</li>
|
|
146
|
-
</ul>
|
|
147
|
-
</div>
|
|
148
|
-
</template>
|
|
149
|
-
|
|
150
|
-
<script setup>
|
|
151
|
-
import { ref } from 'vue'
|
|
152
|
-
|
|
153
|
-
const toc = ref([
|
|
154
|
-
{ id: 'introduction', title: 'Introduction' },
|
|
155
|
-
{ id: 'details', title: 'Details', sub: [{ id: 'subsection', title: 'Subsection' }] },
|
|
156
|
-
{ id: 'conclusion', title: 'Conclusion' },
|
|
157
|
-
])
|
|
158
|
-
</script>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Default CSS
|
|
162
|
-
|
|
163
|
-
By default, the `headers` plugin applies specific CSS classes to different levels of headers. You can add these classes in your CSS to customize the appearance of headers.
|
|
164
|
-
|
|
165
|
-
```scss
|
|
166
|
-
.markdown-h1 {
|
|
167
|
-
font-size: 2.4em !important;
|
|
168
|
-
font-weight: 700;
|
|
169
|
-
margin: 0 0 1em !important;
|
|
170
|
-
display: flex;
|
|
171
|
-
align-items: center;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.markdown-h2 {
|
|
175
|
-
font-size: 1.8em !important;
|
|
176
|
-
font-weight: 600;
|
|
177
|
-
padding-bottom: 8px !important;
|
|
178
|
-
border-bottom: 1px solid $separator-color;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.markdown-h3 {
|
|
182
|
-
font-size: 1.6em !important;
|
|
183
|
-
font-weight: 500;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.markdown-h4 {
|
|
187
|
-
font-size: 1.4em !important;
|
|
188
|
-
font-weight: 500;
|
|
189
|
-
&:before {
|
|
190
|
-
content: '» ';
|
|
191
|
-
vertical-align: text-top;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.markdown-h5 {
|
|
196
|
-
font-size: 1em !important;
|
|
197
|
-
font-weight: 500;
|
|
198
|
-
&:before {
|
|
199
|
-
content: '»» ';
|
|
200
|
-
vertical-align: text-top;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.markdown-h6 {
|
|
205
|
-
font-size: 1em !important;
|
|
206
|
-
font-weight: 400;
|
|
207
|
-
&:before {
|
|
208
|
-
content: '»»» ';
|
|
209
|
-
vertical-align: text-top;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
@media (max-width: 850px) {
|
|
214
|
-
.markdown-h1 {
|
|
215
|
-
font-size: 1.7em !important;
|
|
216
|
-
}
|
|
217
|
-
.markdown-h2 {
|
|
218
|
-
font-size: 1.4em !important;
|
|
219
|
-
}
|
|
220
|
-
.markdown-h3 {
|
|
221
|
-
font-size: 1.3em !important;
|
|
222
|
-
}
|
|
223
|
-
.markdown-h4 {
|
|
224
|
-
font-size: 1.2em !important;
|
|
225
|
-
}
|
|
226
|
-
.markdown-h5 {
|
|
227
|
-
font-size: 1.1em !important;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
86
|
### Conclusion
|
|
233
87
|
|
|
234
88
|
The `headers` plugin is a powerful tool for adding custom classes to headers and generating a TOC in your Markdown content. By customizing the levels, slugify function, and format function, you can tailor the plugin to fit your specific needs. Remember, it is up to you to handle the generated TOC data and send it to the front-end in a way that suits your application. Experiment with different configurations and find the one that works best for you.
|
|
@@ -82,6 +82,8 @@ md.use(headersPlugin, {
|
|
|
82
82
|
slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Optional: Customize slugification
|
|
83
83
|
format: (str) => str.toUpperCase(), // Optional: Customize header formatting
|
|
84
84
|
shouldAllowNested: true, // Optional: Allow headers inside nested blocks
|
|
85
|
+
shouldAllowApi = true, // Optional: Allow headers from api title
|
|
86
|
+
shouldAllowExample = true, // Optional: Allow headers from example title
|
|
85
87
|
})
|
|
86
88
|
|
|
87
89
|
// Now you can use the Headers plugin in your Markdown content
|
|
@@ -98,6 +100,8 @@ The Headers plugin accepts the following options:
|
|
|
98
100
|
- **level**: Heading levels to be extracted. Should be a subset of markdown-it-anchor's level option to ensure the slug exists. Default is `[2, 3]`.
|
|
99
101
|
|
|
100
102
|
- **shouldAllowNested**: Should allow headers inside nested blocks or not. Default is `false`.
|
|
103
|
+
- **shouldAllowApi**: Should allow headers from api title or not. Default is `true`.
|
|
104
|
+
- **shouldAllowExample**: Should allow headers from example title or not. Default is `true`.
|
|
101
105
|
|
|
102
106
|
## Advanced Configuration
|
|
103
107
|
|
|
@@ -116,6 +120,8 @@ md.use(headersPlugin, {
|
|
|
116
120
|
slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Customize slugification
|
|
117
121
|
format: (str) => str.toUpperCase(), // Customize header formatting
|
|
118
122
|
shouldAllowNested: true, // Allow headers inside nested blocks
|
|
123
|
+
shouldAllowApi = true, // Optional: Allow headers from api blocks
|
|
124
|
+
shouldAllowExample = true, // Optional: Allow headers from example blocks
|
|
119
125
|
})
|
|
120
126
|
.use(markdownItAnchor)
|
|
121
127
|
.use(markdownItToc)
|
|
@@ -101,7 +101,7 @@ Import Q-Press styles:
|
|
|
101
101
|
```ts [maxheight=400px]
|
|
102
102
|
import { defineConfig } from '#q-app/wrappers'
|
|
103
103
|
import type { Plugin } from 'vite'
|
|
104
|
-
import { viteMdPlugin, type MenuItem } from '@md-plugins/vite-md-plugin'
|
|
104
|
+
import { viteMdPlugin, type MenuItem, type MarkdownOptions } from '@md-plugins/vite-md-plugin'
|
|
105
105
|
|
|
106
106
|
export default defineConfig(async (ctx) => {
|
|
107
107
|
// Dynamically import siteConfig
|
|
@@ -117,6 +117,7 @@ export default defineConfig(async (ctx) => {
|
|
|
117
117
|
{
|
|
118
118
|
path: ctx.appPaths.srcDir + '/markdown',
|
|
119
119
|
menu: sidebar as MenuItem[],
|
|
120
|
+
// options: myOptions as MarkdownOptions
|
|
120
121
|
},
|
|
121
122
|
],
|
|
122
123
|
// other plugins...
|
|
@@ -11,6 +11,30 @@ The `viteMdPlugin` is a powerful tool for integrating Markdown processing into y
|
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
import { Plugin } from 'vite'
|
|
14
|
+
import { Options } from 'markdown-it'
|
|
15
|
+
import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote'
|
|
16
|
+
import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks'
|
|
17
|
+
import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter'
|
|
18
|
+
import { HeadersPluginOptions } from '@md-plugins/md-plugin-headers'
|
|
19
|
+
import { ImagePluginOptions } from '@md-plugins/md-plugin-image'
|
|
20
|
+
import { InlineCodePluginOptions } from '@md-plugins/md-plugin-inlinecode'
|
|
21
|
+
import { LinkPluginOptions } from '@md-plugins/md-plugin-link'
|
|
22
|
+
import { TablePluginOptions } from '@md-plugins/md-plugin-table'
|
|
23
|
+
|
|
24
|
+
interface MarkdownOptions extends Options {
|
|
25
|
+
html?: boolean
|
|
26
|
+
linkify?: boolean
|
|
27
|
+
typographer?: boolean
|
|
28
|
+
breaks?: boolean
|
|
29
|
+
blockquote?: BlockquotePluginOptions
|
|
30
|
+
codeblocks?: CodeblockPluginOptions
|
|
31
|
+
frontmatter?: FrontmatterPluginOptions
|
|
32
|
+
headers?: HeadersPluginOptions | boolean
|
|
33
|
+
image?: ImagePluginOptions
|
|
34
|
+
inlinecode?: InlineCodePluginOptions
|
|
35
|
+
link?: LinkPluginOptions
|
|
36
|
+
table?: TablePluginOptions
|
|
37
|
+
}
|
|
14
38
|
|
|
15
39
|
interface MenuItem {
|
|
16
40
|
name: string
|
|
@@ -24,12 +48,14 @@ interface MenuItem {
|
|
|
24
48
|
external?: boolean
|
|
25
49
|
expanded?: boolean
|
|
26
50
|
}
|
|
51
|
+
|
|
27
52
|
interface MenuNode {
|
|
28
53
|
name: string
|
|
29
54
|
path?: string
|
|
30
55
|
external?: boolean
|
|
31
56
|
children?: MenuNode[]
|
|
32
57
|
}
|
|
58
|
+
|
|
33
59
|
interface FlatMenuEntry {
|
|
34
60
|
name: string
|
|
35
61
|
category: string | null
|
|
@@ -37,18 +63,23 @@ interface FlatMenuEntry {
|
|
|
37
63
|
prev?: FlatMenuEntry
|
|
38
64
|
next?: FlatMenuEntry
|
|
39
65
|
}
|
|
66
|
+
|
|
40
67
|
type FlatMenu = Record<string, FlatMenuEntry>
|
|
68
|
+
|
|
41
69
|
interface NavItem extends FlatMenuEntry {
|
|
42
70
|
classes: string
|
|
43
71
|
}
|
|
72
|
+
|
|
44
73
|
interface RelatedItem {
|
|
45
74
|
name: string
|
|
46
75
|
category: string
|
|
47
76
|
path: string
|
|
48
77
|
}
|
|
78
|
+
|
|
49
79
|
interface UserConfig {
|
|
50
80
|
path: string
|
|
51
81
|
menu: MenuItem[]
|
|
82
|
+
config?: MarkdownOptions
|
|
52
83
|
}
|
|
53
84
|
|
|
54
85
|
/**
|
|
@@ -58,6 +89,7 @@ interface UserConfig {
|
|
|
58
89
|
* @param userConfig - The configuration object for the Vite Markdown plugin.
|
|
59
90
|
* @param userConfig.path - The base path prefix to be used for routing or file resolution.
|
|
60
91
|
* @param userConfig.menu - An array of MenuItem objects representing the navigation menu structure.
|
|
92
|
+
* @param userConfig.config - Additional configuration options for the Markdown processing.
|
|
61
93
|
* @returns A Vite Plugin object pre-configured with the provided settings for Markdown processing.
|
|
62
94
|
*/
|
|
63
95
|
declare function viteMdPlugin(userConfig: UserConfig): Plugin
|
|
@@ -65,6 +97,7 @@ declare function viteMdPlugin(userConfig: UserConfig): Plugin
|
|
|
65
97
|
export {
|
|
66
98
|
type FlatMenu,
|
|
67
99
|
type FlatMenuEntry,
|
|
100
|
+
type MarkdownOptions,
|
|
68
101
|
type MenuItem,
|
|
69
102
|
type MenuNode,
|
|
70
103
|
type NavItem,
|
|
@@ -102,7 +135,7 @@ If you’re using the Quasar Framework with Vite, additional configuration is ne
|
|
|
102
135
|
1. Update `quasar.config.(js|ts)`:
|
|
103
136
|
|
|
104
137
|
```typescript
|
|
105
|
-
import { viteMdPlugin } from '@md-plugins/vite-md-plugin'
|
|
138
|
+
import { viteMdPlugin, type MenuItem, type MarkdownOptions } from '@md-plugins/vite-md-plugin'
|
|
106
139
|
import { menu } from './src/assets/menu'; // be sure to create this file
|
|
107
140
|
|
|
108
141
|
export default defineConfig((ctx) => {
|
|
@@ -120,6 +153,7 @@ export default defineConfig((ctx) => {
|
|
|
120
153
|
{
|
|
121
154
|
path: ctx.appPaths.srcDir + '/markdown',
|
|
122
155
|
menu: sidebar as MenuItem[],
|
|
156
|
+
// options: myOptions as MarkdownOptions
|
|
123
157
|
},
|
|
124
158
|
],
|
|
125
159
|
// ...
|
|
@@ -176,6 +210,38 @@ export interface MenuItem {
|
|
|
176
210
|
}
|
|
177
211
|
```
|
|
178
212
|
|
|
213
|
+
#### `config`
|
|
214
|
+
|
|
215
|
+
- **Type**: `MarkdownOptions`
|
|
216
|
+
- **Description**: Additional configuration options for the Markdown processing.
|
|
217
|
+
|
|
218
|
+
````ts
|
|
219
|
+
import { Options } from 'markdown-it';
|
|
220
|
+
import { BlockquotePluginOptions } from '@md-plugins/md-plugin-blockquote';
|
|
221
|
+
import { CodeblockPluginOptions } from '@md-plugins/md-plugin-codeblocks';
|
|
222
|
+
import { FrontmatterPluginOptions } from '@md-plugins/md-plugin-frontmatter';
|
|
223
|
+
import { HeadersPluginOptions } from '@md-plugins/md-plugin-headers';
|
|
224
|
+
import { ImagePluginOptions } from '@md-plugins/md-plugin-image';
|
|
225
|
+
import { InlineCodePluginOptions } from '@md-plugins/md-plugin-inlinecode';
|
|
226
|
+
import { LinkPluginOptions } from '@md-plugins/md-plugin-link';
|
|
227
|
+
import { TablePluginOptions } from '@md-plugins/md-plugin-table';
|
|
228
|
+
|
|
229
|
+
interface MarkdownOptions extends Options {
|
|
230
|
+
html?: boolean;
|
|
231
|
+
linkify?: boolean;
|
|
232
|
+
typographer?: boolean;
|
|
233
|
+
breaks?: boolean;
|
|
234
|
+
blockquote?: BlockquotePluginOptions;
|
|
235
|
+
codeblocks?: CodeblockPluginOptions;
|
|
236
|
+
frontmatter?: FrontmatterPluginOptions;
|
|
237
|
+
headers?: HeadersPluginOptions | boolean;
|
|
238
|
+
image?: ImagePluginOptions;
|
|
239
|
+
inlinecode?: InlineCodePluginOptions;
|
|
240
|
+
link?: LinkPluginOptions;
|
|
241
|
+
table?: TablePluginOptions;
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
179
245
|
### Example Configuration
|
|
180
246
|
|
|
181
247
|
Here is an example of how you can configure the `viteMdPlugin` with custom options:
|
|
@@ -195,7 +261,7 @@ const basePath = '/docs'
|
|
|
195
261
|
export default defineConfig({
|
|
196
262
|
plugins: [vue(), viteMdPlugin(basePath, menu)],
|
|
197
263
|
})
|
|
198
|
-
|
|
264
|
+
````
|
|
199
265
|
|
|
200
266
|
### Using the Plugin
|
|
201
267
|
|
|
@@ -217,7 +283,7 @@ When you build your project, the `viteMdPlugin` will process this Markdown file
|
|
|
217
283
|
|
|
218
284
|
## Advanced
|
|
219
285
|
|
|
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.
|
|
286
|
+
If you need to change the behavior of `viteMdPlugin`, you can make behavioral changes via the `MarkdownOptions`, or you can create your own Vite plugin and use that instead. Look at the source to see how it can be done.
|
|
221
287
|
|
|
222
288
|
## Conclusion
|
|
223
289
|
|