@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,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Frontmatter Plugin
|
|
3
|
+
desc: Frontmatter plugin for Markdown.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Welcome to the Frontmatter Plugin documentation! This guide will provide you with an overview of the Frontmatter plugin and its features.
|
|
7
|
+
|
|
8
|
+
## What is the Frontmatter Plugin?
|
|
9
|
+
|
|
10
|
+
The Frontmatter Plugin is a powerful tool that enhances the standard Markdown functionality by allowing you to extract and process frontmatter and excerpts. It integrates seamlessly with Markdown-It to provide a flexible and customizable way to handle frontmatter in your Markdown files.
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **Frontmatter Extraction**: Extract frontmatter data from your Markdown files.
|
|
15
|
+
- **Excerpt Rendering**: Optionally render excerpts from the frontmatter.
|
|
16
|
+
- **Customizable Options**: Use custom options for the gray-matter library.
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
|
|
20
|
+
Here are some examples of what you can achieve with the Frontmatter Plugin:
|
|
21
|
+
|
|
22
|
+
### Standard Frontmatter
|
|
23
|
+
|
|
24
|
+
```markup
|
|
25
|
+
---
|
|
26
|
+
title: My Document
|
|
27
|
+
author: John Doe
|
|
28
|
+
date: 2023-10-01
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# My Document
|
|
32
|
+
|
|
33
|
+
This is the content of my document.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Frontmatter with Excerpt
|
|
37
|
+
|
|
38
|
+
```markup
|
|
39
|
+
---
|
|
40
|
+
title: My Document
|
|
41
|
+
author: John Doe
|
|
42
|
+
date: 2023-10-01
|
|
43
|
+
excerpt: This is a short summary of my document.
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
# My Document
|
|
47
|
+
|
|
48
|
+
This is the content of my document.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Name
|
|
52
|
+
|
|
53
|
+
The official NPM name is `@md-plugins/md-plugin-frontmatter`.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
You can install the Frontmatter plugin using npm, yarn, or pnpm. Choose your preferred method below:
|
|
58
|
+
|
|
59
|
+
```tabs
|
|
60
|
+
<<| bash npm |>>
|
|
61
|
+
npm install @md-plugins/md-plugin-frontmatter
|
|
62
|
+
<<| bash yarn |>>
|
|
63
|
+
yarn add @md-plugins/md-plugin-frontmatter
|
|
64
|
+
<<| bash pnpm |>>
|
|
65
|
+
pnpm add @md-plugins/md-plugin-frontmatter
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
After installing the plugin, you need to configure it in your Markdown-It setup. Here's an example of how to do that:
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
import MarkdownIt from 'markdown-it'
|
|
74
|
+
import { frontmatterPlugin } from '@md-plugins/md-plugin-frontmatter'
|
|
75
|
+
|
|
76
|
+
const md = new MarkdownIt()
|
|
77
|
+
|
|
78
|
+
md.use(frontmatterPlugin, {
|
|
79
|
+
grayMatterOptions: {
|
|
80
|
+
excerpt: true, // Enable excerpt extraction
|
|
81
|
+
},
|
|
82
|
+
renderExcerpt: true, // Optional: Render the excerpt
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
// Now you can use the Frontmatter plugin in your Markdown content
|
|
86
|
+
const result = md.render(
|
|
87
|
+
'---\ntitle: My Document\nauthor: John Doe\ndate: 2023-10-01\nexcerpt: This is a short summary of my document.\n---\n\n# My Document\n\nThis is the content of my document.',
|
|
88
|
+
)
|
|
89
|
+
console.log(result)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Options
|
|
93
|
+
|
|
94
|
+
The Frontmatter plugin accepts the following options:
|
|
95
|
+
|
|
96
|
+
- **grayMatterOptions**: Options for the gray-matter library. See [gray-matter options](https://github.com/jonschlinkert/gray-matter#options) for more details.
|
|
97
|
+
- **renderExcerpt**: Render the excerpt or not. Default is `true`.
|
|
98
|
+
|
|
99
|
+
## Advanced Configuration
|
|
100
|
+
|
|
101
|
+
For more advanced configurations, you can combine the Frontmatter plugin with other Markdown-It plugins to enhance your Markdown content further. Here's an example:
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
import MarkdownIt from 'markdown-it'
|
|
105
|
+
import { frontmatterPlugin } from '@md-plugins/md-plugin-frontmatter'
|
|
106
|
+
import markdownItAnchor from 'markdown-it-anchor'
|
|
107
|
+
import markdownItToc from 'markdown-it-toc-done-right'
|
|
108
|
+
|
|
109
|
+
const md = new MarkdownIt()
|
|
110
|
+
|
|
111
|
+
md.use(frontmatterPlugin, {
|
|
112
|
+
grayMatterOptions: {
|
|
113
|
+
excerpt: true, // Enable excerpt extraction
|
|
114
|
+
},
|
|
115
|
+
renderExcerpt: true, // Render the excerpt
|
|
116
|
+
})
|
|
117
|
+
.use(markdownItAnchor)
|
|
118
|
+
.use(markdownItToc)
|
|
119
|
+
|
|
120
|
+
// Now you can use the Frontmatter plugin along with other plugins in your Markdown content
|
|
121
|
+
const result = md.render(
|
|
122
|
+
'---\ntitle: My Document\nauthor: John Doe\ndate: 2023-10-01\nexcerpt: This is a short summary of my document.\n---\n\n# Table of Contents\n\n[[toc]]\n\n# My Document\n\nThis is the content of my document.',
|
|
123
|
+
)
|
|
124
|
+
console.log(result)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Support
|
|
128
|
+
|
|
129
|
+
If you have any questions or need assistance, please refer to the FAQ or reach out to our support team.
|
|
130
|
+
|
|
131
|
+
Happy coding!
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Headers Plugin Advanced Topics
|
|
3
|
+
desc: Headers plugin advanced topics for Markdown.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Headers Plugin
|
|
7
|
+
|
|
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
|
+
|
|
10
|
+
### Type Infformation
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { PluginWithOptions } from 'markdown-it'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options of md-plugin-headers
|
|
17
|
+
*/
|
|
18
|
+
interface HeadersPluginOptions {
|
|
19
|
+
/**
|
|
20
|
+
* A custom slugification function
|
|
21
|
+
*
|
|
22
|
+
* Should use the same slugify function with markdown-it-anchor
|
|
23
|
+
* to ensure the link is matched
|
|
24
|
+
*/
|
|
25
|
+
slugify?: (str: string) => string
|
|
26
|
+
/**
|
|
27
|
+
* A function for formatting header title
|
|
28
|
+
*/
|
|
29
|
+
format?: (str: string) => string
|
|
30
|
+
/**
|
|
31
|
+
* Heading level that going to be extracted
|
|
32
|
+
*
|
|
33
|
+
* Should be a subset of markdown-it-anchor's `level` option
|
|
34
|
+
* to ensure the slug is existed
|
|
35
|
+
*
|
|
36
|
+
* @default [2,3]
|
|
37
|
+
*/
|
|
38
|
+
level?: number[]
|
|
39
|
+
/**
|
|
40
|
+
* Should allow headers inside nested blocks or not
|
|
41
|
+
*
|
|
42
|
+
* If set to `true`, headers inside blockquote, list, etc. would also be extracted.
|
|
43
|
+
*
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
shouldAllowNested?: boolean
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface TocItem {
|
|
50
|
+
id: string
|
|
51
|
+
title: string
|
|
52
|
+
sub?: boolean
|
|
53
|
+
deep?: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare module '@md-plugins/shared' {
|
|
57
|
+
interface MarkdownItEnv {
|
|
58
|
+
/**
|
|
59
|
+
* The toc that are extracted by `md-plugin-headers`
|
|
60
|
+
*/
|
|
61
|
+
toc?: TocItem[]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare const headersPlugin: PluginWithOptions<HeadersPluginOptions>
|
|
66
|
+
|
|
67
|
+
export { type HeadersPluginOptions, type TocItem, headersPlugin }
|
|
68
|
+
```
|
|
69
|
+
|
|
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;
|
|
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;
|
|
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;
|
|
183
|
+
font-weight: 500;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.markdown-h4 {
|
|
187
|
+
font-size: 1.4em;
|
|
188
|
+
font-weight: 500;
|
|
189
|
+
&:before {
|
|
190
|
+
content: '» ';
|
|
191
|
+
vertical-align: text-top;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.markdown-h5 {
|
|
196
|
+
font-size: 1em;
|
|
197
|
+
font-weight: 500;
|
|
198
|
+
&:before {
|
|
199
|
+
content: '»» ';
|
|
200
|
+
vertical-align: text-top;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.markdown-h6 {
|
|
205
|
+
font-size: 1em;
|
|
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;
|
|
216
|
+
}
|
|
217
|
+
.markdown-h2 {
|
|
218
|
+
font-size: 1.4em;
|
|
219
|
+
}
|
|
220
|
+
.markdown-h3 {
|
|
221
|
+
font-size: 1.3em;
|
|
222
|
+
}
|
|
223
|
+
.markdown-h4 {
|
|
224
|
+
font-size: 1.2em;
|
|
225
|
+
}
|
|
226
|
+
.markdown-h5 {
|
|
227
|
+
font-size: 1.1em;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Conclusion
|
|
233
|
+
|
|
234
|
+
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.
|
|
235
|
+
|
|
236
|
+
Happy coding!
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Headers Plugin
|
|
3
|
+
desc: Headers plugin for Markdown.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Welcome to the Headers Plugin documentation! This guide will provide you with an overview of the Headers plugin and its features.
|
|
7
|
+
|
|
8
|
+
## What is the Headers Plugin?
|
|
9
|
+
|
|
10
|
+
The Headers Plugin is a powerful tool that enhances the standard header functionality in Markdown. It allows you to extract and format headers, making it easier to create a table of contents and navigate through your documentation.
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- **Custom Slugification**: Use a custom slugification function to generate unique IDs for headers.
|
|
15
|
+
- **Header Formatting**: Apply custom formatting to header titles.
|
|
16
|
+
- **Heading Levels**: Specify which heading levels to extract.
|
|
17
|
+
- **Nested Headers**: Optionally allow headers inside nested blocks to be extracted.
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
Here are some examples of what you can achieve with the Headers Plugin:
|
|
22
|
+
|
|
23
|
+
### Standard Header Extraction
|
|
24
|
+
|
|
25
|
+
```markup
|
|
26
|
+
# Main Title
|
|
27
|
+
|
|
28
|
+
## Sub Title
|
|
29
|
+
|
|
30
|
+
### Another Sub Title
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Custom Slugification and Formatting
|
|
34
|
+
|
|
35
|
+
You can apply custom slugification and formatting to headers:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import MarkdownIt from 'markdown-it'
|
|
39
|
+
import { headersPlugin } from '@md-plugins/md-plugin-headers'
|
|
40
|
+
|
|
41
|
+
const md = new MarkdownIt()
|
|
42
|
+
|
|
43
|
+
md.use(headersPlugin, {
|
|
44
|
+
slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Custom slugification
|
|
45
|
+
format: (str) => str.toUpperCase(), // Custom formatting
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Now you can use the Headers plugin in your Markdown content
|
|
49
|
+
const result = md.render('# Custom Header\n\n## Another Header')
|
|
50
|
+
console.log(result)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Name
|
|
54
|
+
|
|
55
|
+
The official NPM name is `@md-plugins/md-plugin-headers`.
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
You can install the Headers plugin using npm, yarn, or pnpm. Choose your preferred method below:
|
|
60
|
+
|
|
61
|
+
```tabs
|
|
62
|
+
<<| bash npm |>>
|
|
63
|
+
npm install @md-plugins/md-plugin-headers
|
|
64
|
+
<<| bash yarn |>>
|
|
65
|
+
yarn add @md-plugins/md-plugin-headers
|
|
66
|
+
<<| bash pnpm |>>
|
|
67
|
+
pnpm add @md-plugins/md-plugin-headers
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
After installing the plugin, you need to configure it in your Markdown-It setup. Here's an example of how to do that:
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import MarkdownIt from 'markdown-it'
|
|
76
|
+
import { headersPlugin } from '@md-plugins/md-plugin-headers'
|
|
77
|
+
|
|
78
|
+
const md = new MarkdownIt()
|
|
79
|
+
|
|
80
|
+
md.use(headersPlugin, {
|
|
81
|
+
level: [2, 3], // Optional: Specify which heading levels to extract
|
|
82
|
+
slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Optional: Customize slugification
|
|
83
|
+
format: (str) => str.toUpperCase(), // Optional: Customize header formatting
|
|
84
|
+
shouldAllowNested: true, // Optional: Allow headers inside nested blocks
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
// Now you can use the Headers plugin in your Markdown content
|
|
88
|
+
const result = md.render('# Main Title\n\n## Sub Title\n\n### Another Sub Title')
|
|
89
|
+
console.log(result)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Options
|
|
93
|
+
|
|
94
|
+
The Headers plugin accepts the following options:
|
|
95
|
+
|
|
96
|
+
- **slugify**: A custom slugification function. Should use the same slugify function with markdown-it-anchor to ensure the link is matched.
|
|
97
|
+
- **format**: A function for formatting header titles.
|
|
98
|
+
- **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
|
+
|
|
100
|
+
- **shouldAllowNested**: Should allow headers inside nested blocks or not. Default is `false`.
|
|
101
|
+
|
|
102
|
+
## Advanced Configuration
|
|
103
|
+
|
|
104
|
+
For more advanced configurations, you can combine the Headers plugin with other Markdown-It plugins to enhance your Markdown content further. Here's an example:
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
import MarkdownIt from 'markdown-it'
|
|
108
|
+
import { headersPlugin } from '@md-plugins/md-plugin-headers'
|
|
109
|
+
import markdownItAnchor from 'markdown-it-anchor'
|
|
110
|
+
import markdownItToc from 'markdown-it-toc-done-right'
|
|
111
|
+
|
|
112
|
+
const md = new MarkdownIt()
|
|
113
|
+
|
|
114
|
+
md.use(headersPlugin, {
|
|
115
|
+
level: [2, 3], // Specify which heading levels to extract
|
|
116
|
+
slugify: (str) => str.toLowerCase().replace(/\s+/g, '-'), // Customize slugification
|
|
117
|
+
format: (str) => str.toUpperCase(), // Customize header formatting
|
|
118
|
+
shouldAllowNested: true, // Allow headers inside nested blocks
|
|
119
|
+
})
|
|
120
|
+
.use(markdownItAnchor)
|
|
121
|
+
.use(markdownItToc)
|
|
122
|
+
|
|
123
|
+
// Now you can use the Headers plugin along with other plugins in your Markdown content
|
|
124
|
+
const result = md.render(
|
|
125
|
+
'# Table of Contents\n\n[[toc]]\n\n# Main Title\n\n## Sub Title\n\n### Another Sub Title',
|
|
126
|
+
)
|
|
127
|
+
console.log(result)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Support
|
|
131
|
+
|
|
132
|
+
If you have any questions or need assistance, please refer to the FAQ or reach out to our support team.
|
|
133
|
+
|
|
134
|
+
Happy coding!
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Image Plugin Advanced Topics
|
|
3
|
+
desc: Image plugin advanced topics for Markdown.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Image Plugin
|
|
7
|
+
|
|
8
|
+
The `image` plugin allows you to add custom classes to images and ensure that the `alt` attribute is properly set in your Markdown content. It also allows you to provide a `width` and a `height`. This section will cover how the plugin works, the available options for customization, and examples of how to use it effectively.
|
|
9
|
+
|
|
10
|
+
### Type Information
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import MarkdownIt from 'markdown-it'
|
|
14
|
+
|
|
15
|
+
declare const imagePlugin: (
|
|
16
|
+
md: MarkdownIt,
|
|
17
|
+
{
|
|
18
|
+
imageClass,
|
|
19
|
+
}?: {
|
|
20
|
+
imageClass?: string | undefined
|
|
21
|
+
},
|
|
22
|
+
) => void
|
|
23
|
+
|
|
24
|
+
interface ImagePluginOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The class for the image
|
|
27
|
+
*
|
|
28
|
+
* @default 'markdown-image'
|
|
29
|
+
*/
|
|
30
|
+
imageClass?: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { type ImagePluginOptions, imagePlugin }
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### How It Works
|
|
37
|
+
|
|
38
|
+
The `image` plugin processes image tokens in your Markdown content, adding custom classes and ensuring that the `alt` attribute is properly set as well as setting the `width` and `height` attributes if set inside the `alt text` area of the image markdown. This helps improve the accessibility and styling of images in your Markdown content.
|
|
39
|
+
|
|
40
|
+
### Default Behavior
|
|
41
|
+
|
|
42
|
+
By default, the `image` plugin adds the `markdown-image` class to all images and sets the `alt` attribute to the image's content if it is not already set. It also allows you to specify the `width` and `height` of the displayed image. Here is an example of a Markdown file with images:
|
|
43
|
+
|
|
44
|
+
```markdown
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Plugin Options
|
|
53
|
+
|
|
54
|
+
The `image` plugin provides an option for customization. Here is the available option and its description:
|
|
55
|
+
|
|
56
|
+
#### imageClass
|
|
57
|
+
|
|
58
|
+
- **Type**: `string`
|
|
59
|
+
- **Default**: `'markdown-image'`
|
|
60
|
+
- **Description**: The class to be added to all images.
|
|
61
|
+
|
|
62
|
+
### Example Configuration
|
|
63
|
+
|
|
64
|
+
Here is an example of how you can configure the `image` plugin with custom options:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import MarkdownIt from 'markdown-it'
|
|
68
|
+
import { imagePlugin } from '@md-plugins/md-plugin-image'
|
|
69
|
+
|
|
70
|
+
const md = new MarkdownIt()
|
|
71
|
+
|
|
72
|
+
md.use(imagePlugin, {
|
|
73
|
+
imageClass: 'custom-image-class',
|
|
74
|
+
})
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Customizing the CSS
|
|
78
|
+
|
|
79
|
+
You can customize the appearance of images by overriding the default CSS class. Here are some examples of how you can customize the images:
|
|
80
|
+
|
|
81
|
+
#### Example 1: Customizing the Border
|
|
82
|
+
|
|
83
|
+
```css
|
|
84
|
+
.custom-image-class {
|
|
85
|
+
border: 2px solid #3498db; /* Add a blue border to images */
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Example 2: Adding a Shadow
|
|
90
|
+
|
|
91
|
+
```css
|
|
92
|
+
.custom-image-class {
|
|
93
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Add a shadow to images */
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Example 3: Changing the Size
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
.custom-image-class {
|
|
101
|
+
width: 100%;
|
|
102
|
+
max-width: 600px; /* Set a maximum width for images */
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Handling the `alt`, `width`, and `height` Attributes
|
|
107
|
+
|
|
108
|
+
The `image` plugin ensures that the `alt` attribute is properly set for all images. If the `alt` attribute is not present or is empty, the plugin sets it to the image's content. Additionally, the plugin allows you to specify the `width` and `height` attributes within the `alt` text. These attributes are extracted and applied to the image element, and then removed from the `alt` text. This helps improve the accessibility and styling of your Markdown content.
|
|
109
|
+
|
|
110
|
+
### Conclusion
|
|
111
|
+
|
|
112
|
+
The `image` plugin is a powerful tool for adding custom classes to images and ensuring that the `alt`, `width`, and `height` attributes are properly set in your Markdown content. By customizing the class and CSS, you can tailor the appearance of images to match the style of your project. Experiment with different configurations and find the one that works best for you.
|
|
113
|
+
|
|
114
|
+
Happy coding!
|