@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.
Files changed (200) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +230 -0
  3. package/old/prompts.js +44 -0
  4. package/old/uninstall.js +9 -0
  5. package/package.json +60 -0
  6. package/scripts/build.js +33 -0
  7. package/src/index.js +63 -0
  8. package/src/install.js +49 -0
  9. package/src/templates/.gitkeep +0 -0
  10. package/src/templates/init/src/_q-press/.gitkeep +0 -0
  11. package/src/templates/init/src/_q-press/api/components/DarkModeToggle.json +37 -0
  12. package/src/templates/init/src/_q-press/api/components/MarkdownApi.json +67 -0
  13. package/src/templates/init/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
  14. package/src/templates/init/src/_q-press/api/components/MarkdownCardLink.json +28 -0
  15. package/src/templates/init/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
  16. package/src/templates/init/src/_q-press/api/components/MarkdownCode.json +37 -0
  17. package/src/templates/init/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
  18. package/src/templates/init/src/_q-press/api/components/MarkdownCodepen.json +21 -0
  19. package/src/templates/init/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
  20. package/src/templates/init/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
  21. package/src/templates/init/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
  22. package/src/templates/init/src/_q-press/api/components/MarkdownExample.json +22 -0
  23. package/src/templates/init/src/_q-press/api/components/MarkdownHeader.json +28 -0
  24. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
  25. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
  26. package/src/templates/init/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
  27. package/src/templates/init/src/_q-press/api/components/MarkdownInstallation.json +33 -0
  28. package/src/templates/init/src/_q-press/api/components/MarkdownLayout.json +52 -0
  29. package/src/templates/init/src/_q-press/api/components/MarkdownLink.json +23 -0
  30. package/src/templates/init/src/_q-press/api/components/MarkdownPage.json +71 -0
  31. package/src/templates/init/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
  32. package/src/templates/init/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
  33. package/src/templates/init/src/_q-press/api/components/MarkdownPageToc.json +17 -0
  34. package/src/templates/init/src/_q-press/api/components/MarkdownPrerender.json +25 -0
  35. package/src/templates/init/src/_q-press/api/components/MarkdownTree.json +27 -0
  36. package/src/templates/init/src/_q-press/api/composables/dark.json +29 -0
  37. package/src/templates/init/src/_q-press/api/composables/scroll.json +34 -0
  38. package/src/templates/init/src/_q-press/assets/get-meta.ts +29 -0
  39. package/src/templates/init/src/_q-press/components/DarkModeToggle.vue +105 -0
  40. package/src/templates/init/src/_q-press/components/MarkdownApi.vue +588 -0
  41. package/src/templates/init/src/_q-press/components/MarkdownApiEntry.ts +594 -0
  42. package/src/templates/init/src/_q-press/components/MarkdownCardLink.vue +25 -0
  43. package/src/templates/init/src/_q-press/components/MarkdownCardTitle.vue +21 -0
  44. package/src/templates/init/src/_q-press/components/MarkdownCode.vue +25 -0
  45. package/src/templates/init/src/_q-press/components/MarkdownCodePrism.ts +36 -0
  46. package/src/templates/init/src/_q-press/components/MarkdownCodepen.vue +183 -0
  47. package/src/templates/init/src/_q-press/components/MarkdownCopyButton.vue +104 -0
  48. package/src/templates/init/src/_q-press/components/MarkdownExample.vue +221 -0
  49. package/src/templates/init/src/_q-press/components/MarkdownInstallation.vue +166 -0
  50. package/src/templates/init/src/_q-press/components/MarkdownLink.vue +38 -0
  51. package/src/templates/init/src/_q-press/components/MarkdownPrerender.ts +82 -0
  52. package/src/templates/init/src/_q-press/components/MarkdownTree.vue +105 -0
  53. package/src/templates/init/src/_q-press/components/markdown-utils.ts +105 -0
  54. package/src/templates/init/src/_q-press/composables/dark.ts +39 -0
  55. package/src/templates/init/src/_q-press/composables/scroll.ts +115 -0
  56. package/src/templates/init/src/_q-press/css/app.scss +662 -0
  57. package/src/templates/init/src/_q-press/css/fonts.scss +100 -0
  58. package/src/templates/init/src/_q-press/css/prism-theme.scss +298 -0
  59. package/src/templates/init/src/_q-press/css/themes/default.scss +68 -0
  60. package/src/templates/init/src/_q-press/css/themes/newspaper.scss +69 -0
  61. package/src/templates/init/src/_q-press/css/themes/sunrise.scss +67 -0
  62. package/src/templates/init/src/_q-press/css/themes/tawny.scss +69 -0
  63. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
  64. package/src/templates/init/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
  65. package/src/templates/init/src/_q-press/layouts/MarkdownHeader.vue +412 -0
  66. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
  67. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
  68. package/src/templates/init/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
  69. package/src/templates/init/src/_q-press/layouts/MarkdownLayout.vue +239 -0
  70. package/src/templates/init/src/_q-press/layouts/MarkdownPage.vue +307 -0
  71. package/src/templates/init/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
  72. package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
  73. package/src/templates/init/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
  74. package/src/templates/init/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
  75. package/src/templates/init/src/_q-press/layouts/MarkdownSearch.vue +449 -0
  76. package/src/templates/init/src/_q-press/stores/markdown.ts +101 -0
  77. package/src/templates/init/src/components/LandingPage/LandingPage.vue +341 -0
  78. package/src/templates/init/src/components/Releases/PackageReleases.vue +164 -0
  79. package/src/templates/init/src/components/Releases/PublicReleases.vue +149 -0
  80. package/src/templates/init/src/components/Releases/ReleasesAvailable.vue +74 -0
  81. package/src/templates/init/src/examples/QAvatar/BasicExample.vue +11 -0
  82. package/src/templates/init/src/markdown/__elements.md +548 -0
  83. package/src/templates/init/src/markdown/__elements2.md +347 -0
  84. package/src/templates/init/src/markdown/faq/best-practices.md +0 -0
  85. package/src/templates/init/src/markdown/faq/general.md +0 -0
  86. package/src/templates/init/src/markdown/faq/troubleshooting.md +0 -0
  87. package/src/templates/init/src/markdown/getting-started/introduction.md +67 -0
  88. package/src/templates/init/src/markdown/guides/contributing.md +101 -0
  89. package/src/templates/init/src/markdown/guides/faq.md +115 -0
  90. package/src/templates/init/src/markdown/guides/release-notes.md +0 -0
  91. package/src/templates/init/src/markdown/guides/style-guide.md +0 -0
  92. package/src/templates/init/src/markdown/landing-page.md +11 -0
  93. package/src/templates/init/src/markdown/listing.ts +3 -0
  94. package/src/templates/init/src/markdown/md-plugins/blockquote/advanced.md +83 -0
  95. package/src/templates/init/src/markdown/md-plugins/blockquote/overview.md +183 -0
  96. package/src/templates/init/src/markdown/md-plugins/codeblocks/advanced.md +210 -0
  97. package/src/templates/init/src/markdown/md-plugins/codeblocks/overview.md +616 -0
  98. package/src/templates/init/src/markdown/md-plugins/containers/advanced.md +301 -0
  99. package/src/templates/init/src/markdown/md-plugins/containers/overview.md +206 -0
  100. package/src/templates/init/src/markdown/md-plugins/frontmatter/advanced.md +164 -0
  101. package/src/templates/init/src/markdown/md-plugins/frontmatter/overview.md +131 -0
  102. package/src/templates/init/src/markdown/md-plugins/headers/advanced.md +236 -0
  103. package/src/templates/init/src/markdown/md-plugins/headers/overview.md +134 -0
  104. package/src/templates/init/src/markdown/md-plugins/image/advanced.md +114 -0
  105. package/src/templates/init/src/markdown/md-plugins/image/overview.md +124 -0
  106. package/src/templates/init/src/markdown/md-plugins/imports/advanced.md +105 -0
  107. package/src/templates/init/src/markdown/md-plugins/imports/overview.md +80 -0
  108. package/src/templates/init/src/markdown/md-plugins/inline-code/advanced.md +133 -0
  109. package/src/templates/init/src/markdown/md-plugins/inline-code/overview.md +101 -0
  110. package/src/templates/init/src/markdown/md-plugins/link/advanced.md +157 -0
  111. package/src/templates/init/src/markdown/md-plugins/link/overview.md +126 -0
  112. package/src/templates/init/src/markdown/md-plugins/shared/overview.md +175 -0
  113. package/src/templates/init/src/markdown/md-plugins/table/advanced.md +190 -0
  114. package/src/templates/init/src/markdown/md-plugins/table/overview.md +186 -0
  115. package/src/templates/init/src/markdown/md-plugins/title/advanced.md +88 -0
  116. package/src/templates/init/src/markdown/md-plugins/title/overview.md +99 -0
  117. package/src/templates/init/src/markdown/other/release-notes.md +12 -0
  118. package/src/templates/init/src/markdown/privacy-policy.md +12 -0
  119. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/advanced.md +101 -0
  120. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/components.md +69 -0
  121. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/overview.md +254 -0
  122. package/src/templates/init/src/markdown/quasar-app-extensions/qpress/themes.md +4 -0
  123. package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/advanced.md +4 -0
  124. package/src/templates/init/src/markdown/quasar-app-extensions/vitemdpluginappext/overview.md +103 -0
  125. package/src/templates/init/src/markdown/vite-plugins/index.md +6 -0
  126. package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/advanced.md +138 -0
  127. package/src/templates/init/src/markdown/vite-plugins/viteexamplesplugin/overview.md +88 -0
  128. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/advanced.md +226 -0
  129. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/index.md +6 -0
  130. package/src/templates/init/src/markdown/vite-plugins/vitemdplugin/overview.md +166 -0
  131. package/src/templates/init/src/q-press.globals.d.ts +36 -0
  132. package/src/templates/init/src/siteConfig/index.ts +440 -0
  133. package/src/templates/update/src/_q-press/.gitkeep +0 -0
  134. package/src/templates/update/src/_q-press/api/components/DarkModeToggle.json +37 -0
  135. package/src/templates/update/src/_q-press/api/components/MarkdownApi.json +67 -0
  136. package/src/templates/update/src/_q-press/api/components/MarkdownApiEntry.json +76 -0
  137. package/src/templates/update/src/_q-press/api/components/MarkdownCardLink.json +28 -0
  138. package/src/templates/update/src/_q-press/api/components/MarkdownCardTitle.json +48 -0
  139. package/src/templates/update/src/_q-press/api/components/MarkdownCode.json +37 -0
  140. package/src/templates/update/src/_q-press/api/components/MarkdownCodePrism.json +29 -0
  141. package/src/templates/update/src/_q-press/api/components/MarkdownCodepen.json +21 -0
  142. package/src/templates/update/src/_q-press/api/components/MarkdownCopyButton.json +36 -0
  143. package/src/templates/update/src/_q-press/api/components/MarkdownDrawerSidebar.json +17 -0
  144. package/src/templates/update/src/_q-press/api/components/MarkdownDrawerToc.json +17 -0
  145. package/src/templates/update/src/_q-press/api/components/MarkdownExample.json +22 -0
  146. package/src/templates/update/src/_q-press/api/components/MarkdownHeader.json +28 -0
  147. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderIconLinks.json +16 -0
  148. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderMenu.json +77 -0
  149. package/src/templates/update/src/_q-press/api/components/MarkdownHeaderTextLinks.json +33 -0
  150. package/src/templates/update/src/_q-press/api/components/MarkdownInstallation.json +33 -0
  151. package/src/templates/update/src/_q-press/api/components/MarkdownLayout.json +52 -0
  152. package/src/templates/update/src/_q-press/api/components/MarkdownLink.json +23 -0
  153. package/src/templates/update/src/_q-press/api/components/MarkdownPage.json +71 -0
  154. package/src/templates/update/src/_q-press/api/components/MarkdownPageFooter.json +21 -0
  155. package/src/templates/update/src/_q-press/api/components/MarkdownPageSidebar.json +56 -0
  156. package/src/templates/update/src/_q-press/api/components/MarkdownPageToc.json +17 -0
  157. package/src/templates/update/src/_q-press/api/components/MarkdownPrerender.json +25 -0
  158. package/src/templates/update/src/_q-press/api/components/MarkdownTree.json +27 -0
  159. package/src/templates/update/src/_q-press/api/composables/dark.json +29 -0
  160. package/src/templates/update/src/_q-press/api/composables/scroll.json +34 -0
  161. package/src/templates/update/src/_q-press/assets/get-meta.ts +29 -0
  162. package/src/templates/update/src/_q-press/components/DarkModeToggle.vue +105 -0
  163. package/src/templates/update/src/_q-press/components/MarkdownApi.vue +588 -0
  164. package/src/templates/update/src/_q-press/components/MarkdownApiEntry.ts +594 -0
  165. package/src/templates/update/src/_q-press/components/MarkdownCardLink.vue +25 -0
  166. package/src/templates/update/src/_q-press/components/MarkdownCardTitle.vue +21 -0
  167. package/src/templates/update/src/_q-press/components/MarkdownCode.vue +25 -0
  168. package/src/templates/update/src/_q-press/components/MarkdownCodePrism.ts +36 -0
  169. package/src/templates/update/src/_q-press/components/MarkdownCodepen.vue +183 -0
  170. package/src/templates/update/src/_q-press/components/MarkdownCopyButton.vue +104 -0
  171. package/src/templates/update/src/_q-press/components/MarkdownExample.vue +221 -0
  172. package/src/templates/update/src/_q-press/components/MarkdownInstallation.vue +166 -0
  173. package/src/templates/update/src/_q-press/components/MarkdownLink.vue +38 -0
  174. package/src/templates/update/src/_q-press/components/MarkdownPrerender.ts +82 -0
  175. package/src/templates/update/src/_q-press/components/MarkdownTree.vue +105 -0
  176. package/src/templates/update/src/_q-press/components/markdown-utils.ts +105 -0
  177. package/src/templates/update/src/_q-press/composables/dark.ts +39 -0
  178. package/src/templates/update/src/_q-press/composables/scroll.ts +115 -0
  179. package/src/templates/update/src/_q-press/css/app.scss +662 -0
  180. package/src/templates/update/src/_q-press/css/fonts.scss +100 -0
  181. package/src/templates/update/src/_q-press/css/prism-theme.scss +298 -0
  182. package/src/templates/update/src/_q-press/css/themes/default.scss +68 -0
  183. package/src/templates/update/src/_q-press/css/themes/newspaper.scss +69 -0
  184. package/src/templates/update/src/_q-press/css/themes/sunrise.scss +67 -0
  185. package/src/templates/update/src/_q-press/css/themes/tawny.scss +69 -0
  186. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerSidebar.vue +32 -0
  187. package/src/templates/update/src/_q-press/layouts/MarkdownDrawerToc.vue +37 -0
  188. package/src/templates/update/src/_q-press/layouts/MarkdownHeader.vue +412 -0
  189. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderIconLinks.vue +31 -0
  190. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderMenu.ts +93 -0
  191. package/src/templates/update/src/_q-press/layouts/MarkdownHeaderTextLinks.vue +37 -0
  192. package/src/templates/update/src/_q-press/layouts/MarkdownLayout.vue +239 -0
  193. package/src/templates/update/src/_q-press/layouts/MarkdownPage.vue +307 -0
  194. package/src/templates/update/src/_q-press/layouts/MarkdownPageFooter.vue +187 -0
  195. package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.scss +54 -0
  196. package/src/templates/update/src/_q-press/layouts/MarkdownPageSidebar.ts +218 -0
  197. package/src/templates/update/src/_q-press/layouts/MarkdownPageToc.vue +23 -0
  198. package/src/templates/update/src/_q-press/layouts/MarkdownSearch.vue +449 -0
  199. package/src/templates/update/src/_q-press/stores/markdown.ts +101 -0
  200. package/src/templates/update/src/q-press.globals.d.ts +36 -0
@@ -0,0 +1,301 @@
1
+ ---
2
+ title: Containers Plugin Advanced Topics
3
+ desc: Containers plugin advanced topics for Markdown.
4
+ ---
5
+
6
+ ## Containers Plugin
7
+
8
+ The `containers` plugin allows you to add custom containers for callouts, warnings, and more in your Markdown content. This section will cover the CSS used by the plugin, how you can customize the output with your own CSS, and the available options for configuring the plugin.
9
+
10
+ ### Type Information
11
+
12
+ ```ts
13
+ import MarkdownIt from 'markdown-it'
14
+ import Token from 'markdown-it/lib/token.mjs'
15
+ import container from 'markdown-it-container'
16
+
17
+ type Container = typeof container
18
+
19
+ type CreateContainerFn = (
20
+ container: Container,
21
+ type: string,
22
+ defaultTitle: string,
23
+ ) => [Container, string, any?]
24
+
25
+ interface ContainerDetails {
26
+ type: string
27
+ defaultTitle: string
28
+ }
29
+
30
+ interface ContainerOptions {
31
+ render(tokens: Token[], idx: number): string
32
+ }
33
+
34
+ /**
35
+ * Adds container support to a MarkdownIt instance.
36
+ *
37
+ * This function applies custom container plugins to the MarkdownIt parser.
38
+ *
39
+ * @param md - The MarkdownIt instance to which the container plugins will be added.
40
+ * @param containers - An array of ContainerDetails objects, each specifying a container type and its default title.
41
+ * @param createContainer - A function that creates and returns the container plugin configuration.
42
+ *
43
+ * @example
44
+ * const containers: ContainerDetails[] = [
45
+ * { type: 'warning', defaultTitle: 'Warning' },
46
+ * { type: 'tip', defaultTitle: 'Tip' },
47
+ * { type: 'details', defaultTitle: 'Details' },
48
+ * ];
49
+ *
50
+ * function createContainer(
51
+ * container: Container,
52
+ * containerType: string,
53
+ * defaultTitle: string
54
+ * ): [Container, string, ContainerOptions] {
55
+ * const containerTypeLen = containerType.length;
56
+ *
57
+ * return [
58
+ * container,
59
+ * containerType,
60
+ * {
61
+ * render(tokens: Token[], idx: number): string {
62
+ * const token = tokens[idx];
63
+ * const title =
64
+ * token.info.trim().slice(containerTypeLen).trim() || defaultTitle;
65
+ *
66
+ * if (containerType === 'details') {
67
+ * return token.nesting === 1
68
+ * ? `<details class="markdown-note markdown-note--${containerType}"><summary class="markdown-note__title">${title}</summary>\n`
69
+ * : '</details>\n';
70
+ * }
71
+ *
72
+ * return token.nesting === 1
73
+ * ? `<div class="markdown-note markdown-note--${containerType}"><p class="markdown-note__title">${title}</p>\n`
74
+ * : '</div>\n';
75
+ * },
76
+ * },
77
+ * ];
78
+ * }
79
+ *
80
+ */
81
+ declare function containersPlugin(
82
+ md: MarkdownIt,
83
+ containers: ContainerDetails[],
84
+ createContainer: CreateContainerFn,
85
+ ): void
86
+
87
+ export {
88
+ type Container,
89
+ type ContainerDetails,
90
+ type ContainerOptions,
91
+ type CreateContainerFn,
92
+ containersPlugin,
93
+ }
94
+ ```
95
+
96
+ ### Default CSS
97
+
98
+ By default, the `containers` plugin applies specific CSS classes to different types of containers. You can add these classes in your CSS to customize the appearance of containers.
99
+
100
+ ::: tip
101
+ The following classes are in SCSS format.
102
+ :::
103
+
104
+ ```scss
105
+ .markdown-note {
106
+ font-size: $font-size;
107
+ border-radius: $generic-border-radius;
108
+ margin: 16px 0;
109
+ padding: 16px;
110
+ border-width: 1px;
111
+ border-style: solid;
112
+
113
+ > p,
114
+ > ul {
115
+ margin-bottom: 0;
116
+ }
117
+
118
+ &:not(.markdown-note--tip, .markdown-note--warning, .markdown-note--danger) {
119
+ background-color: $grey-2;
120
+ border-color: $separator-color;
121
+ .markdown-note__title,
122
+ .markdown-link,
123
+ .markdown-token {
124
+ color: $brand-primary;
125
+ }
126
+ .markdown-token {
127
+ border-color: $brand-primary;
128
+ }
129
+ }
130
+
131
+ &--tip {
132
+ background-color: scale-color($positive, $lightness: 85%);
133
+ border-color: $positive;
134
+ .markdown-note__title,
135
+ .markdown-link,
136
+ .markdown-token {
137
+ color: scale-color($positive, $lightness: -40%);
138
+ }
139
+ .markdown-token {
140
+ border-color: scale-color($positive, $lightness: -40%);
141
+ }
142
+ }
143
+
144
+ &--warning {
145
+ background-color: scale-color($warning, $lightness: 85%);
146
+ border-color: scale-color($warning, $lightness: -30%);
147
+ .markdown-note__title,
148
+ .markdown-link,
149
+ .markdown-token {
150
+ color: scale-color($warning, $lightness: -40%);
151
+ }
152
+ .markdown-token {
153
+ border-color: scale-color($warning, $lightness: -40%);
154
+ }
155
+ }
156
+
157
+ &--danger {
158
+ background-color: scale-color($negative, $lightness: 90%);
159
+ border-color: $negative;
160
+ .markdown-note__title,
161
+ .markdown-link,
162
+ .markdown-token {
163
+ color: $negative;
164
+ }
165
+ .markdown-token {
166
+ border-color: $negative;
167
+ }
168
+ }
169
+
170
+ &--details {
171
+ .markdown-note__title {
172
+ cursor: pointer;
173
+ display: list-item;
174
+ }
175
+
176
+ &:not([open]) > .markdown-note__title {
177
+ padding-bottom: 0;
178
+ }
179
+ }
180
+
181
+ &__title {
182
+ font-weight: 700;
183
+ letter-spacing: $letter-spacing-brand;
184
+ padding-bottom: 8px;
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### Customizing the CSS
190
+
191
+ You can customize the appearance of containers by overriding the default CSS classes. Here are some examples of how you can customize the containers:
192
+
193
+ #### Example 1: Customizing the Border Color
194
+
195
+ ```css
196
+ .markdown-note--tip {
197
+ border-color: #3498db; /* Change the border color to blue */
198
+ }
199
+ ```
200
+
201
+ #### Example 2: Adding a Background Image
202
+
203
+ ```css
204
+ .markdown-note {
205
+ background-image: url('path/to/your/image.png');
206
+ background-size: cover;
207
+ background-repeat: no-repeat;
208
+ }
209
+ ```
210
+
211
+ #### Example 3: Changing the Font Style
212
+
213
+ ```css
214
+ .markdown-note__title {
215
+ font-family: 'Courier New', Courier, monospace; /* Change the font style */
216
+ }
217
+ ```
218
+
219
+ ### Plugin Options
220
+
221
+ The `containers` plugin provides several options for customization. Here are the available options and their descriptions:
222
+
223
+ #### `type`
224
+
225
+ - **Type**: `string`
226
+ - **Description**: The type of the container (e.g., 'tip', 'warning', 'danger', 'details').
227
+
228
+ #### `defaultTitle`
229
+
230
+ - **Type**: `string`
231
+ - **Description**: The default title to use if no specific title is provided in the Markdown.
232
+
233
+ #### `render`
234
+
235
+ - **Type**: `function`
236
+ - **Description**: A custom render function to define how the container should be rendered.
237
+
238
+ ### Example Configuration
239
+
240
+ Here is an example of how you can configure the `containers` plugin with custom options:
241
+
242
+ ```typescript
243
+ import MarkdownIt from 'markdown-it'
244
+ import type Token from 'markdown-it/lib/token.mjs'
245
+ import { containersPlugin } from '@md-plugins/md-plugin-containers'
246
+ import type {
247
+ ContainerDetails,
248
+ CreateContainerFn,
249
+ Container,
250
+ ContainerOptions,
251
+ } from '@md-plugins/md-plugin-containers'
252
+
253
+ const createContainer: CreateContainerFn = (
254
+ container: Container,
255
+ containerType: string,
256
+ defaultTitle: string,
257
+ ): [Container, string, ContainerOptions] => {
258
+ const containerTypeLen = containerType.length
259
+
260
+ return [
261
+ container,
262
+ containerType,
263
+ {
264
+ render(tokens: Token[], idx: number): string {
265
+ const token = tokens[idx]
266
+ if (!token) {
267
+ return ''
268
+ }
269
+
270
+ const title = token.info.trim().slice(containerTypeLen).trim() || defaultTitle
271
+
272
+ if (containerType === 'details') {
273
+ return token.nesting === 1
274
+ ? `<details class="markdown-note markdown-note--${containerType}"><summary class="markdown-note__title">${title}</summary>\n`
275
+ : '</details>\n'
276
+ }
277
+
278
+ return token.nesting === 1
279
+ ? `<div class="markdown-note markdown-note--${containerType}"><p class="markdown-note__title">${title}</p>\n`
280
+ : '</div>\n'
281
+ },
282
+ },
283
+ ]
284
+ }
285
+
286
+ const containers: ContainerDetails[] = [
287
+ { type: 'tip', defaultTitle: 'TIP' },
288
+ { type: 'warning', defaultTitle: 'WARNING' },
289
+ { type: 'danger', defaultTitle: 'WARNING' },
290
+ { type: 'details', defaultTitle: 'Details' },
291
+ ]
292
+
293
+ const md = new MarkdownIt()
294
+ md.use(containersPlugin, containers, createContainer)
295
+ ```
296
+
297
+ ### Conclusion
298
+
299
+ By customizing the CSS classes and using the available plugin options, you can tailor the appearance and behavior of containers to match the style of your project. Experiment with different styles and configurations to find the one that works best for you.
300
+
301
+ Happy coding!
@@ -0,0 +1,206 @@
1
+ ---
2
+ title: Containers Plugin
3
+ desc: Containers plugin for Markdown.
4
+ ---
5
+
6
+ Welcome to the Containers Plugin documentation! This guide will provide you with an overview of the Containers plugin and its features.
7
+
8
+ ## What is the Containers Plugin?
9
+
10
+ The Containers Plugin is a powerful tool that enhances the standard Markdown functionality by allowing you to create custom containers for different types of content blocks. It integrates seamlessly with Markdown-It to provide a flexible and customizable way to handle containers in your Markdown files.
11
+
12
+ ## Key Features
13
+
14
+ - **Custom Containers**: Create custom containers for different types of content blocks like tips, warnings, and details.
15
+ - **Default Titles**: Specify default titles for containers if no specific title is provided in the Markdown.
16
+ - **Flexible Configuration**: Use a custom function to create and configure containers.
17
+
18
+ ## Examples
19
+
20
+ Here are some examples of what you can achieve with the Containers Plugin:
21
+
22
+ ### Standard Container
23
+
24
+ ::: tip
25
+ This is a tip container.
26
+ :::
27
+
28
+ ```markup
29
+ ::: tip
30
+ This is a tip container.
31
+ :::
32
+ ```
33
+
34
+ ::: warning
35
+ This is a warning container.
36
+ :::
37
+
38
+ ```markup
39
+ ::: warning
40
+ This is a warning container.
41
+ :::
42
+ ```
43
+
44
+ ::: danger
45
+ This is a danger container.
46
+ :::
47
+
48
+ ```markup
49
+ ::: danger
50
+ This is a danger container.
51
+ :::
52
+ ```
53
+
54
+ ::: details
55
+ This is a details container.
56
+ :::
57
+
58
+ ```markup
59
+ ::: details
60
+ This is a details container.
61
+ :::
62
+ ```
63
+
64
+ ### Container with Custom Title
65
+
66
+ ::: warning Custom Warning Title
67
+ This is a warning container with a custom title.
68
+ :::
69
+
70
+ ```markup
71
+ ::: warning Custom Warning Title
72
+ This is a warning container with a custom title.
73
+ :::
74
+ ```
75
+
76
+ ## Name
77
+
78
+ The official NPM name is `@md-plugins/md-plugin-containers`.
79
+
80
+ ## Installation
81
+
82
+ You can install the Containers plugin using npm, yarn, or pnpm. Choose your preferred method below:
83
+
84
+ ```tabs
85
+ <<| bash npm |>>
86
+ npm install @md-plugins/md-plugin-containers
87
+ <<| bash yarn |>>
88
+ yarn add @md-plugins/md-plugin-containers
89
+ <<| bash pnpm |>>
90
+ pnpm add @md-plugins/md-plugin-containers
91
+ ```
92
+
93
+ ## Configuration
94
+
95
+ After installing the plugin, you need to configure it in your Markdown-It setup. Here's an example of how to do that:
96
+
97
+ ```js
98
+ import MarkdownIt from 'markdown-it'
99
+ import { containersPlugin } from '@md-plugins/md-plugin-containers'
100
+ import container from 'markdown-it-container'
101
+
102
+ const md = new MarkdownIt()
103
+
104
+ const containers = [
105
+ { type: 'warning', defaultTitle: 'Warning' },
106
+ { type: 'tip', defaultTitle: 'Tip' },
107
+ { type: 'details', defaultTitle: 'Details' },
108
+ ]
109
+
110
+ function createContainer(container, containerType, defaultTitle) {
111
+ const containerTypeLen = containerType.length
112
+
113
+ return [
114
+ container,
115
+ containerType,
116
+ {
117
+ render(tokens, idx) {
118
+ const token = tokens[idx]
119
+ const title = token.info.trim().slice(containerTypeLen).trim() || defaultTitle
120
+
121
+ if (containerType === 'details') {
122
+ return token.nesting === 1
123
+ ? `<details class="markdown-note markdown-note--${containerType}"><summary class="markdown-note__title">${title}</summary>\n`
124
+ : '</details>\n'
125
+ }
126
+
127
+ return token.nesting === 1
128
+ ? `<div class="markdown-note markdown-note--${containerType}"><p class="markdown-note__title">${title}</p>\n`
129
+ : '</div>\n'
130
+ },
131
+ },
132
+ ]
133
+ }
134
+
135
+ md.use(containersPlugin, containers, createContainer)
136
+
137
+ // Now you can use the Containers plugin in your Markdown content
138
+ const result = md.render('::: tip\nThis is a tip container.\n:::')
139
+ console.log(result)
140
+ ```
141
+
142
+ ### Options
143
+
144
+ The Containers plugin accepts the following options:
145
+
146
+ - **containers**: An array of `ContainerDetails` objects, each specifying a container type and its default title.
147
+ - **createContainer**: A function that creates and returns the container plugin configuration.
148
+
149
+ ## Advanced Configuration
150
+
151
+ For more advanced configurations, you can combine the Containers plugin with other Markdown-It plugins to enhance your Markdown content further. Here's an example:
152
+
153
+ ```js
154
+ import MarkdownIt from 'markdown-it'
155
+ import { containersPlugin } from '@md-plugins/md-plugin-containers'
156
+ import markdownItAnchor from 'markdown-it-anchor'
157
+ import markdownItToc from 'markdown-it-toc-done-right'
158
+ import container from 'markdown-it-container'
159
+
160
+ const md = new MarkdownIt()
161
+
162
+ const containers = [
163
+ { type: 'warning', defaultTitle: 'Warning' },
164
+ { type: 'tip', defaultTitle: 'Tip' },
165
+ { type: 'details', defaultTitle: 'Details' },
166
+ ]
167
+
168
+ function createContainer(container, containerType, defaultTitle) {
169
+ const containerTypeLen = containerType.length
170
+
171
+ return [
172
+ container,
173
+ containerType,
174
+ {
175
+ render(tokens, idx) {
176
+ const token = tokens[idx]
177
+ const title = token.info.trim().slice(containerTypeLen).trim() || defaultTitle
178
+
179
+ if (containerType === 'details') {
180
+ return token.nesting === 1
181
+ ? `<details class="markdown-note markdown-note--${containerType}"><summary class="markdown-note__title">${title}</summary>\n`
182
+ : '</details>\n'
183
+ }
184
+
185
+ return token.nesting === 1
186
+ ? `<div class="markdown-note markdown-note--${containerType}"><p class="markdown-note__title">${title}</p>\n`
187
+ : '</div>\n'
188
+ },
189
+ },
190
+ ]
191
+ }
192
+
193
+ md.use(containersPlugin, containers, createContainer).use(markdownItAnchor).use(markdownItToc)
194
+
195
+ // Now you can use the Containers plugin along with other plugins in your Markdown content
196
+ const result = md.render(
197
+ '::: tip\nThis is a tip container.\n:::\n\n# Table of Contents\n\n[[toc]]\n\n::: warning Custom Warning Title\nThis is a warning container with a custom title.\n:::',
198
+ )
199
+ console.log(result)
200
+ ```
201
+
202
+ ## Support
203
+
204
+ If you have any questions or need assistance, please refer to the FAQ or reach out to our support team.
205
+
206
+ Happy coding!
@@ -0,0 +1,164 @@
1
+ ---
2
+ title: Frontmatter Plugin Advanced Topics
3
+ desc: Frontmatter plugin advanced topics for Markdown.
4
+ ---
5
+
6
+ ## Frontmatter Plugin
7
+
8
+ The `frontmatter` plugin allows you to extract and process frontmatter content from your Markdown files. 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 { PluginWithOptions } from 'markdown-it'
14
+ import matter from 'gray-matter'
15
+
16
+ type GrayMatterOptions = matter.GrayMatterOption<string, GrayMatterOptions>
17
+
18
+ /**
19
+ * Options of md-plugin-frontmatter
20
+ */
21
+ interface FrontmatterPluginOptions {
22
+ /**
23
+ * Options of gray-matter
24
+ *
25
+ * @see https://github.com/jonschlinkert/gray-matter#options
26
+ */
27
+ grayMatterOptions?: GrayMatterOptions
28
+ /**
29
+ * Render the excerpt or not
30
+ *
31
+ * @default false
32
+ */
33
+ renderExcerpt?: boolean
34
+ }
35
+
36
+ declare module '@md-plugins/shared' {
37
+ interface MarkdownItEnv {
38
+ /**
39
+ * The raw Markdown content without frontmatter
40
+ */
41
+ content?: string
42
+ /**
43
+ * Whether render excerpt or not
44
+ */
45
+ renderExcerpt?: boolean
46
+ /**
47
+ * The excerpt that extracted by `md-plugin-frontmatter`
48
+ *
49
+ * - Would be the rendered HTML when `renderExcerpt` is enabled
50
+ * - Would be the raw Markdown when `renderExcerpt` is disabled
51
+ */
52
+ excerpt?: string
53
+ /**
54
+ * The frontmatter that extracted by `md-plugin-frontmatter`
55
+ */
56
+ frontmatter?: Record<string, unknown>
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Get markdown frontmatter and excerpt
62
+ *
63
+ * Extract them into env
64
+ */
65
+ declare const frontmatterPlugin: PluginWithOptions<FrontmatterPluginOptions>
66
+
67
+ export { type FrontmatterPluginOptions, frontmatterPlugin }
68
+ ```
69
+
70
+ ### How It Works
71
+
72
+ Frontmatter is a block of metadata at the top of a Markdown file, enclosed by triple dashes (`---`). The `frontmatter` plugin parses this block and makes the metadata available for use in your Markdown content.
73
+
74
+ ### Default Behavior
75
+
76
+ By default, the `frontmatter` plugin extracts the frontmatter content and makes it available in the `env` object passed to the Markdown renderer. Here is an example of a Markdown file with frontmatter:
77
+
78
+ ```markdown
79
+ ---
80
+ title: My Awesome Post
81
+ date: 2023-10-01
82
+ tags: [markdown, frontmatter, plugin]
83
+ ---
84
+ ```
85
+
86
+ ### Plugin Options
87
+
88
+ The frontmatter plugin provides several options for customization. Here are the available options and their descriptions:
89
+
90
+ #### `grayMatterOptions`
91
+
92
+ - **Type**: `object`
93
+ - **Description**: Options to pass to the `gray-matter` library for parsing frontmatter.
94
+
95
+ #### `renderExcerpt`
96
+
97
+ - **Type**: `boolean`
98
+ - **Default**: `false`
99
+ - **Description**: Whether to render the excerpt using the original `markdown-it` render method.
100
+
101
+ ### Example Configuration
102
+
103
+ Here is an example of how you can configure the frontmatter plugin with custom options:
104
+
105
+ ```typescript
106
+ import MarkdownIt from 'markdown-it'
107
+ import { frontmatterPlugin } from '@md-plugins/md-plugin-frontmatter'
108
+
109
+ const md = new MarkdownIt()
110
+
111
+ md.use(frontmatterPlugin, {
112
+ grayMatterOptions: {
113
+ excerpt: true,
114
+ excerpt_separator: '<!-- more -->',
115
+ },
116
+ renderExcerpt: true,
117
+ })
118
+ ```
119
+
120
+ ### Using Frontmatter in Templates
121
+
122
+ Once the frontmatter is extracted and validated, 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 frontmatter in a Vue component:
123
+
124
+ ```html
125
+ <template>
126
+ <div>
127
+ <h1>{{ frontmatter.title }}</h1>
128
+ <p>Published on: {{ frontmatter.date }}</p>
129
+ <p>Tags: {{ frontmatter.tags.join(', ') }}</p>
130
+ </div>
131
+ </template>
132
+
133
+ <script setup>
134
+ import { ref } from 'vue'
135
+
136
+ const frontmatter = ref({
137
+ title: 'My Awesome Post',
138
+ date: '2023-10-01',
139
+ tags: ['markdown', 'frontmatter', 'plugin'],
140
+ })
141
+ </script>
142
+ ```
143
+
144
+ ### Handling Errors
145
+
146
+ The frontmatter plugin includes error handling to ensure that any issues with parsing the frontmatter do not break the rendering process. If an error occurs, the plugin will log the error and continue rendering the content without the frontmatter.
147
+
148
+ ```typescript
149
+ try {
150
+ // Parse frontmatter and content
151
+ ;({ data, content } = grayMatter(src, grayMatterOptions))
152
+ } catch (error) {
153
+ console.error('Failed to parse frontmatter:', error)
154
+ data = {}
155
+ content = src
156
+ excerpt = undefined
157
+ }
158
+ ```
159
+
160
+ ### Conclusion
161
+
162
+ The frontmatter plugin is a powerful tool for extracting and processing metadata from your Markdown files. By customizing the parsing and validation logic, you can tailor the plugin to fit your specific needs. Remember, it is up to you to handle the extracted frontmatter 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.
163
+
164
+ Happy coding!