@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,88 @@
1
+ ---
2
+ title: Asset Handling
3
+ order: 5
4
+ ---
5
+
6
+ # Asset Handling
7
+
8
+ Greg uses Vite for asset processing, so all standard Vite rules apply.
9
+
10
+
11
+ ## Referencing images
12
+
13
+ ### From Markdown
14
+
15
+ Relative paths are resolved from the location of the `.md` file:
16
+
17
+ ```md
18
+ ![diagram](./images/diagram.png)
19
+ ```
20
+
21
+ Absolute paths are resolved from the project root's `public/` directory:
22
+
23
+ ```md
24
+ ![logo](/logo.svg)
25
+ ```
26
+
27
+ ### From the `public/` folder
28
+
29
+ Files placed in `public/` are served as-is and are accessible at the root (`/`):
30
+
31
+ ```
32
+ public/
33
+ logo.svg → /logo.svg
34
+ favicon.ico → /favicon.ico
35
+ ```
36
+
37
+ They are **not** processed by Vite — no hashing, no transformation.
38
+
39
+
40
+ ## Static assets with Vite processing
41
+
42
+ Assets imported via relative URLs are processed by Vite (content-hash in filename,
43
+ tree-shaking, etc.). Inside `.svelte` files use a standard `import`:
44
+
45
+ ```svelte
46
+ <script>
47
+ import logo from '../assets/logo.svg';
48
+ </script>
49
+
50
+ <img src={logo} alt="Logo" />
51
+ ```
52
+
53
+ In Markdown the recommended approach is to place permanent assets in `public/`
54
+ and reference them with absolute paths.
55
+
56
+
57
+ ## Inline attributes for sizing
58
+
59
+ Use the [inline attributes](/guide/markdown/inline-attributes)
60
+ syntax to add `width`, `height` or CSS classes directly in Markdown:
61
+
62
+ ```md
63
+ ![diagram](./schema.png){width=640 height=480}
64
+
65
+ ![icon](/icons/info.svg){class="inline-icon" width=24}
66
+ ```
67
+
68
+
69
+ ## The `<Image>` component
70
+
71
+ The `<Image>` component renders a `<picture>` element with separate `dark` and
72
+ `light` variants, matching the current theme:
73
+
74
+ ```md
75
+ <Image
76
+ src="/logo-light.svg"
77
+ dark="/logo-dark.svg"
78
+ alt="Greg logo"
79
+ />
80
+ ```
81
+
82
+ | Prop | Type | Description |
83
+ | -------- | ----------------- | ---------------------------------- |
84
+ | `src` | `string` | Default (or light-theme) image URL |
85
+ | `dark` | `string?` | Dark-theme image URL |
86
+ | `alt` | `string?` | Alt text |
87
+ | `width` | `number\|string?` | Element width |
88
+ | `height` | `number\|string?` | Element height |
@@ -0,0 +1,162 @@
1
+ ---
2
+ title: Deploying
3
+ order: 6
4
+ ---
5
+
6
+ # Deploying
7
+
8
+ Greg outputs a **single-page application (SPA)**. All URLs are handled
9
+ client-side, so the web server must serve `index.html` for every route that
10
+ does not match a static file.
11
+
12
+
13
+ ## Build
14
+
15
+ ```sh
16
+ npm run build
17
+ ```
18
+
19
+ The output is placed in `dist/`. It contains:
20
+
21
+ ```
22
+ dist/
23
+ index.html
24
+ assets/ ← JS, CSS, fonts (content-hashed)
25
+ search-index.json
26
+ <any public/ files>
27
+ ```
28
+
29
+
30
+ ## Static route generation
31
+
32
+ If your hosting does not support SPA fallback rules, you can pre-generate
33
+ `index.html` copies for every docs route:
34
+
35
+ ```sh
36
+ greg build:static
37
+ ```
38
+
39
+ This runs `vite build` followed by a post-processing step that copies
40
+ `dist/index.html` to `dist/<route>/index.html` for every known page.
41
+ The result works on any static file server without rewrite configuration.
42
+
43
+
44
+ ## Markdown export
45
+
46
+ To export resolved Markdown files (with all includes and snippets expanded):
47
+
48
+ ```sh
49
+ greg build:markdown
50
+ ```
51
+
52
+ The output lands in `dist/resolved-markdown/` by default.
53
+ Pass `--docsDir` or `--outDir` to customise paths.
54
+
55
+
56
+ ## SPA fallback — server configuration
57
+
58
+ Configure your server to return `index.html` for all `404` responses.
59
+
60
+ ### Nginx
61
+
62
+ ```nginx
63
+ server {
64
+ root /var/www/my-docs/dist;
65
+ index index.html;
66
+
67
+ location / {
68
+ try_files $uri $uri/ /index.html;
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Apache (`.htaccess`)
74
+
75
+ ```apache [httpd.conf]
76
+ <IfModule mod_rewrite.c>
77
+ RewriteEngine On
78
+ RewriteBase /
79
+ RewriteCond %{REQUEST_FILENAME} !-f
80
+ RewriteCond %{REQUEST_FILENAME} !-d
81
+ RewriteRule . /index.html [L]
82
+ </IfModule>
83
+ ```
84
+
85
+ ### Caddy
86
+
87
+ ```caddyfile
88
+ my-docs.example.com {
89
+ root * /var/www/my-docs/dist
90
+ file_server
91
+ try_files {path} /index.html
92
+ }
93
+ ```
94
+
95
+
96
+ ## Netlify
97
+
98
+ Add a `public/_redirects` file:
99
+
100
+ ```
101
+ /* /index.html 200
102
+ ```
103
+
104
+ Or use `netlify.toml`:
105
+
106
+ ```toml
107
+ [[redirects]]
108
+ from = "/*"
109
+ to = "/index.html"
110
+ status = 200
111
+ ```
112
+
113
+
114
+ ## Vercel
115
+
116
+ Add a `vercel.json` at the project root:
117
+
118
+ ```json
119
+ {
120
+ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
121
+ }
122
+ ```
123
+
124
+
125
+ ## GitHub Pages
126
+
127
+ GitHub Pages does not natively support SPA fallback. The common workaround is:
128
+
129
+ 1. Copy `dist/index.html` → `dist/404.html` after the build.
130
+ 2. Add a redirect script in `404.html` to restore the original URL and reload.
131
+
132
+ Alternatively, use [GitHub Actions + a custom workflow](https://vitejs.dev/guide/static-deploy#github-pages) with the approach above.
133
+
134
+
135
+ ## Base path
136
+
137
+ If your docs are served from a sub-path (e.g. `https://example.com/my-project/`),
138
+ set `base` in `vite.config.js`:
139
+
140
+ ```js
141
+ export default defineConfig({
142
+ base: '/my-project/',
143
+ // …
144
+ });
145
+ ```
146
+
147
+ Also update `docsBase` in `greg.config.js`:
148
+
149
+ ```js
150
+ export default {
151
+ srcDir: 'docs',
152
+ docsBase: '/my-project/docs',
153
+ // …
154
+ }
155
+ ```
156
+
157
+ And the plugin `srcDir` (URL prefix) in `vite.config.js`:
158
+
159
+ ```js
160
+ vitePluginSearchIndex({ docsDir: 'docs', srcDir: '/my-project/docs' }),
161
+ vitePluginSearchServer({ docsDir: 'docs', srcDir: '/my-project/docs' }),
162
+ ```
@@ -0,0 +1,334 @@
1
+ ---
2
+ title: Getting Started
3
+ order: 1
4
+ ---
5
+
6
+ ## What is Greg?
7
+
8
+ Greg is a **documentation engine built on Svelte 5 and Vite**. You write your
9
+ content in plain Markdown files, Greg turns them into a fast, polished
10
+ single-page site — complete with responsive sidebar navigation, full-text
11
+ search, dark/light mode, code syntax highlighting, and a rich set of Markdown
12
+ extensions.
13
+
14
+ Greg is inspired by [VitePress](https://vitepress.dev){target="_blank" rel="noopener noreferrer"} and reuses most of its Markdown
15
+ syntax and configuration conventions, but runs on Svelte 5 instead of Vue.
16
+ If you have used VitePress before, you will feel right at home.
17
+
18
+ ## Prerequisites
19
+
20
+ Before you start, make sure the following are installed:
21
+
22
+ | Tool | Required version | How to check |
23
+ | ------- | ---------------- | -------------------- |
24
+ | Node.js | ≥ 18 | `node --version` |
25
+ | npm | comes with Node | `npm --version` |
26
+
27
+ You do **not** need to install Svelte or Vite separately — the `init` wizard
28
+ or the manual install step handles those for you.
29
+
30
+ ---
31
+
32
+ ## Option A — New project from scratch
33
+
34
+ This is the recommended path if you are starting fresh with no existing
35
+ codebase.
36
+
37
+ ### 1. Create an empty folder and open it
38
+
39
+ ```sh
40
+ mkdir my-docs
41
+ cd my-docs
42
+ ```
43
+
44
+ ### 2. Run the interactive initializer
45
+
46
+ ```sh
47
+ npx @dominikcz/greg init
48
+ ```
49
+
50
+ The wizard asks a handful of questions:
51
+
52
+ | Question | What it does |
53
+ | -------- | ------------ |
54
+ | **Docs directory** | Where your Markdown files will live. Default: `docs` |
55
+ | **Site title** | Shown in the browser tab and the site header |
56
+ | **Description** | Used in the HTML `<meta>` tag |
57
+ | **TypeScript** | Creates `.ts` config files instead of `.js` |
58
+ | **Add npm scripts** | Adds `dev`, `build` and `preview` to `package.json` |
59
+ | **Starter content** | _Empty_ — bare minimum; _Sample_ — example pages; _Generated_ — large fake docs set |
60
+ | **Install now** | Runs `npm install` (or your package manager) right away |
61
+
62
+ When it finishes, you will see a summary of created files.
63
+
64
+ ### 3. Start the development server
65
+
66
+ ```sh
67
+ npm run dev
68
+ ```
69
+
70
+ Open `http://localhost:5173` in your browser — your docs site is running.
71
+ Every time you save a `.md` file the page updates instantly without a full
72
+ reload.
73
+
74
+ ### 4. Write your first page
75
+
76
+ Edit or create any `.md` file inside the `docs/` folder:
77
+
78
+ ```md
79
+ <!-- docs/guide/my-first-page.md -->
80
+ ---
81
+ title: My First Page
82
+ ---
83
+
84
+ # Hello, Greg!
85
+
86
+ This is my first docs page.
87
+ ```
88
+
89
+ Save the file — it immediately appears in the sidebar and becomes accessible
90
+ at `/guide/my-first-page`.
91
+
92
+ ---
93
+
94
+ ## Option B — Add Greg to an existing project
95
+
96
+ Use this path if you already have a Vite project (for example a Svelte app)
97
+ and want to add a docs section to it.
98
+
99
+ ### 1. Install the packages
100
+
101
+ ```sh
102
+ npm install --save-dev @dominikcz/greg @sveltejs/vite-plugin-svelte svelte vite
103
+ ```
104
+
105
+ ### 2. Create the config files
106
+
107
+ **`greg.config.js`** — site-level settings:
108
+
109
+ ```js
110
+ export default {
111
+ srcDir: 'docs', // folder where your .md files live
112
+ docsBase: '', // URL prefix — '' means docs are at the root URL
113
+ mainTitle: 'My Docs',
114
+ sidebar: 'auto', // auto-generate sidebar from folder structure
115
+ }
116
+ ```
117
+
118
+ `srcDir` can also be an array if your markdown sources are split across folders:
119
+
120
+ ```js
121
+ export default {
122
+ srcDir: ['docs', 'api-docs', 'handbook'],
123
+ docsBase: '',
124
+ }
125
+ ```
126
+
127
+ In that case, Greg scans all listed folders for `.md` files.
128
+
129
+ **`svelte.config.js`** — re-export Greg's bundled Svelte config (includes
130
+ mdsvex for Markdown processing):
131
+
132
+ ```js
133
+ export { default } from '@dominikcz/greg/svelte.config'
134
+ ```
135
+
136
+ **`vite.config.js`** — register the Greg Vite plugins:
137
+
138
+ ```js
139
+ import { defineConfig } from 'vite'
140
+ import { svelte } from '@sveltejs/vite-plugin-svelte'
141
+ import {
142
+ vitePluginGregConfig,
143
+ vitePluginSearchIndex,
144
+ vitePluginSearchServer,
145
+ vitePluginFrontmatter,
146
+ vitePluginCopyDocs,
147
+ } from '@dominikcz/greg/plugins'
148
+
149
+ const docsDir = ['docs', 'api-docs', 'handbook']
150
+ const docsBase = ''
151
+
152
+ export default defineConfig({
153
+ plugins: [
154
+ svelte(),
155
+ vitePluginGregConfig(),
156
+ vitePluginSearchIndex({ docsDir, srcDir: docsBase }),
157
+ vitePluginSearchServer({ docsDir, srcDir: docsBase }),
158
+ vitePluginFrontmatter({ docsDir, srcDir: docsBase }),
159
+ vitePluginCopyDocs({ docsDir, srcDir: docsBase }),
160
+ ],
161
+ })
162
+ ```
163
+
164
+ `docsDir` in Greg Vite plugins accepts either a string (single folder) or a string array (multiple folders).
165
+
166
+ **`index.html`** — minimal HTML entry point:
167
+
168
+ ```html
169
+ <!doctype html>
170
+ <html lang="en">
171
+ <head>
172
+ <meta charset="UTF-8" />
173
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
174
+ <title>My Docs</title>
175
+ </head>
176
+ <body>
177
+ <div id="app"></div>
178
+ <script type="module" src="/src/main.js"></script>
179
+ </body>
180
+ </html>
181
+ ```
182
+
183
+ **`src/main.js`** — Vite entry point:
184
+
185
+ ```js
186
+ import App from './App.svelte'
187
+ import { mount } from 'svelte'
188
+
189
+ const app = mount(App, { target: document.getElementById('app') })
190
+ export default app
191
+ ```
192
+
193
+ **`src/App.svelte`** — mount the docs engine:
194
+
195
+ ```svelte
196
+ <script>
197
+ import MarkdownDocs from '@dominikcz/greg'
198
+ </script>
199
+
200
+ <MarkdownDocs />
201
+ ```
202
+
203
+ ### 3. Create your first Markdown page
204
+
205
+ ```sh
206
+ mkdir docs
207
+ ```
208
+
209
+ ```md
210
+ <!-- docs/index.md -->
211
+ ---
212
+ title: Home
213
+ ---
214
+
215
+ # Welcome
216
+
217
+ This is the home page of my documentation.
218
+ ```
219
+
220
+ ### 4. Add scripts to `package.json`
221
+
222
+ ```json
223
+ {
224
+ "scripts": {
225
+ "dev": "greg dev",
226
+ "build": "greg build",
227
+ "preview": "greg preview"
228
+ }
229
+ }
230
+ ```
231
+
232
+ Then run:
233
+
234
+ ```sh
235
+ npm run dev
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Project structure explained
241
+
242
+ After setup your project will look like this:
243
+
244
+ ```text
245
+ .
246
+ ├─ docs/ ← all your Markdown content lives here
247
+ │ ├─ index.md ← home page (shown at the root URL)
248
+ │ ├─ guide/
249
+ │ │ ├─ index.md ← section landing page
250
+ │ │ └─ getting-started.md
251
+ │ └─ reference/
252
+ ├─ src/
253
+ │ ├─ App.svelte ← mounts <MarkdownDocs> (rarely needs editing)
254
+ │ └─ main.js ← Vite entry point
255
+ ├─ svelte.config.js ← Svelte + mdsvex options (must be plain .js)
256
+ ├─ vite.config.js ← Vite config with Greg plugins
257
+ ├─ greg.config.js ← title, sidebar, nav, locales, search …
258
+ └─ package.json
259
+ ```
260
+
261
+ Key rules:
262
+ - Every `.md` file in `docs/` becomes a page. The URL matches its file path.
263
+ - Files and folders whose name starts with `__` (double underscore) are
264
+ **not** turned into pages — use this for partials and shared snippets.
265
+ - `index.md` in any folder is accessible at the folder URL (e.g.
266
+ `docs/guide/index.md` → `/guide`).
267
+
268
+ ## The `greg.config.js` file
269
+
270
+ This is the main configuration file. The most commonly used options:
271
+
272
+ ```js
273
+ export default {
274
+ srcDir: 'docs', // path to your Markdown files
275
+ docsBase: '', // URL prefix for all docs pages
276
+ mainTitle: 'My Docs', // site title shown in header
277
+ sidebar: 'auto', // 'auto' builds sidebar from folder structure
278
+
279
+ // Manual sidebar (optional):
280
+ // sidebar: [
281
+ // { text: 'Guide', auto: '/guide' },
282
+ // { text: 'Reference', auto: '/reference' },
283
+ // ],
284
+
285
+ // Top navigation bar (optional):
286
+ // nav: [
287
+ // { text: 'Guide', link: '/guide' },
288
+ // { text: 'Reference', link: '/reference' },
289
+ // ],
290
+
291
+ outline: [2, 3], // show h2 and h3 in the on-page outline
292
+ }
293
+ ```
294
+
295
+ See the [`<MarkdownDocs>` reference](/reference/markdowndocs) for a complete
296
+ list of all configuration options.
297
+
298
+ ## Development server
299
+
300
+ ```sh
301
+ npm run dev
302
+ # equivalent: greg dev
303
+ ```
304
+
305
+ - Serves at `http://localhost:5173` by default
306
+ - Markdown file saves trigger instant hot-reload — no full page refresh
307
+ - The search index is rebuilt automatically in the background
308
+
309
+ ## Production build
310
+
311
+ ```sh
312
+ npm run build
313
+ # equivalent: greg build
314
+ ```
315
+
316
+ Outputs a fully static SPA in `dist/`. The build:
317
+ - Pre-renders all page metadata and the search index
318
+ - Bundles and optimises all CSS and JavaScript
319
+ - Copies your Markdown files so they can be served statically
320
+
321
+ The resulting `dist/` folder can be deployed to any static hosting service.
322
+ See [Deploying](./deploying) for step-by-step hosting guides.
323
+
324
+ ## Next steps
325
+
326
+ Now that your site is running, explore these topics:
327
+
328
+ - **[Markdown extensions](./markdown)** — tables, code groups, callouts, math,
329
+ diagrams and more
330
+ - **[Routing](./routing)** — how URLs are resolved from file paths
331
+ - **[Localization](./localization)** — multi-language docs with automatic UI
332
+ translations
333
+ - **[Search](../reference/search)** — configure full-text search
334
+ - **[Deploying](./deploying)** — publish to GitHub Pages, Netlify, Vercel, etc.
@@ -0,0 +1,23 @@
1
+ ---
2
+ title: Guide
3
+ order: 1
4
+ ---
5
+
6
+ # Guide
7
+
8
+ Welcome to the Greg documentation guide.
9
+
10
+ If you are new here, start with **[Getting Started](./getting-started)** — it
11
+ walks you through creating a new project from scratch *or* adding Greg to an
12
+ existing one, step by step.
13
+
14
+ ## Topics
15
+
16
+ - [Getting Started](./getting-started) — requirements, quick-start wizard, manual installation, project structure, first page
17
+ - [Routing](./routing) — how file-based routing works, URL resolution, anchor links
18
+ - [Markdown Extensions](./markdown) — tables, code groups, callouts, math, diagrams, includes and more
19
+ - [Localization](./localization) — multi-language docs, automatic UI translations, locale routing
20
+ - [Versioning](./versioning) — multi-version builds, version switcher, outdated notice
21
+ - [Asset Handling](./asset-handling) — images, public files, and the `<Image>` component
22
+ - [Using Svelte](./using-svelte) — Svelte components and reactivity inside Markdown pages
23
+ - [Deploying](./deploying) — publishing to GitHub Pages, Netlify, Vercel and other hosts