|
| 1 | +import fs from 'node:fs'; |
| 2 | +import path from 'node:path'; |
1 | 3 | import {defineConfig} from 'vitepress'; |
| 4 | +import {groupIconMdPlugin, groupIconVitePlugin} from 'vitepress-plugin-group-icons'; |
2 | 5 | import typedocSidebar from '../api/typedoc-sidebar.json'; |
3 | 6 |
|
| 7 | +// Copy source .md files to the build output so pages can be fetched as raw |
| 8 | +// markdown (powers the "View as Markdown" / "Copy for LLM" buttons). |
| 9 | +function copyMarkdownSources(srcDir: string, outDir: string) { |
| 10 | + const entries = fs.readdirSync(srcDir, {withFileTypes: true}); |
| 11 | + for (const entry of entries) { |
| 12 | + if (entry.name.startsWith('.') || entry.name === 'node_modules') continue; |
| 13 | + const src = path.join(srcDir, entry.name); |
| 14 | + const dest = path.join(outDir, entry.name); |
| 15 | + if (entry.isDirectory()) { |
| 16 | + fs.mkdirSync(dest, {recursive: true}); |
| 17 | + copyMarkdownSources(src, dest); |
| 18 | + } else if (entry.isFile() && entry.name.endsWith('.md')) { |
| 19 | + fs.copyFileSync(src, dest); |
| 20 | + } |
| 21 | + } |
| 22 | +} |
| 23 | + |
4 | 24 | // Build configuration from environment |
5 | 25 | const isDevBuild = process.env.IS_DEV_BUILD === 'true'; |
6 | 26 |
|
@@ -152,19 +172,64 @@ export default defineConfig({ |
152 | 172 |
|
153 | 173 | head: [['script', {}, versionSwitchScript]], |
154 | 174 |
|
| 175 | + // Git-based "Last updated" timestamps (overridable per-page via frontmatter) |
| 176 | + lastUpdated: true, |
| 177 | + |
155 | 178 | // Ignore dead links in api-readme.md (links are valid after TypeDoc generates the API docs) |
156 | 179 | ignoreDeadLinks: [/^\.\/clients\//], |
157 | 180 |
|
158 | | - // Show deeper heading levels in the outline |
| 181 | + buildEnd(siteConfig) { |
| 182 | + copyMarkdownSources(siteConfig.srcDir, siteConfig.outDir); |
| 183 | + }, |
| 184 | + |
| 185 | + // Show deeper heading levels in the outline; register group-icons md plugin |
159 | 186 | markdown: { |
160 | 187 | toc: {level: [2, 3, 4]}, |
| 188 | + config(md) { |
| 189 | + md.use(groupIconMdPlugin); |
| 190 | + }, |
| 191 | + }, |
| 192 | + |
| 193 | + vite: { |
| 194 | + plugins: [ |
| 195 | + groupIconVitePlugin({ |
| 196 | + customIcon: { |
| 197 | + npx: 'vscode-icons:file-type-npm', |
| 198 | + homebrew: 'logos:homebrew', |
| 199 | + 'agentforce vibes': { |
| 200 | + light: |
| 201 | + '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 56" fill="#333"><path d="M34 18h-7.9l6.8-15.2c0-.2.1-.5.1-.8 0-1.1-.9-2-2-2H9c-.9 0-1.7.6-1.9 1.5l-7 26c0 .2-.1.3-.1.5 0 1.1.9 2 2 2h7.5L4 53.5c0 .1-.1.3-.1.5 0 1.1.9 2 2 2 .6 0 1.2-.3 1.5-.7l28-34c.3-.4.5-.8.5-1.3.1-1.1-.8-2-1.9-2Z"/></svg>', |
| 202 | + dark: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 56" fill="#e8e8e8"><path d="M34 18h-7.9l6.8-15.2c0-.2.1-.5.1-.8 0-1.1-.9-2-2-2H9c-.9 0-1.7.6-1.9 1.5l-7 26c0 .2-.1.3-.1.5 0 1.1.9 2 2 2h7.5L4 53.5c0 .1-.1.3-.1.5 0 1.1.9 2 2 2 .6 0 1.2-.3 1.5-.7l28-34c.3-.4.5-.8.5-1.3.1-1.1-.8-2-1.9-2Z"/></svg>', |
| 203 | + }, |
| 204 | + 'claude code': 'logos:claude-icon', |
| 205 | + 'copilot (vs code)': 'logos:visual-studio-code', |
| 206 | + 'copilot cli': { |
| 207 | + light: 'logos:github-copilot', |
| 208 | + dark: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#e8e8e8"><path d="M21.4 14.3A10 10 0 0 0 22 11C22 5.5 17.5 1 12 1S2 5.5 2 11c0 1.1.2 2.2.6 3.3A5 5 0 0 0 0 18.5C0 21 2 23 4.5 23H6a1 1 0 0 0 1-1v-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zm2-3.2-.2-.1-4.6-2.7a.7.7 0 0 0-.8 0L8.8 7.3V5l4.7-2.7a4.4 4.4 0 0 1 6.5 4.6zm-12 4L6 9.7V4a4.4 4.4 0 0 1 7.2-3.4l-.2.1L8.4 3.3a.7.7 0 0 0-.4.7zm1-2.2 2.5-1.4 2.5 1.4v2.9L9.5 13l-2.5-1.5z"/></svg>', |
| 213 | + }, |
| 214 | + 'b2c cli': 'logos:salesforce', |
| 215 | + }, |
| 216 | + }), |
| 217 | + ], |
161 | 218 | }, |
162 | 219 |
|
163 | 220 | themeConfig: { |
164 | 221 | logo: '/logo.svg', |
165 | 222 | outline: { |
166 | 223 | level: [2, 3], |
167 | 224 | }, |
| 225 | + editLink: { |
| 226 | + pattern: 'https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/edit/main/docs/:path', |
| 227 | + text: 'Suggest changes to this page', |
| 228 | + }, |
| 229 | + lastUpdated: { |
| 230 | + text: 'Last updated', |
| 231 | + formatOptions: {dateStyle: 'medium'}, |
| 232 | + }, |
168 | 233 | nav: [ |
169 | 234 | {text: 'Guides', link: '/guide/'}, |
170 | 235 | {text: 'MCP', link: '/mcp/'}, |
@@ -199,6 +264,16 @@ export default defineConfig({ |
199 | 264 |
|
200 | 265 | search: { |
201 | 266 | provider: 'local', |
| 267 | + options: { |
| 268 | + detailedView: true, |
| 269 | + miniSearch: { |
| 270 | + searchOptions: { |
| 271 | + fuzzy: 0.2, |
| 272 | + prefix: true, |
| 273 | + boost: {title: 4, text: 2, titles: 1}, |
| 274 | + }, |
| 275 | + }, |
| 276 | + }, |
202 | 277 | }, |
203 | 278 | }, |
204 | 279 | }); |
0 commit comments