@dominikcz/greg 0.9.27

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 (183) hide show
  1. package/README.md +397 -0
  2. package/bin/greg.js +241 -0
  3. package/bin/init.js +351 -0
  4. package/bin/templates/docs/getting-started.md +47 -0
  5. package/bin/templates/docs/index.md +11 -0
  6. package/bin/templates/greg.config.js +39 -0
  7. package/bin/templates/greg.config.ts +38 -0
  8. package/bin/templates/index.html +16 -0
  9. package/bin/templates/src/App.svelte +5 -0
  10. package/bin/templates/src/app.css +20 -0
  11. package/bin/templates/src/main.js +9 -0
  12. package/bin/templates/svelte.config.js +1 -0
  13. package/bin/templates/tsconfig.json +21 -0
  14. package/bin/templates/vite.config.js +23 -0
  15. package/docs/__partials/markdown/examples/basic.md +4 -0
  16. package/docs/__partials/markdown/examples/diff.md +10 -0
  17. package/docs/__partials/markdown/examples/focus.md +5 -0
  18. package/docs/__partials/markdown/examples/language-title.md +3 -0
  19. package/docs/__partials/markdown/examples/line-highlighting.md +5 -0
  20. package/docs/__partials/markdown/examples/line-numbers.md +5 -0
  21. package/docs/__partials/note.md +4 -0
  22. package/docs/guide/__shared-warning.md +4 -0
  23. package/docs/guide/asset-handling.md +88 -0
  24. package/docs/guide/deploying.md +162 -0
  25. package/docs/guide/getting-started.md +334 -0
  26. package/docs/guide/index.md +23 -0
  27. package/docs/guide/localization.md +290 -0
  28. package/docs/guide/markdown/code.md +95 -0
  29. package/docs/guide/markdown/components-and-mermaid.md +43 -0
  30. package/docs/guide/markdown/containers.md +110 -0
  31. package/docs/guide/markdown/header-anchors.md +34 -0
  32. package/docs/guide/markdown/includes.md +84 -0
  33. package/docs/guide/markdown/index.md +20 -0
  34. package/docs/guide/markdown/inline-attributes.md +21 -0
  35. package/docs/guide/markdown/links-and-toc.md +64 -0
  36. package/docs/guide/markdown/math.md +54 -0
  37. package/docs/guide/markdown/syntax-highlighting.md +75 -0
  38. package/docs/guide/routing.md +150 -0
  39. package/docs/guide/using-svelte.md +88 -0
  40. package/docs/guide/versioning.md +281 -0
  41. package/docs/incompatibilities.md +48 -0
  42. package/docs/index.md +43 -0
  43. package/docs/reference/badge.md +100 -0
  44. package/docs/reference/carbon-ads.md +46 -0
  45. package/docs/reference/code-group.md +126 -0
  46. package/docs/reference/home-page.md +232 -0
  47. package/docs/reference/index.md +18 -0
  48. package/docs/reference/markdowndocs.md +275 -0
  49. package/docs/reference/outline.md +79 -0
  50. package/docs/reference/search.md +263 -0
  51. package/docs/reference/steps.md +200 -0
  52. package/docs/reference/team-page.md +189 -0
  53. package/docs/reference/theme.md +150 -0
  54. package/fakeDocsGenerator/generate_docs.js +310 -0
  55. package/package.json +92 -0
  56. package/scripts/build-versions.js +609 -0
  57. package/scripts/generate-static.js +79 -0
  58. package/scripts/render-markdown.js +420 -0
  59. package/src/lib/MarkdownDocs/AiChat.svelte +936 -0
  60. package/src/lib/MarkdownDocs/BackToTop.svelte +68 -0
  61. package/src/lib/MarkdownDocs/Breadcrumb.svelte +68 -0
  62. package/src/lib/MarkdownDocs/DocsNavigation.svelte +149 -0
  63. package/src/lib/MarkdownDocs/DocsSiteHeader.svelte +758 -0
  64. package/src/lib/MarkdownDocs/DocsVersionSwitcher.svelte +103 -0
  65. package/src/lib/MarkdownDocs/MarkdownDocs.svelte +2115 -0
  66. package/src/lib/MarkdownDocs/MarkdownRenderer.svelte +487 -0
  67. package/src/lib/MarkdownDocs/Outline.svelte +238 -0
  68. package/src/lib/MarkdownDocs/PrevNext.svelte +115 -0
  69. package/src/lib/MarkdownDocs/SearchModal.svelte +1241 -0
  70. package/src/lib/MarkdownDocs/TreeView.svelte +32 -0
  71. package/src/lib/MarkdownDocs/TreeViewItem.svelte +219 -0
  72. package/src/lib/MarkdownDocs/VersionOutdatedNotice.svelte +72 -0
  73. package/src/lib/MarkdownDocs/__tests__/codeDirectives.test.js +54 -0
  74. package/src/lib/MarkdownDocs/__tests__/common.test.js +41 -0
  75. package/src/lib/MarkdownDocs/__tests__/docsExamplesLint.test.js +77 -0
  76. package/src/lib/MarkdownDocs/__tests__/fixtures/docs/markdown/__partial-basic.md +3 -0
  77. package/src/lib/MarkdownDocs/__tests__/fixtures/docs/markdown/snippet.js +9 -0
  78. package/src/lib/MarkdownDocs/__tests__/fixtures/includes/part.md +11 -0
  79. package/src/lib/MarkdownDocs/__tests__/fixtures/includes/wrapper.md +5 -0
  80. package/src/lib/MarkdownDocs/__tests__/fixtures/snippets/sample.js +8 -0
  81. package/src/lib/MarkdownDocs/__tests__/fixtures/snippets/sample.md +5 -0
  82. package/src/lib/MarkdownDocs/__tests__/helpers.js +67 -0
  83. package/src/lib/MarkdownDocs/__tests__/localeUtils.test.js +204 -0
  84. package/src/lib/MarkdownDocs/__tests__/markdown.test.js +704 -0
  85. package/src/lib/MarkdownDocs/__tests__/markdownRendererRuntime.test.js +65 -0
  86. package/src/lib/MarkdownDocs/__tests__/searchIndexBuilder.test.js +117 -0
  87. package/src/lib/MarkdownDocs/__tests__/sqliteStore.test.js +202 -0
  88. package/src/lib/MarkdownDocs/__tests__/useRouter.test.js +16 -0
  89. package/src/lib/MarkdownDocs/ai/adapters/customAdapter.js +14 -0
  90. package/src/lib/MarkdownDocs/ai/adapters/customAdapter.ts +43 -0
  91. package/src/lib/MarkdownDocs/ai/adapters/ollamaAdapter.js +81 -0
  92. package/src/lib/MarkdownDocs/ai/adapters/ollamaAdapter.ts +116 -0
  93. package/src/lib/MarkdownDocs/ai/adapters/openaiAdapter.js +92 -0
  94. package/src/lib/MarkdownDocs/ai/adapters/openaiAdapter.ts +137 -0
  95. package/src/lib/MarkdownDocs/ai/aiProvider.ts +31 -0
  96. package/src/lib/MarkdownDocs/ai/characters.js +52 -0
  97. package/src/lib/MarkdownDocs/ai/characters.ts +69 -0
  98. package/src/lib/MarkdownDocs/ai/chunkStore.ts +25 -0
  99. package/src/lib/MarkdownDocs/ai/chunker.js +85 -0
  100. package/src/lib/MarkdownDocs/ai/chunker.ts +135 -0
  101. package/src/lib/MarkdownDocs/ai/docLinker.js +26 -0
  102. package/src/lib/MarkdownDocs/ai/docLinker.ts +36 -0
  103. package/src/lib/MarkdownDocs/ai/promptBuilder.js +33 -0
  104. package/src/lib/MarkdownDocs/ai/promptBuilder.ts +53 -0
  105. package/src/lib/MarkdownDocs/ai/ragPipeline.js +54 -0
  106. package/src/lib/MarkdownDocs/ai/ragPipeline.ts +106 -0
  107. package/src/lib/MarkdownDocs/ai/stores/memoryStore.js +88 -0
  108. package/src/lib/MarkdownDocs/ai/stores/memoryStore.ts +112 -0
  109. package/src/lib/MarkdownDocs/ai/stores/sqliteStore.ts +372 -0
  110. package/src/lib/MarkdownDocs/ai/types.ts +71 -0
  111. package/src/lib/MarkdownDocs/aiServer.js +288 -0
  112. package/src/lib/MarkdownDocs/codeDirectives.js +191 -0
  113. package/src/lib/MarkdownDocs/codeFenceInfo.js +45 -0
  114. package/src/lib/MarkdownDocs/codeGroup.ts +46 -0
  115. package/src/lib/MarkdownDocs/common.ts +47 -0
  116. package/src/lib/MarkdownDocs/docsUtils.js +281 -0
  117. package/src/lib/MarkdownDocs/index.plugins.js +22 -0
  118. package/src/lib/MarkdownDocs/layouts/LayoutDoc.svelte +8 -0
  119. package/src/lib/MarkdownDocs/layouts/LayoutHome.svelte +58 -0
  120. package/src/lib/MarkdownDocs/layouts/LayoutPage.svelte +9 -0
  121. package/src/lib/MarkdownDocs/loadGregConfig.js +82 -0
  122. package/src/lib/MarkdownDocs/localeUtils.ts +682 -0
  123. package/src/lib/MarkdownDocs/markdownRendererRuntime.ts +314 -0
  124. package/src/lib/MarkdownDocs/mermaidThemes.js +319 -0
  125. package/src/lib/MarkdownDocs/navigationUtils.js +22 -0
  126. package/src/lib/MarkdownDocs/rehypeCodeGroup.js +326 -0
  127. package/src/lib/MarkdownDocs/rehypeCodeTitle.js +96 -0
  128. package/src/lib/MarkdownDocs/rehypeToc.js +170 -0
  129. package/src/lib/MarkdownDocs/remarkCodeMeta.js +22 -0
  130. package/src/lib/MarkdownDocs/remarkContainers.js +329 -0
  131. package/src/lib/MarkdownDocs/remarkCustomAnchors.js +42 -0
  132. package/src/lib/MarkdownDocs/remarkEscapeSvelte.js +33 -0
  133. package/src/lib/MarkdownDocs/remarkGlobalComponents.js +65 -0
  134. package/src/lib/MarkdownDocs/remarkImports.js +461 -0
  135. package/src/lib/MarkdownDocs/remarkImportsBrowser.js +349 -0
  136. package/src/lib/MarkdownDocs/remarkInlineAttrs.js +95 -0
  137. package/src/lib/MarkdownDocs/remarkMathToHtml.js +138 -0
  138. package/src/lib/MarkdownDocs/searchIndexBuilder.js +497 -0
  139. package/src/lib/MarkdownDocs/searchServer.js +263 -0
  140. package/src/lib/MarkdownDocs/treeViewTypes.ts +11 -0
  141. package/src/lib/MarkdownDocs/useRouter.svelte.ts +114 -0
  142. package/src/lib/MarkdownDocs/useSplitter.svelte.ts +33 -0
  143. package/src/lib/MarkdownDocs/versioningDefaults.js +20 -0
  144. package/src/lib/MarkdownDocs/vitePluginAiServer.js +204 -0
  145. package/src/lib/MarkdownDocs/vitePluginCopyDocs.js +153 -0
  146. package/src/lib/MarkdownDocs/vitePluginFrontmatter.js +109 -0
  147. package/src/lib/MarkdownDocs/vitePluginGregConfig.js +108 -0
  148. package/src/lib/MarkdownDocs/vitePluginSearchIndex.js +57 -0
  149. package/src/lib/MarkdownDocs/vitePluginSearchServer.js +190 -0
  150. package/src/lib/components/Badge.svelte +59 -0
  151. package/src/lib/components/Button.svelte +138 -0
  152. package/src/lib/components/CarbonAds.svelte +99 -0
  153. package/src/lib/components/CodeGroup.svelte +102 -0
  154. package/src/lib/components/Feature.svelte +209 -0
  155. package/src/lib/components/Features.svelte +123 -0
  156. package/src/lib/components/Hero.svelte +399 -0
  157. package/src/lib/components/Image.svelte +128 -0
  158. package/src/lib/components/Link.svelte +105 -0
  159. package/src/lib/components/SocialLink.svelte +84 -0
  160. package/src/lib/components/SocialLinks.svelte +33 -0
  161. package/src/lib/components/Steps.svelte +143 -0
  162. package/src/lib/components/TeamMember.svelte +273 -0
  163. package/src/lib/components/TeamMembers.svelte +81 -0
  164. package/src/lib/components/TeamPage.svelte +65 -0
  165. package/src/lib/components/TeamPageSection.svelte +108 -0
  166. package/src/lib/components/TeamPageTitle.svelte +89 -0
  167. package/src/lib/components/index.js +24 -0
  168. package/src/lib/portal/context.js +12 -0
  169. package/src/lib/portal/index.js +3 -0
  170. package/src/lib/portal/portal.svelte +14 -0
  171. package/src/lib/portal/slot.svelte +8 -0
  172. package/src/lib/scss/__code.scss +128 -0
  173. package/src/lib/scss/__containers.scss +99 -0
  174. package/src/lib/scss/__markdown.scss +447 -0
  175. package/src/lib/scss/__scrollbar.scss +60 -0
  176. package/src/lib/scss/__steps.scss +100 -0
  177. package/src/lib/scss/__theme.scss +238 -0
  178. package/src/lib/scss/__toc.scss +55 -0
  179. package/src/lib/scss/__utilities.scss +7 -0
  180. package/src/lib/scss/greg.scss +9 -0
  181. package/src/lib/spinner/spinner.svelte +42 -0
  182. package/svelte.config.js +146 -0
  183. package/types/index.d.ts +456 -0
@@ -0,0 +1,290 @@
1
+ ---
2
+ title: Localization
3
+ order: 3
4
+ ---
5
+
6
+ ## Localization
7
+
8
+ Greg supports locale configuration via `locales` in
9
+ `greg.config.js`. Each locale can define its own labels, navigation, sidebar,
10
+ and translated UI text in `themeConfig`.
11
+
12
+ ## Basic locale map
13
+
14
+ ```js
15
+ export default {
16
+ srcDir: 'docs',
17
+ docsBase: '',
18
+ locales: {
19
+ '/': {
20
+ lang: 'en-US',
21
+ label: 'English',
22
+ title: 'Greg',
23
+ themeConfig: {
24
+ nav: [{ text: 'Guide', link: '/guide' }],
25
+ sidebar: [{ text: 'Guide', auto: '/guide' }],
26
+ },
27
+ },
28
+ '/pl/': {
29
+ lang: 'pl-PL',
30
+ label: 'Polski',
31
+ title: 'Greg',
32
+ themeConfig: {
33
+ nav: [{ text: 'Przewodnik', link: '/pl/guide' }],
34
+ sidebar: [{ text: 'Przewodnik', auto: '/guide' }],
35
+ },
36
+ },
37
+ },
38
+ };
39
+ ```
40
+
41
+ For `docsBase: ''`, locale URL mapping is:
42
+
43
+ - `'/'` -> `/`
44
+ - `'/pl/'` -> `/pl`
45
+
46
+ ## Locale folders and routes
47
+
48
+ By convention, translated files live in a locale-prefixed folder, for example:
49
+
50
+ ```text
51
+ docs/
52
+ guide/getting-started.md
53
+ pl/guide/getting-started.md
54
+ ```
55
+
56
+ That gives:
57
+
58
+ - EN: `/docs/guide/getting-started`
59
+ - PL: `/docs/pl/guide/getting-started`
60
+
61
+ Use locale-specific internal links in translated pages to avoid accidental
62
+ `/pl/pl/...` paths.
63
+
64
+ ## Separate directory for each locale
65
+
66
+ You can also place each locale in its own top-level docs directory.
67
+
68
+ ```js
69
+ export default {
70
+ srcDir: 'docs',
71
+ docsBase: '',
72
+ locales: {
73
+ '/en/': {
74
+ lang: 'en-US',
75
+ label: 'English',
76
+ themeConfig: {
77
+ nav: [{ text: 'Guide', link: '/en/guide' }],
78
+ },
79
+ },
80
+ '/pl/': {
81
+ lang: 'pl-PL',
82
+ label: 'Polski',
83
+ themeConfig: {
84
+ nav: [{ text: 'Przewodnik', link: '/pl/guide' }],
85
+ },
86
+ },
87
+ },
88
+ };
89
+ ```
90
+
91
+ Recommended content structure:
92
+
93
+ ```text
94
+ docs/
95
+ en/
96
+ guide/
97
+ reference/
98
+ pl/
99
+ guide/
100
+ reference/
101
+ ```
102
+
103
+ That gives URLs such as `/en/...` and `/pl/...`, with fully
104
+ separated content trees per locale.
105
+
106
+ ### Default locale landing behavior
107
+
108
+ When you use only namespaced locales (for example `'/en/'` and `'/pl/'`, with
109
+ no `'/'` locale), Greg automatically redirects:
110
+
111
+ - `/` -> first configured locale root (for example `/docs/en`)
112
+ - docs root (for `docsBase: ''` this is `/`) -> first configured locale root
113
+
114
+ The first entry order in `locales` is therefore treated as the default locale.
115
+
116
+ How it works:
117
+
118
+ 1. Greg checks whether a root locale `'/'` exists.
119
+ 2. If it exists, no redirect is applied.
120
+ 3. If it does not exist, and user opens `/` or base docs root, Greg navigates
121
+ to `locales` first entry root.
122
+
123
+ Example:
124
+
125
+ ```js
126
+ locales: {
127
+ '/en/': { label: 'English' },
128
+ '/pl/': { label: 'Polski' },
129
+ }
130
+ ```
131
+
132
+ In this setup the default landing locale is English, because `'/en/'` is first.
133
+
134
+ ## What goes into `themeConfig`
135
+
136
+ Each locale can translate standard docs chrome and navigation text:
137
+
138
+ - `nav`, `sidebar`, `outline`
139
+ - `docFooter.prev`, `docFooter.next`
140
+ - language and accessibility labels (`langMenuLabel`, `skipToContentLabel`, ...)
141
+ - search UI labels via `themeConfig.search.locales`
142
+
143
+ Example:
144
+
145
+ ```js
146
+ themeConfig: {
147
+ langMenuLabel: 'Zmien jezyk',
148
+ returnToTopLabel: 'Wroc do gory',
149
+ docFooter: { prev: 'Poprzednia strona', next: 'Nastepna strona' },
150
+ search: {
151
+ locales: {
152
+ '/pl/': {
153
+ button: { buttonText: 'Szukaj...', buttonAriaLabel: 'Wyszukiwarka' },
154
+ modal: {
155
+ searchBox: { placeholder: 'Szukaj w dokumentacji...' },
156
+ noResultsText: 'Brak wynikow dla',
157
+ loadingScreen: { loadingText: 'Wczytywanie indeksu...' },
158
+ errorScreen: { titleText: 'Nie udalo sie wczytac indeksu wyszukiwania.' },
159
+ footer: { navigateText: 'nawiguj', selectText: 'otworz', closeText: 'zamknij' },
160
+ },
161
+ },
162
+ },
163
+ },
164
+ }
165
+ ```
166
+
167
+ ## Search configuration in localized docs
168
+
169
+ Search behavior is configured in top-level `search`, while locale-specific UI
170
+ texts stay in each locale `themeConfig.search.locales`.
171
+
172
+ ```js
173
+ export default {
174
+ search: {
175
+ provider: 'server',
176
+ serverUrl: '/api/search',
177
+ },
178
+ locales: {
179
+ '/pl/': {
180
+ themeConfig: {
181
+ search: {
182
+ locales: {
183
+ '/pl/': {
184
+ button: { buttonText: 'Szukaj...' },
185
+ modal: { searchBox: { placeholder: 'Szukaj w dokumentacji...' } },
186
+ },
187
+ },
188
+ },
189
+ },
190
+ },
191
+ },
192
+ };
193
+ ```
194
+
195
+ This keeps one global search backend configuration and per-locale UI copy.
196
+
197
+ ## Versioning localization
198
+
199
+ Versioning UI text (version switcher and outdated notice) is configured in
200
+ `versioning.ui`, and can be overridden per locale using `versioning.locales`.
201
+
202
+ ```js
203
+ versioning: {
204
+ ui: {
205
+ versionMenuLabel: 'Version',
206
+ outdatedVersionActionLabel: 'Go to latest'
207
+ },
208
+ locales: {
209
+ '/pl/': {
210
+ ui: {
211
+ versionMenuLabel: 'Wersja',
212
+ outdatedVersionActionLabel: 'Przejdz do najnowszej'
213
+ }
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ Resolution order:
220
+
221
+ 1. `versioning.locales[active-locale].ui`
222
+ 2. `versioning.ui`
223
+ 3. built-in defaults
224
+
225
+ If `versions.json` is unavailable, Greg shows the locale-resolved
226
+ `manifestUnavailableText` in the header.
227
+
228
+ ## Built-in locale strings
229
+
230
+ Greg ships with built-in UI translations for common languages. When a locale
231
+ defines `lang`, Greg automatically resolves the matching built-in strings —
232
+ so you only need to configure what differs from the defaults.
233
+
234
+ Currently built-in languages:
235
+
236
+ | `lang` | Language |
237
+ |--------|----------|
238
+ | `en` / `en-US` / `en-GB` … | English |
239
+ | `pl` / `pl-PL` … | Polish |
240
+
241
+ Built-in strings cover all UI labels: navigation accessibility labels,
242
+ doc footer links, search modal labels, and AI chat labels.
243
+
244
+ **Resolution order for every UI string:**
245
+
246
+ 1. Explicit value in `themeConfig` / `themeConfig.search.locales`
247
+ 2. Built-in string for the locale's `lang`
248
+ 3. Hard-coded English fallback
249
+
250
+ ### Minimal multilingual config
251
+
252
+ With built-in strings you don't need to repeat any UI text. A full
253
+ two-language setup is as simple as:
254
+
255
+ ```js
256
+ export default {
257
+ locales: {
258
+ '/': {
259
+ lang: 'en-US',
260
+ label: 'English',
261
+ title: 'My Docs',
262
+ themeConfig: {
263
+ nav: [{ text: 'Guide', link: '/guide' }],
264
+ sidebar: [{ text: 'Guide', auto: '/guide' }],
265
+ },
266
+ },
267
+ '/pl/': {
268
+ lang: 'pl-PL', // ← all Polish UI text is resolved automatically
269
+ label: 'Polski',
270
+ title: 'Moja Dokumentacja',
271
+ themeConfig: {
272
+ nav: [{ text: 'Przewodnik', link: '/guide' }],
273
+ sidebar: [{ text: 'Przewodnik', auto: '/guide' }],
274
+ outline: { level: [2, 3], label: 'Na tej stronie' },
275
+ },
276
+ },
277
+ },
278
+ };
279
+ ```
280
+
281
+ You can still override individual strings by setting them explicitly — the
282
+ explicit value always takes precedence.
283
+
284
+ ## Recommended workflow
285
+
286
+ 1. Start from English docs structure.
287
+ 2. Mirror file paths in `docs/pl/...`.
288
+ 3. Translate page content.
289
+ 4. Translate navigation and labels in locale `themeConfig`.
290
+ 5. Build and verify routes/search for both locales.
@@ -0,0 +1,95 @@
1
+ ---
2
+ title: Code blocks and groups
3
+ order: 5
4
+ ---
5
+
6
+ # Code blocks and groups
7
+
8
+ For syntax highlighting details and line focus/diff markers, see
9
+ [Syntax highlighting](./syntax-highlighting).
10
+
11
+ ## Code block title
12
+
13
+ Add a `[Title]` annotation in the language line:
14
+
15
+ ````md
16
+ ```js [example.js]
17
+ export const answer = 42;
18
+ ```
19
+ ````
20
+
21
+ Output:
22
+
23
+ ```js [example.js]
24
+ export const answer = 42;
25
+ ```
26
+
27
+ ## Code groups
28
+
29
+ Group multiple code blocks into a tabbed interface:
30
+
31
+ ````md
32
+ ::: code-group
33
+
34
+ ```sh [npm]
35
+ npm install
36
+ ```
37
+
38
+ ```sh [pnpm]
39
+ pnpm install
40
+ ```
41
+
42
+ ```sh [yarn]
43
+ yarn install
44
+ ```
45
+
46
+ :::
47
+ ````
48
+
49
+ Output:
50
+
51
+ ::: code-group
52
+
53
+ ```sh [npm]
54
+ npm install
55
+ ```
56
+
57
+ ```sh [pnpm]
58
+ pnpm install
59
+ ```
60
+
61
+ ```sh [yarn]
62
+ yarn install
63
+ ```
64
+
65
+ :::
66
+
67
+ Explicit label override:
68
+
69
+ ````md
70
+ ::: code-group labels=[Option A, Option B]
71
+
72
+ ```js
73
+ // option A
74
+ ```
75
+
76
+ ```ts
77
+ // option B
78
+ ```
79
+
80
+ :::
81
+ ````
82
+
83
+ Output:
84
+
85
+ ::: code-group labels=[Option A, Option B]
86
+
87
+ ```js
88
+ // option A
89
+ ```
90
+
91
+ ```ts
92
+ // option B
93
+ ```
94
+
95
+ :::
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: Svelte components and Mermaid
3
+ order: 8
4
+ ---
5
+
6
+ # Svelte components and Mermaid
7
+
8
+ ## Svelte components
9
+
10
+ Built-in components (`Badge`, `Button`, `Image`, `Link`) can be used directly in
11
+ `.md` files without any import statement:
12
+
13
+ ```md
14
+ ### Stability <Badge type="tip" text="stable" />
15
+
16
+ The API is considered stable as of v1.0.
17
+
18
+ <Badge type="warning">experimental</Badge>
19
+ ```
20
+
21
+ Output:
22
+
23
+ **Stability** <Badge type="tip" text="stable" />
24
+
25
+ The API is considered stable as of v1.0.
26
+
27
+ <Badge type="warning">experimental</Badge>
28
+
29
+ ::: info .svx files
30
+ In `.svx` files you can also write arbitrary Svelte markup with full reactivity
31
+ (`$state`, event handlers, etc.). In runtime `.md` files only the registered
32
+ built-in components are hydrated.
33
+ :::
34
+
35
+ ## Mermaid diagrams
36
+
37
+ Greg supports Mermaid diagrams.
38
+
39
+ <<< @/snippets/mermaid-sequence.md
40
+
41
+ Output:
42
+
43
+ <!--@include: @/snippets/mermaid-sequence.md-->
@@ -0,0 +1,110 @@
1
+ ---
2
+ title: Custom containers
3
+ order: 3
4
+ ---
5
+
6
+ # Custom containers
7
+
8
+ ## Default types
9
+
10
+ ```md
11
+ ::: info
12
+ Informational note.
13
+ :::
14
+
15
+ ::: tip
16
+ Helpful tip.
17
+ :::
18
+
19
+ ::: warning
20
+ Watch out for this.
21
+ :::
22
+
23
+ ::: danger
24
+ Dangerous operation!
25
+ :::
26
+ ```
27
+
28
+ Output:
29
+
30
+ ::: info
31
+ Informational note.
32
+ :::
33
+
34
+ ::: tip
35
+ Helpful tip.
36
+ :::
37
+
38
+ ::: warning
39
+ Watch out for this.
40
+ :::
41
+
42
+ ::: danger
43
+ Dangerous operation!
44
+ :::
45
+
46
+ ## Custom title
47
+
48
+ ```md
49
+ ::: warning Be careful!
50
+ Custom title replaces the default label.
51
+ :::
52
+ ```
53
+
54
+ Output:
55
+
56
+ ::: warning Be careful!
57
+ Custom title replaces the default label.
58
+ :::
59
+
60
+ ## Details (collapsible)
61
+
62
+ ```md
63
+ ::: details Click to expand
64
+ Hidden content revealed on click.
65
+ :::
66
+ ```
67
+
68
+ Output:
69
+
70
+ ::: details Click to expand
71
+ Hidden content revealed on click.
72
+ :::
73
+
74
+ ## GitHub-style alerts
75
+
76
+ The `> [!TYPE]` blockquote syntax is also supported:
77
+
78
+ ```md
79
+ > [!NOTE]
80
+ > Useful information.
81
+
82
+ > [!TIP]
83
+ > Pro tip.
84
+
85
+ > [!IMPORTANT]
86
+ > Key point.
87
+
88
+ > [!WARNING]
89
+ > Be careful.
90
+
91
+ > [!CAUTION]
92
+ > Dangerous action.
93
+ ```
94
+
95
+ Output:
96
+
97
+ > [!NOTE]
98
+ > Useful information.
99
+
100
+ > [!TIP]
101
+ > Pro tip.
102
+
103
+ > [!IMPORTANT]
104
+ > Key point.
105
+
106
+ > [!WARNING]
107
+ > Be careful.
108
+
109
+ > [!CAUTION]
110
+ > Dangerous action.
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Header anchors
3
+ order: 1
4
+ ---
5
+
6
+ # Header anchors
7
+
8
+ Every heading automatically receives a slug-based `id` so it can be linked to:
9
+
10
+ ```md
11
+ ## My Section
12
+ ```
13
+
14
+ Output:
15
+
16
+ ## My Section
17
+
18
+ Expected HTML includes `<h2 id="my-section">`.
19
+
20
+ ## Custom anchors
21
+
22
+ Override the auto-generated slug with a `{#custom-id}` suffix:
23
+
24
+ ```md
25
+ ## My Section {#custom-anchor}
26
+ ```
27
+
28
+ This lets you link to `#custom-anchor` even if the heading text changes.
29
+
30
+ Output:
31
+
32
+ ## My Section {#custom-anchor}
33
+
34
+ [Jump to custom anchor](#custom-anchor)
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: Including external files
3
+ order: 5
4
+ ---
5
+
6
+ # Including external files
7
+
8
+ ## Code snippets - `<<<`
9
+
10
+ Import an external source file as a code block:
11
+
12
+ ```md
13
+ <<< @/snippets/example.js
14
+ ```
15
+
16
+ Output:
17
+
18
+ <<< @/snippets/example.js
19
+
20
+ The `@` alias resolves to the project root. The language is detected from the
21
+ file extension.
22
+
23
+ ### Region
24
+
25
+ Import only a named region of the file (marked with `#region name` / `#endregion`):
26
+
27
+ ```md
28
+ <<< @/snippets/example.js#setup
29
+ ```
30
+
31
+ Output:
32
+
33
+ <<< @/snippets/example.js#setup
34
+
35
+ ### Range
36
+
37
+ Import specific line numbers:
38
+
39
+ ```md
40
+ <<< @/snippets/example.js{5-10}
41
+ ```
42
+
43
+ Output:
44
+
45
+ <<< @/snippets/example.js{5-10}
46
+
47
+ ### Title override
48
+
49
+ ```md
50
+ <<< @/snippets/example.js [my-example.js]
51
+ ```
52
+
53
+ Output:
54
+
55
+ <<< @/snippets/example.js [my-example.js]
56
+
57
+ ## Markdown include - `<!--@include:-->`
58
+
59
+ Include another Markdown file inline:
60
+
61
+ ```md
62
+ <!--@include: /guide/__shared-warning.md-->
63
+ ```
64
+
65
+ File `__shared-warning.md` looks like this:
66
+
67
+ <<< /guide/__shared-warning.md
68
+
69
+ Output:
70
+
71
+ <!--@include: /guide/__shared-warning.md-->
72
+
73
+ The included file is processed by the full Markdown pipeline. Partial files
74
+ (name starts with `__`) are excluded from routing.
75
+
76
+ The `/` prefix resolves to the `docs/` directory root:
77
+
78
+ ```md
79
+ <!--@include: /__partials/note.md-->
80
+ ```
81
+
82
+ Output:
83
+
84
+ <!--@include: /__partials/note.md-->
@@ -0,0 +1,20 @@
1
+ ---
2
+ title: Markdown Extensions
3
+ order: 2
4
+ ---
5
+
6
+ # Markdown Extensions
7
+
8
+ Greg extends standard Markdown with a rich set of authoring features.
9
+
10
+ ## Topics
11
+
12
+ - [Header anchors](./header-anchors)
13
+ - [Links and table of contents](./links-and-toc)
14
+ - [Custom containers](./containers)
15
+ - [Syntax highlighting](./syntax-highlighting)
16
+ - [Code blocks and code groups](./code)
17
+ - [Including external files](./includes)
18
+ - [Math equations](./math)
19
+ - [Inline attributes on links and images](./inline-attributes)
20
+ - [Svelte components and Mermaid](./components-and-mermaid)
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Inline attributes
3
+ order: 7
4
+ ---
5
+
6
+ # Inline attributes on links and images
7
+
8
+ Attach HTML attributes to links and images with a `{...}` block immediately after
9
+ the closing `)`:
10
+
11
+ ```md
12
+ [Open in new tab](https://example.com){target="_blank" rel="noopener"}
13
+
14
+ [styled link](../routing){class="my-link"}
15
+ ```
16
+
17
+ Output:
18
+
19
+ [Open in new tab](https://example.com){target="_blank" rel="noopener"}
20
+
21
+ [styled link](../routing){class="my-link"}