From 2d1e379287bb2c12d9db55d5621ac823c93bcd74 Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Sun, 12 Oct 2025 21:35:02 +0200 Subject: [PATCH 1/4] feat: fs sidebar --- docs/app.config.ts | 183 ++----------- .../{quickstart.mdx => (0)quickstart.mdx} | 0 ...to-existing.mdx => (1)add-to-existing.mdx} | 0 .../guide/{config.mdx => (2)config.mdx} | 19 +- .../guide/{structure.mdx => (3)structure.mdx} | 0 .../guide/{deploy.mdx => (4)deploy.mdx} | 0 .../custom-themes.mdx | 0 .../extending-themes.mdx | 0 docs/src/routes/guide/dave.mdx | 1 + .../markdown.mdx => features/(0)markdown.mdx} | 0 .../(1)language-switcher.mdx} | 0 .../i18n.mdx => features/(2)i18n.mdx} | 0 .../sitemap.mdx => features/(3)sitemap.mdx} | 0 .../guide/{(features) => features}/dev.mdx | 0 .../{(components) => components}/article.mdx | 0 .../{(components) => components}/features.mdx | 0 .../{(components) => components}/footer.mdx | 0 .../{(components) => components}/header.mdx | 0 .../{(components) => components}/hero.mdx | 0 .../last-updated.mdx | 0 .../{(components) => components}/link.mdx | 0 .../locale-selector.mdx | 0 .../{(components) => components}/sidebar.mdx | 0 .../theme-selector.mdx | 0 .../{(components) => components}/toc.mdx | 0 docs/src/routes/reference/index.mdx | 1 + package.json | 1 - pnpm-lock.yaml | 244 ------------------ src/config/sidebar.ts | 110 ++++++++ src/default-theme/components/DocSearch.css | 216 ---------------- src/default-theme/components/DocSearch.tsx | 18 -- src/default-theme/components/Header.tsx | 5 - src/default-theme/index.ts | 10 +- 33 files changed, 131 insertions(+), 677 deletions(-) rename docs/src/routes/guide/{quickstart.mdx => (0)quickstart.mdx} (100%) rename docs/src/routes/guide/{add-to-existing.mdx => (1)add-to-existing.mdx} (100%) rename docs/src/routes/guide/{config.mdx => (2)config.mdx} (94%) rename docs/src/routes/guide/{structure.mdx => (3)structure.mdx} (100%) rename docs/src/routes/guide/{deploy.mdx => (4)deploy.mdx} (100%) rename docs/src/routes/guide/{(customization) => customization}/custom-themes.mdx (100%) rename docs/src/routes/guide/{(customization) => customization}/extending-themes.mdx (100%) rename docs/src/routes/guide/{(features)/markdown.mdx => features/(0)markdown.mdx} (100%) rename docs/src/routes/guide/{language-switcher.mdx => features/(1)language-switcher.mdx} (100%) rename docs/src/routes/guide/{(features)/i18n.mdx => features/(2)i18n.mdx} (100%) rename docs/src/routes/guide/{(features)/sitemap.mdx => features/(3)sitemap.mdx} (100%) rename docs/src/routes/guide/{(features) => features}/dev.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/article.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/features.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/footer.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/header.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/hero.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/last-updated.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/link.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/locale-selector.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/sidebar.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/theme-selector.mdx (100%) rename docs/src/routes/reference/default-theme/{(components) => components}/toc.mdx (100%) delete mode 100644 src/default-theme/components/DocSearch.css delete mode 100644 src/default-theme/components/DocSearch.tsx diff --git a/docs/app.config.ts b/docs/app.config.ts index b9e9ff2..c500575 100644 --- a/docs/app.config.ts +++ b/docs/app.config.ts @@ -3,7 +3,8 @@ import { defineConfig } from "@solidjs/start/config"; import arraybuffer from "vite-plugin-arraybuffer"; import { createWithSolidBase, defineTheme } from "../src/config"; -import defaultTheme from "../src/default-theme"; +import defaultTheme, { DefaultThemeSidebarItem } from "../src/default-theme"; +import { createFilesystemSidebar, SidebarConfig } from "../src/config/sidebar"; const theme = defineTheme({ componentsPath: import.meta.resolve("./src/solidbase-theme"), @@ -97,173 +98,23 @@ export default defineConfig( }, ], sidebar: { - "/guide": [ - { - title: "Overview", - collapsed: false, - items: [ - { - title: "What is SolidBase?", - link: "/", - }, - { - title: "Quick Start", - link: "/quickstart", - status: "new", - }, - { - title: "Add to an Existing Project", - link: "/add-to-existing", - }, - { - title: "Configure Your App", - link: "/config", - }, - { - title: "Project Structure", - link: "/structure", - }, - { - title: "Deploy Your Site", - link: "/deploy", - }, - ], - }, - { - title: "Features", - collapsed: false, - items: [ - { - title: "Markdown Extensions", - link: "/markdown", - }, - { - title: "Language Switcher", - link: "/language-switcher", - }, - { - title: "Internationalisation", - link: "/i18n", - }, - { - title: "Sitemap Generation", - link: "/sitemap", - }, - { - title: "Dev", - link: "/dev", - }, - ], - }, - { - title: "Customisation", - collapsed: false, - items: [ - { - title: "Custom Themes", - link: "/custom-themes", - }, - { - title: "Extending Themes", - link: "/extending-themes", - }, - ], - }, - ], - "/reference": [ - { - title: "Reference", - collapsed: false, - items: [ - { - title: "Configuration Options", - link: "/config", - }, - { - title: "Frontmatter Config", - link: "/frontmatter", - }, - { - title: "Runtime API", - link: "/runtime-api", - }, - ], - }, - { - title: "Default Theme", - collapsed: false, - items: [ - { - title: "Overview", - link: "/default-theme", - }, - { - title: "CSS Variables", - link: "/default-theme/css-variables", - }, - { - title: "Components", - collapsed: false, - items: [ - { - title: "Article", - link: "/default-theme/article", - }, - { - title: "Features", - link: "/default-theme/features", - }, - { - title: "Footer", - link: "/default-theme/footer", - }, - { - title: "Header", - link: "/default-theme/header", - }, - { - title: "Hero", - link: "/default-theme/hero", - }, - { - title: "Last Updated", - link: "/default-theme/last-updated", - }, - { - title: "Link", - link: "/default-theme/link", - }, - { - title: "Locale Selector", - link: "/default-theme/locale-selector", - }, - { - title: "Sidebar", - link: "/default-theme/sidebar", - }, - { - title: "Table of Contents", - link: "/default-theme/toc", - }, - { - title: "Theme Selector", - link: "/default-theme/theme-selector", - }, - ], - }, - { - title: "Landing", - link: "/default-theme/landing", - }, - { - title: "Layout", - link: "/default-theme/layout", - }, - ], - }, - ], + "/guide": customFSSidebar("/guide", "Overview"), + "/reference": customFSSidebar("/reference", "Reference"), }, }, }, ), ); + + +function customFSSidebar(route: string, title: string) { + const sidebar = createFilesystemSidebar(route); + + return [ + { + title, + items: sidebar.filter((i) => !("items" in i)), + }, + ...sidebar.filter((i) => ("items" in i)) + ]; +} diff --git a/docs/src/routes/guide/quickstart.mdx b/docs/src/routes/guide/(0)quickstart.mdx similarity index 100% rename from docs/src/routes/guide/quickstart.mdx rename to docs/src/routes/guide/(0)quickstart.mdx diff --git a/docs/src/routes/guide/add-to-existing.mdx b/docs/src/routes/guide/(1)add-to-existing.mdx similarity index 100% rename from docs/src/routes/guide/add-to-existing.mdx rename to docs/src/routes/guide/(1)add-to-existing.mdx diff --git a/docs/src/routes/guide/config.mdx b/docs/src/routes/guide/(2)config.mdx similarity index 94% rename from docs/src/routes/guide/config.mdx rename to docs/src/routes/guide/(2)config.mdx index 1e21419..1707b7b 100644 --- a/docs/src/routes/guide/config.mdx +++ b/docs/src/routes/guide/(2)config.mdx @@ -235,7 +235,7 @@ nav: [ The sidebar configuration allows you to create a structured sidebar navigation for different sections of your documentation, with support for collapsible groups and nested items. The value is an array, each containing a title, a collapsed state, and an array of items. Each item can have a title, link, and optional status (`"new"`, `"updated"`, `"next"`). :::note -While there are preset statuses available, you can create your own custom status styles. +While there are preset statuses available, you can create your own custom status styles. ```ts title="app.config.ts" // .. @@ -293,20 +293,3 @@ sidebar: { }, // .. ``` - -#### Search - -SolidBase includes built-in search functionality. At the moment, it supports [Algolia DocSearch](https://docsearch.algolia.com/). You can configure the search provider and its options using the `search` option within `themeConfig`. - -```ts title="app.config.ts" -// .. -search: { - provider: "algolia", - options: { - appID: "", - apiKey: "" - indexName: "" - } -} -// .. -``` \ No newline at end of file diff --git a/docs/src/routes/guide/structure.mdx b/docs/src/routes/guide/(3)structure.mdx similarity index 100% rename from docs/src/routes/guide/structure.mdx rename to docs/src/routes/guide/(3)structure.mdx diff --git a/docs/src/routes/guide/deploy.mdx b/docs/src/routes/guide/(4)deploy.mdx similarity index 100% rename from docs/src/routes/guide/deploy.mdx rename to docs/src/routes/guide/(4)deploy.mdx diff --git a/docs/src/routes/guide/(customization)/custom-themes.mdx b/docs/src/routes/guide/customization/custom-themes.mdx similarity index 100% rename from docs/src/routes/guide/(customization)/custom-themes.mdx rename to docs/src/routes/guide/customization/custom-themes.mdx diff --git a/docs/src/routes/guide/(customization)/extending-themes.mdx b/docs/src/routes/guide/customization/extending-themes.mdx similarity index 100% rename from docs/src/routes/guide/(customization)/extending-themes.mdx rename to docs/src/routes/guide/customization/extending-themes.mdx diff --git a/docs/src/routes/guide/dave.mdx b/docs/src/routes/guide/dave.mdx index da1689a..de98001 100644 --- a/docs/src/routes/guide/dave.mdx +++ b/docs/src/routes/guide/dave.mdx @@ -1,5 +1,6 @@ --- title: What are we missing? +excludeFromSidebar: true --- # Day 1088 of asking for an internal shitpost channel diff --git a/docs/src/routes/guide/(features)/markdown.mdx b/docs/src/routes/guide/features/(0)markdown.mdx similarity index 100% rename from docs/src/routes/guide/(features)/markdown.mdx rename to docs/src/routes/guide/features/(0)markdown.mdx diff --git a/docs/src/routes/guide/language-switcher.mdx b/docs/src/routes/guide/features/(1)language-switcher.mdx similarity index 100% rename from docs/src/routes/guide/language-switcher.mdx rename to docs/src/routes/guide/features/(1)language-switcher.mdx diff --git a/docs/src/routes/guide/(features)/i18n.mdx b/docs/src/routes/guide/features/(2)i18n.mdx similarity index 100% rename from docs/src/routes/guide/(features)/i18n.mdx rename to docs/src/routes/guide/features/(2)i18n.mdx diff --git a/docs/src/routes/guide/(features)/sitemap.mdx b/docs/src/routes/guide/features/(3)sitemap.mdx similarity index 100% rename from docs/src/routes/guide/(features)/sitemap.mdx rename to docs/src/routes/guide/features/(3)sitemap.mdx diff --git a/docs/src/routes/guide/(features)/dev.mdx b/docs/src/routes/guide/features/dev.mdx similarity index 100% rename from docs/src/routes/guide/(features)/dev.mdx rename to docs/src/routes/guide/features/dev.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/article.mdx b/docs/src/routes/reference/default-theme/components/article.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/article.mdx rename to docs/src/routes/reference/default-theme/components/article.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/features.mdx b/docs/src/routes/reference/default-theme/components/features.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/features.mdx rename to docs/src/routes/reference/default-theme/components/features.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/footer.mdx b/docs/src/routes/reference/default-theme/components/footer.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/footer.mdx rename to docs/src/routes/reference/default-theme/components/footer.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/header.mdx b/docs/src/routes/reference/default-theme/components/header.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/header.mdx rename to docs/src/routes/reference/default-theme/components/header.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/hero.mdx b/docs/src/routes/reference/default-theme/components/hero.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/hero.mdx rename to docs/src/routes/reference/default-theme/components/hero.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/last-updated.mdx b/docs/src/routes/reference/default-theme/components/last-updated.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/last-updated.mdx rename to docs/src/routes/reference/default-theme/components/last-updated.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/link.mdx b/docs/src/routes/reference/default-theme/components/link.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/link.mdx rename to docs/src/routes/reference/default-theme/components/link.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/locale-selector.mdx b/docs/src/routes/reference/default-theme/components/locale-selector.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/locale-selector.mdx rename to docs/src/routes/reference/default-theme/components/locale-selector.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/sidebar.mdx b/docs/src/routes/reference/default-theme/components/sidebar.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/sidebar.mdx rename to docs/src/routes/reference/default-theme/components/sidebar.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/theme-selector.mdx b/docs/src/routes/reference/default-theme/components/theme-selector.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/theme-selector.mdx rename to docs/src/routes/reference/default-theme/components/theme-selector.mdx diff --git a/docs/src/routes/reference/default-theme/(components)/toc.mdx b/docs/src/routes/reference/default-theme/components/toc.mdx similarity index 100% rename from docs/src/routes/reference/default-theme/(components)/toc.mdx rename to docs/src/routes/reference/default-theme/components/toc.mdx diff --git a/docs/src/routes/reference/index.mdx b/docs/src/routes/reference/index.mdx index 6bab6d1..df20b1d 100644 --- a/docs/src/routes/reference/index.mdx +++ b/docs/src/routes/reference/index.mdx @@ -1,4 +1,5 @@ --- +title: Reference --- # SolidBase Reference diff --git a/package.json b/package.json index 7629dc5..b5e88b2 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,6 @@ "@alloc/quick-lru": "^5.2.0", "@bprogress/core": "^1.1.18", "@docsearch/css": "^3.6.2", - "@docsearch/js": "^3.6.2", "@expressive-code/core": "^0.40.2", "@expressive-code/plugin-collapsible-sections": "^0.40.2", "@expressive-code/plugin-frames": "^0.40.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f0762e..a0aa243 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: '@docsearch/css': specifier: ^3.6.2 version: 3.9.0 - '@docsearch/js': - specifier: ^3.6.2 - version: 3.9.0(@algolia/client-search@5.20.3) '@expressive-code/core': specifier: ^0.40.2 version: 0.40.2 @@ -284,78 +281,6 @@ importers: packages: - '@algolia/autocomplete-core@1.17.9': - resolution: {integrity: sha512-O7BxrpLDPJWWHv/DLA9DRFWs+iY1uOJZkqUwjS5HSZAGcl0hIVCQ97LTLewiZmZ402JYUrun+8NqFP+hCknlbQ==} - - '@algolia/autocomplete-plugin-algolia-insights@1.17.9': - resolution: {integrity: sha512-u1fEHkCbWF92DBeB/KHeMacsjsoI0wFhjZtlCq2ddZbAehshbZST6Hs0Avkc0s+4UyBGbMDnSuXHLuvRWK5iDQ==} - peerDependencies: - search-insights: '>= 1 < 3' - - '@algolia/autocomplete-preset-algolia@1.17.9': - resolution: {integrity: sha512-Na1OuceSJeg8j7ZWn5ssMu/Ax3amtOwk76u4h5J4eK2Nx2KB5qt0Z4cOapCsxot9VcEN11ADV5aUSlQF4RhGjQ==} - peerDependencies: - '@algolia/client-search': '>= 4.9.1 < 6' - algoliasearch: '>= 4.9.1 < 6' - - '@algolia/autocomplete-shared@1.17.9': - resolution: {integrity: sha512-iDf05JDQ7I0b7JEA/9IektxN/80a2MZ1ToohfmNS3rfeuQnIKI3IJlIafD0xu4StbtQTghx9T3Maa97ytkXenQ==} - peerDependencies: - '@algolia/client-search': '>= 4.9.1 < 6' - algoliasearch: '>= 4.9.1 < 6' - - '@algolia/client-abtesting@5.20.3': - resolution: {integrity: sha512-wPOzHYSsW+H97JkBLmnlOdJSpbb9mIiuNPycUCV5DgzSkJFaI/OFxXfZXAh1gqxK+hf0miKue1C9bltjWljrNA==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-analytics@5.20.3': - resolution: {integrity: sha512-XE3iduH9lA7iTQacDGofBQyIyIgaX8qbTRRdj1bOCmfzc9b98CoiMwhNwdTifmmMewmN0EhVF3hP8KjKWwX7Yw==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-common@5.20.3': - resolution: {integrity: sha512-IYRd/A/R3BXeaQVT2805lZEdWo54v39Lqa7ABOxIYnUvX2vvOMW1AyzCuT0U7Q+uPdD4UW48zksUKRixShcWxA==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-insights@5.20.3': - resolution: {integrity: sha512-QGc/bmDUBgzB71rDL6kihI2e1Mx6G6PxYO5Ks84iL3tDcIel1aFuxtRF14P8saGgdIe1B6I6QkpkeIddZ6vWQw==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-personalization@5.20.3': - resolution: {integrity: sha512-zuM31VNPDJ1LBIwKbYGz/7+CSm+M8EhlljDamTg8AnDilnCpKjBebWZR5Tftv/FdWSro4tnYGOIz1AURQgZ+tQ==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-query-suggestions@5.20.3': - resolution: {integrity: sha512-Nn872PuOI8qzi1bxMMhJ0t2AzVBqN01jbymBQOkypvZHrrjZPso3iTpuuLLo9gi3yc/08vaaWTAwJfPhxPwJUw==} - engines: {node: '>= 14.0.0'} - - '@algolia/client-search@5.20.3': - resolution: {integrity: sha512-9+Fm1ahV8/2goSIPIqZnVitV5yHW5E5xTdKy33xnqGd45A9yVv5tTkudWzEXsbfBB47j9Xb3uYPZjAvV5RHbKA==} - engines: {node: '>= 14.0.0'} - - '@algolia/ingestion@1.20.3': - resolution: {integrity: sha512-5GHNTiZ3saLjTNyr6WkP5hzDg2eFFAYWomvPcm9eHWskjzXt8R0IOiW9kkTS6I6hXBwN5H9Zna5mZDSqqJdg+g==} - engines: {node: '>= 14.0.0'} - - '@algolia/monitoring@1.20.3': - resolution: {integrity: sha512-KUWQbTPoRjP37ivXSQ1+lWMfaifCCMzTnEcEnXwAmherS5Tp7us6BAqQDMGOD4E7xyaS2I8pto6WlOzxH+CxmA==} - engines: {node: '>= 14.0.0'} - - '@algolia/recommend@5.20.3': - resolution: {integrity: sha512-oo/gG77xTTTclkrdFem0Kmx5+iSRFiwuRRdxZETDjwzCI7svutdbwBgV/Vy4D4QpYaX4nhY/P43k84uEowCE4Q==} - engines: {node: '>= 14.0.0'} - - '@algolia/requester-browser-xhr@5.20.3': - resolution: {integrity: sha512-BkkW7otbiI/Er1AiEPZs1h7lxbtSO9p09jFhv3/iT8/0Yz0CY79VJ9iq+Wv1+dq/l0OxnMpBy8mozrieGA3mXQ==} - engines: {node: '>= 14.0.0'} - - '@algolia/requester-fetch@5.20.3': - resolution: {integrity: sha512-eAVlXz7UNzTsA1EDr+p0nlIH7WFxo7k3NMxYe8p38DH8YVWLgm2MgOVFUMNg9HCi6ZNOi/A2w/id2ZZ4sKgUOw==} - engines: {node: '>= 14.0.0'} - - '@algolia/requester-node-http@5.20.3': - resolution: {integrity: sha512-FqR3pQPfHfQyX1wgcdK6iyqu86yP76MZd4Pzj1y/YLMj9rRmRCY0E0AffKr//nrOFEwv6uY8BQY4fd9/6b0ZCg==} - engines: {node: '>= 14.0.0'} - '@alloc/quick-lru@5.2.0': resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} @@ -635,26 +560,6 @@ packages: '@docsearch/css@3.9.0': resolution: {integrity: sha512-cQbnVbq0rrBwNAKegIac/t6a8nWoUAn8frnkLFW6YARaRmAQr5/Eoe6Ln2fqkUCZ40KpdrKbpSAmgrkviOxuWA==} - '@docsearch/js@3.9.0': - resolution: {integrity: sha512-4bKHcye6EkLgRE8ze0vcdshmEqxeiJM77M0JXjef7lrYZfSlMunrDOCqyLjiZyo1+c0BhUqA2QpFartIjuHIjw==} - - '@docsearch/react@3.9.0': - resolution: {integrity: sha512-mb5FOZYZIkRQ6s/NWnM98k879vu5pscWqTLubLFBO87igYYT4VzVazh4h5o/zCvTIZgEt3PvsCOMOswOUo9yHQ==} - peerDependencies: - '@types/react': '>= 16.8.0 < 20.0.0' - react: '>= 16.8.0 < 20.0.0' - react-dom: '>= 16.8.0 < 20.0.0' - search-insights: '>= 1 < 3' - peerDependenciesMeta: - '@types/react': - optional: true - react: - optional: true - react-dom: - optional: true - search-insights: - optional: true - '@esbuild/aix-ppc64@0.20.2': resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} engines: {node: '>=12'} @@ -1972,10 +1877,6 @@ packages: resolution: {integrity: sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==} engines: {node: '>= 14'} - algoliasearch@5.20.3: - resolution: {integrity: sha512-iNC6BGvipaalFfDfDnXUje8GUlW5asj0cTMsZJwO/0rhsyLx1L7GZFAY8wW+eQ6AM4Yge2p5GSE5hrBlfSD90Q==} - engines: {node: '>= 14.0.0'} - ansi-align@3.0.1: resolution: {integrity: sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==} @@ -3569,9 +3470,6 @@ packages: resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==} engines: {node: ^10 || ^12 || >=14} - preact@10.26.2: - resolution: {integrity: sha512-0gNmv4qpS9HaN3+40CLBAnKe0ZfyE4ZWo5xKlC1rVrr0ckkEvJvAQqKaHANdFKsGstoxrY4AItZ7kZSGVoVjgg==} - prettier@4.0.0-alpha.10: resolution: {integrity: sha512-auyI68pnS9LmLRQCRuRBQaoqWU3Jnrifbhc+patuIGd1gzB/5h2CW1fa3Lub45R03ah+wzxbB2DNV1S1wzz9QQ==} engines: {node: '>=14'} @@ -4559,110 +4457,6 @@ packages: snapshots: - '@algolia/autocomplete-core@1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3)': - dependencies: - '@algolia/autocomplete-plugin-algolia-insights': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - transitivePeerDependencies: - - '@algolia/client-search' - - algoliasearch - - search-insights - - '@algolia/autocomplete-plugin-algolia-insights@1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3)': - dependencies: - '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - transitivePeerDependencies: - - '@algolia/client-search' - - algoliasearch - - '@algolia/autocomplete-preset-algolia@1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3)': - dependencies: - '@algolia/autocomplete-shared': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - '@algolia/client-search': 5.20.3 - algoliasearch: 5.20.3 - - '@algolia/autocomplete-shared@1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3)': - dependencies: - '@algolia/client-search': 5.20.3 - algoliasearch: 5.20.3 - - '@algolia/client-abtesting@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/client-analytics@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/client-common@5.20.3': {} - - '@algolia/client-insights@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/client-personalization@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/client-query-suggestions@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/client-search@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/ingestion@1.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/monitoring@1.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/recommend@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - - '@algolia/requester-browser-xhr@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - - '@algolia/requester-fetch@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - - '@algolia/requester-node-http@5.20.3': - dependencies: - '@algolia/client-common': 5.20.3 - '@alloc/quick-lru@5.2.0': {} '@ampproject/remapping@2.3.0': @@ -5074,26 +4868,6 @@ snapshots: '@docsearch/css@3.9.0': {} - '@docsearch/js@3.9.0(@algolia/client-search@5.20.3)': - dependencies: - '@docsearch/react': 3.9.0(@algolia/client-search@5.20.3) - preact: 10.26.2 - transitivePeerDependencies: - - '@algolia/client-search' - - '@types/react' - - react - - react-dom - - search-insights - - '@docsearch/react@3.9.0(@algolia/client-search@5.20.3)': - dependencies: - '@algolia/autocomplete-core': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - '@algolia/autocomplete-preset-algolia': 1.17.9(@algolia/client-search@5.20.3)(algoliasearch@5.20.3) - '@docsearch/css': 3.9.0 - algoliasearch: 5.20.3 - transitivePeerDependencies: - - '@algolia/client-search' - '@esbuild/aix-ppc64@0.20.2': optional: true @@ -6418,22 +6192,6 @@ snapshots: agent-base@7.1.3: {} - algoliasearch@5.20.3: - dependencies: - '@algolia/client-abtesting': 5.20.3 - '@algolia/client-analytics': 5.20.3 - '@algolia/client-common': 5.20.3 - '@algolia/client-insights': 5.20.3 - '@algolia/client-personalization': 5.20.3 - '@algolia/client-query-suggestions': 5.20.3 - '@algolia/client-search': 5.20.3 - '@algolia/ingestion': 1.20.3 - '@algolia/monitoring': 1.20.3 - '@algolia/recommend': 5.20.3 - '@algolia/requester-browser-xhr': 5.20.3 - '@algolia/requester-fetch': 5.20.3 - '@algolia/requester-node-http': 5.20.3 - ansi-align@3.0.1: dependencies: string-width: 4.2.3 @@ -8511,8 +8269,6 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - preact@10.26.2: {} - prettier@4.0.0-alpha.10: dependencies: '@prettier/cli': 0.6.0(prettier@4.0.0-alpha.10) diff --git a/src/config/sidebar.ts b/src/config/sidebar.ts index b34a5cc..33bb2d4 100644 --- a/src/config/sidebar.ts +++ b/src/config/sidebar.ts @@ -1,3 +1,7 @@ +import { lstatSync, readdirSync } from "node:fs"; +import path from "node:path"; +import matter from "gray-matter"; + export type SidebarConfig = | Item[] | Record<`/${string}`, Item[]>; @@ -17,3 +21,109 @@ export interface SidebarItemSection { collapsed?: boolean; base?: string; } + +export type SidebarItemWithMeta = SidebarItem & { + filePath: string; + matterData?: any; +} + +export interface FilesystemSidebarOptions { + filter?: (item: SidebarItemWithMeta) => boolean; + sort?: (a: SidebarItemWithMeta, b: SidebarItemWithMeta) => number; +} + +const ROUTES_FOLDER = import.meta.resolve("./src/routes/").substring("file:".length); + +export function createFilesystemSidebar(route: string, options?: FilesystemSidebarOptions): Item[] { + const folder = path.join(ROUTES_FOLDER, route); + + const resolvedOptions: Required = { + filter: (item) => { + console.log("AAAAAAAAA", item.matterData) + return item.matterData?.excludeFromSidebar !== true + }, + sort: (a, b) => { + if (stripExtension(a.filePath).endsWith("index")) return -1; + if (a.filePath > b.filePath) return 1; + if (b.filePath > a.filePath) return -1; + return 0; + }, + ...options + } + + const items = readdirSync(folder).flatMap((file) => { + return traverse(path.join(folder, file), folder, resolvedOptions); + }).filter(Boolean) as SidebarItemWithMeta[]; + + + const transform = (items: SidebarItemWithMeta[]): Item[] => { + return items.filter(resolvedOptions.filter).sort(resolvedOptions.sort).map((item) => { + if ("items" in item) return (stripMeta({ ...item, items: transform(item.items as SidebarItemWithMeta[]) as SidebarItem[]})); + return stripMeta(item); + }) as Item[]; + } + + return transform(items); +} + +function traverse(filePath: string, baseFolder: string, options: Required): SidebarItemWithMeta | SidebarItemWithMeta[] | undefined { + const title = formatTitle(path.basename(filePath)); + + if (title.includes("[...")) return; + + if (lstatSync(filePath).isFile()) { + const matterData = getMatterData(filePath); + + return { + title: getMatterData(filePath).title ?? title, + link: `/${removeParenthesesGroups(stripExtension(path.relative(baseFolder, filePath)))}`.replace(/\/index$/, "").replaceAll("//", "/"), + filePath, + matterData, + }; + } + + const items = + (readdirSync(filePath).flatMap((file) => { + return traverse(path.join(filePath, file), baseFolder, options); + }).filter(Boolean) as SidebarItemWithMeta[]); + + if (title === "") { + return items; + } + + return { + title, + items, + filePath, + }; +} + +function stripExtension(filePath: string): string { + return `${path.parse(filePath).dir}/${path.parse(filePath).name}`; +} + +function getMatterData(filePath: string): { title?: string } & {} { + return matter.read(filePath).data; +} + +function formatTitle(filePath: string): string { + return removeParenthesesGroups( + stripExtension(filePath) + .substring(1) + .split("-") + .map((s) => s.charAt(0).toUpperCase() + s.slice(1)) + .join(" "), + ); +} + +function removeParenthesesGroups(s: string) { + return s.replaceAll(/\((\w|-)+\)/g, "").replaceAll("//", "/"); +} + +function stripMeta(item: SidebarItemWithMeta): SidebarItem { + const stripped = item as any; + stripped.filePath = undefined; + stripped.matterData = undefined; + + return item; +} diff --git a/src/default-theme/components/DocSearch.css b/src/default-theme/components/DocSearch.css deleted file mode 100644 index 7a50940..0000000 --- a/src/default-theme/components/DocSearch.css +++ /dev/null @@ -1,216 +0,0 @@ -/* Credit: https://github.com/vuejs/vitepress/blob/83ce1b8c5e95d2e29e733d9312f514d725fe7f0b/src/client/theme-default/components/VPNavBarSearch.vue */ - -@import "@docsearch/css"; - -:root { - --sb-docsearch-text-light-1: rgba(60, 60, 67); - --sb-docsearch-text-light-2: rgba(60, 60, 67, 0.75); - --sb-docsearch-text-dark-1: rgba(255, 255, 245, 0.86); - --sb-docsearch-text-dark-2: rgba(235, 235, 245, 0.6); - --sb-docsearch-bg: #ffffff; - --sb-docsearch-bg-soft: #f6f6f7; - --sb-docsearch-bg-soft-mute: #e3e3e5; - --sb-docsearch-bg-alt: #f6f6f7; - --sb-docsearch-divider: rgba(60, 60, 67, 0.12); - --sb-docsearch-text-1: var(--sb-docsearch-text-light-1); - --sb-docsearch-text-2: var(--sb-docsearch-text-light-2); - --sb-docsearch-brand: #0284c7; -} - -[data-theme*="dark"] { - --sb-docsearch-bg: #1e1e20; - --sb-docsearch-bg-soft: #252529; - --sb-docsearch-bg-soft-mute: #313136; - --sb-docsearch-bg-alt: #27272a; - --sb-docsearch-divider: rgba(82, 82, 89, 0.32); - --sb-docsearch-text-1: var(--sb-docsearch-text-dark-1); - --sb-docsearch-text-2: var(--sb-docsearch-text-dark-2); -} - -.DocSearch { - --docsearch-primary-color: var(--sb-docsearch-brand); - --docsearch-highlight-color: var(--docsearch-primary-color); - --docsearch-text-color: var(--sb-docsearch-text-1); - --docsearch-muted-color: var(--sb-docsearch-text-2); - --docsearch-searchbox-shadow: none; - --docsearch-searchbox-focus-background: transparent; - --docsearch-key-gradient: transparent; - --docsearch-key-shadow: none; - --docsearch-modal-background: var(--sb-docsearch-bg-soft); - --docsearch-footer-background: var(--sb-docsearch-bg); -} - -[data-theme*="dark"] .DocSearch { - --docsearch-modal-shadow: none; - --docsearch-footer-shadow: none; - --docsearch-logo-color: var(--sb-docsearch-text-2); - --docsearch-hit-background: var(--sb-docsearch-bg-soft-mute); - --docsearch-hit-color: var(--sb-docsearch-text-2); - --docsearch-hit-shadow: none; -} - -.DocSearch-Button { - display: flex; - justify-content: center; - align-items: center; - margin: 0; - padding: 0; - width: 32px; - height: 40px; - background: transparent; - transition: border-color 0.25s; -} - -.DocSearch-Button:hover { - background: transparent; -} - -.DocSearch-Button:focus { - outline: 1px dotted; - outline: 5px auto -webkit-focus-ring-color; -} - -.DocSearch-Button:focus:not(:focus-visible) { - outline: none !important; -} - -@media (min-width: 768px) { - .DocSearch-Button.DocSearch-Button { - justify-content: flex-start; - border: 1px solid transparent; - border-radius: 8px; - padding: 0 10px 0 12px; - width: 100%; - height: 40px; - background-color: var(--sb-docsearch-bg-alt); - } - - .DocSearch-Button:hover { - border-color: var(--sb-docsearch-brand); - background: var(--sb-docsearch-bg-alt); - } -} - -.DocSearch-Button .DocSearch-Button-Container { - display: flex; - align-items: center; -} - -.DocSearch-Button .DocSearch-Search-Icon { - position: relative; - width: 16px; - height: 16px; - color: var(--sb-docsearch-text-1); - fill: currentColor; - transition: color 0.5s; -} - -.DocSearch-Button:hover .DocSearch-Search-Icon { - color: var(--sb-docsearch-text-1); -} - -@media (min-width: 768px) { - .DocSearch-Button .DocSearch-Search-Icon { - top: 1px; - margin-right: 8px; - width: 14px; - height: 14px; - color: var(--sb-docsearch-text-2); - } -} - -.DocSearch-Button .DocSearch-Button-Placeholder { - display: none; - margin-top: 2px; - padding: 0 16px 0 0; - font-size: 13px; - font-weight: 500; - color: var(--sb-docsearch-text-2); - transition: color 0.5s; -} - -.DocSearch-Button:hover .DocSearch-Button-Placeholder { - color: var(--sb-docsearch-text-1); -} - -@media (min-width: 768px) { - .DocSearch-Button .DocSearch-Button-Placeholder { - display: inline-block; - } -} - -.DocSearch-Button .DocSearch-Button-Keys { - /*rtl:ignore*/ - direction: ltr; - display: none; - min-width: auto; -} - -@media (min-width: 768px) { - .DocSearch-Button .DocSearch-Button-Keys { - display: flex; - align-items: center; - } -} - -.DocSearch-Button .DocSearch-Button-Key { - @apply font-sans; - display: block; - margin: 2px 0 0 0; - border: 1px solid var(--sb-docsearch-divider); - /*rtl:begin:ignore*/ - border-right: none; - border-radius: 4px 0 0 4px; - padding-left: 6px; - /*rtl:end:ignore*/ - min-width: 0; - width: auto; - height: 22px; - line-height: 22px; - font-size: 12px; - font-weight: 500; - transition: color 0.5s, border-color 0.5s; -} - -.DocSearch-Button .DocSearch-Button-Key + .DocSearch-Button-Key { - /*rtl:begin:ignore*/ - border-right: 1px solid var(--sb-docsearch-divider); - border-left: none; - border-radius: 0 4px 4px 0; - padding-left: 2px; - padding-right: 6px; - /*rtl:end:ignore*/ -} -.DocSearch-Button .DocSearch-Button-Key:first-child { - font-size: 1px; - letter-spacing: -12px; - color: transparent; -} - -.DocSearch-Button .DocSearch-Button-Key:first-child:after { - content: "⌘"; - font-size: 12px; - letter-spacing: normal; - color: var(--docsearch-muted-color); -} - -.DocSearch-Button .DocSearch-Button-Key:first-child > * { - display: none; -} - -[data-theme*="dark"] .DocSearch-Footer { - border-top: 1px solid var(--sb-docsearch-divider); -} - -.DocSearch-Form { - border: 1px solid var(--sb-docsearch-brand); - background-color: #fff; -} - -[data-theme*="dark"] .DocSearch-Form { - background-color: var(--sb-docsearch-bg-soft-mute); -} - -.DocSearch-Screen-Icon > svg { - margin: auto; -} diff --git a/src/default-theme/components/DocSearch.tsx b/src/default-theme/components/DocSearch.tsx deleted file mode 100644 index 7a4f441..0000000 --- a/src/default-theme/components/DocSearch.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import docsearch from "@docsearch/js"; -import { onMount } from "solid-js"; - -import "./DocSearch.css"; -import { useRouteConfig } from "../utils"; - -export default function DocSearch() { - const config = useRouteConfig(); - - onMount(() => { - const search = config().themeConfig?.search; - if (!search || search.provider !== "algolia") return; - - docsearch({ ...search.options, container: "#docsearch" }); - }); - - return
; -} diff --git a/src/default-theme/components/Header.tsx b/src/default-theme/components/Header.tsx index 62cf373..b046cf9 100644 --- a/src/default-theme/components/Header.tsx +++ b/src/default-theme/components/Header.tsx @@ -13,8 +13,6 @@ import { useRouteConfig } from "../utils"; import { useSidebar } from "../../client/sidebar"; import styles from "./Header.module.css"; -const DocSearch = lazy(() => import("./DocSearch")); - export default function Header() { const [tocRef, setTocRef] = createSignal(); const [navRef, setNavRef] = createSignal(); @@ -100,9 +98,6 @@ export default function Header() { - {config().themeConfig?.search?.provider === "algolia" && ( - - )} {(nav) => ( diff --git a/src/default-theme/index.ts b/src/default-theme/index.ts index 6cc1182..8efe55c 100644 --- a/src/default-theme/index.ts +++ b/src/default-theme/index.ts @@ -116,15 +116,7 @@ const defaultTheme: ThemeDefinition = defineTheme({ }); export default defaultTheme; -export type SearchConfig = { - provider: "algolia"; - options: DocSearchOptions; -}; -export interface DocSearchOptions { - appId: string; - apiKey: string; - indexName: string; -} +export type SearchConfig = {}; export type NavItem = { text: string; From 244dbbc105b2267a15ba2452084ada7925f36859 Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Sun, 12 Oct 2025 21:42:45 +0200 Subject: [PATCH 2/4] style: format --- docs/app.config.ts | 5 ++-- src/config/sidebar.ts | 68 ++++++++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/docs/app.config.ts b/docs/app.config.ts index c500575..2f39827 100644 --- a/docs/app.config.ts +++ b/docs/app.config.ts @@ -3,8 +3,8 @@ import { defineConfig } from "@solidjs/start/config"; import arraybuffer from "vite-plugin-arraybuffer"; import { createWithSolidBase, defineTheme } from "../src/config"; +import { SidebarConfig, createFilesystemSidebar } from "../src/config/sidebar"; import defaultTheme, { DefaultThemeSidebarItem } from "../src/default-theme"; -import { createFilesystemSidebar, SidebarConfig } from "../src/config/sidebar"; const theme = defineTheme({ componentsPath: import.meta.resolve("./src/solidbase-theme"), @@ -106,7 +106,6 @@ export default defineConfig( ), ); - function customFSSidebar(route: string, title: string) { const sidebar = createFilesystemSidebar(route); @@ -115,6 +114,6 @@ function customFSSidebar(route: string, title: string) { title, items: sidebar.filter((i) => !("items" in i)), }, - ...sidebar.filter((i) => ("items" in i)) + ...sidebar.filter((i) => "items" in i), ]; } diff --git a/src/config/sidebar.ts b/src/config/sidebar.ts index 33bb2d4..41b566f 100644 --- a/src/config/sidebar.ts +++ b/src/config/sidebar.ts @@ -25,22 +25,27 @@ export interface SidebarItemSection { export type SidebarItemWithMeta = SidebarItem & { filePath: string; matterData?: any; -} +}; export interface FilesystemSidebarOptions { filter?: (item: SidebarItemWithMeta) => boolean; sort?: (a: SidebarItemWithMeta, b: SidebarItemWithMeta) => number; } -const ROUTES_FOLDER = import.meta.resolve("./src/routes/").substring("file:".length); +const ROUTES_FOLDER = import.meta + .resolve("./src/routes/") + .substring("file:".length); -export function createFilesystemSidebar(route: string, options?: FilesystemSidebarOptions): Item[] { +export function createFilesystemSidebar( + route: string, + options?: FilesystemSidebarOptions, +): Item[] { const folder = path.join(ROUTES_FOLDER, route); const resolvedOptions: Required = { filter: (item) => { - console.log("AAAAAAAAA", item.matterData) - return item.matterData?.excludeFromSidebar !== true + console.log("AAAAAAAAA", item.matterData); + return item.matterData?.excludeFromSidebar !== true; }, sort: (a, b) => { if (stripExtension(a.filePath).endsWith("index")) return -1; @@ -48,25 +53,39 @@ export function createFilesystemSidebar(route: string, optio if (b.filePath > a.filePath) return -1; return 0; }, - ...options - } - - const items = readdirSync(folder).flatMap((file) => { - return traverse(path.join(folder, file), folder, resolvedOptions); - }).filter(Boolean) as SidebarItemWithMeta[]; + ...options, + }; + const items = readdirSync(folder) + .flatMap((file) => { + return traverse(path.join(folder, file), folder, resolvedOptions); + }) + .filter(Boolean) as SidebarItemWithMeta[]; const transform = (items: SidebarItemWithMeta[]): Item[] => { - return items.filter(resolvedOptions.filter).sort(resolvedOptions.sort).map((item) => { - if ("items" in item) return (stripMeta({ ...item, items: transform(item.items as SidebarItemWithMeta[]) as SidebarItem[]})); - return stripMeta(item); - }) as Item[]; - } + return items + .filter(resolvedOptions.filter) + .sort(resolvedOptions.sort) + .map((item) => { + if ("items" in item) + return stripMeta({ + ...item, + items: transform( + item.items as SidebarItemWithMeta[], + ) as SidebarItem[], + }); + return stripMeta(item); + }) as Item[]; + }; return transform(items); } -function traverse(filePath: string, baseFolder: string, options: Required): SidebarItemWithMeta | SidebarItemWithMeta[] | undefined { +function traverse( + filePath: string, + baseFolder: string, + options: Required, +): SidebarItemWithMeta | SidebarItemWithMeta[] | undefined { const title = formatTitle(path.basename(filePath)); if (title.includes("[...")) return; @@ -76,16 +95,19 @@ function traverse(filePath: string, baseFolder: string, options: Required { - return traverse(path.join(filePath, file), baseFolder, options); - }).filter(Boolean) as SidebarItemWithMeta[]); + const items = readdirSync(filePath) + .flatMap((file) => { + return traverse(path.join(filePath, file), baseFolder, options); + }) + .filter(Boolean) as SidebarItemWithMeta[]; if (title === "") { return items; @@ -117,7 +139,7 @@ function formatTitle(filePath: string): string { } function removeParenthesesGroups(s: string) { - return s.replaceAll(/\((\w|-)+\)/g, "").replaceAll("//", "/"); + return s.replaceAll(/\((\w|-|_)+\)/g, "").replaceAll("//", "/"); } function stripMeta(item: SidebarItemWithMeta): SidebarItem { From 802c6cec49350469ca39032155b332cf1faf865f Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Mon, 13 Oct 2025 14:28:29 +0200 Subject: [PATCH 3/4] chore: css touch ups --- docs/app.config.ts | 16 +- docs/src/routes/guide/(4)deploy.mdx | 3 +- .../src/routes/guide/features/(0)markdown.mdx | 255 ++++++++++++++---- src/config/sidebar.ts | 1 - src/default-theme/Layout.module.css | 7 +- 5 files changed, 201 insertions(+), 81 deletions(-) diff --git a/docs/app.config.ts b/docs/app.config.ts index 2f39827..a0709c4 100644 --- a/docs/app.config.ts +++ b/docs/app.config.ts @@ -98,22 +98,10 @@ export default defineConfig( }, ], sidebar: { - "/guide": customFSSidebar("/guide", "Overview"), - "/reference": customFSSidebar("/reference", "Reference"), + "/guide": createFilesystemSidebar("/guide"), + "/reference": createFilesystemSidebar("/reference"), }, }, }, ), ); - -function customFSSidebar(route: string, title: string) { - const sidebar = createFilesystemSidebar(route); - - return [ - { - title, - items: sidebar.filter((i) => !("items" in i)), - }, - ...sidebar.filter((i) => "items" in i), - ]; -} diff --git a/docs/src/routes/guide/(4)deploy.mdx b/docs/src/routes/guide/(4)deploy.mdx index f805947..5d2eff8 100644 --- a/docs/src/routes/guide/(4)deploy.mdx +++ b/docs/src/routes/guide/(4)deploy.mdx @@ -4,5 +4,4 @@ title: Deploy # {frontmatter.title} -A SolidBase app can be deployed anywhere a SolidStart app can be deployed. You can use [Nitro's](https://nitro.build/deploy) in your `app.config.ts` to add presets to deploy your app to various platforms. - +A SolidBase app can be deployed anywhere a SolidStart app can be deployed. You can use [Nitro](https://nitro.build/deploy) in your `app.config.ts` to add presets to deploy your app to various platforms. diff --git a/docs/src/routes/guide/features/(0)markdown.mdx b/docs/src/routes/guide/features/(0)markdown.mdx index 6701e1a..fb10d92 100644 --- a/docs/src/routes/guide/features/(0)markdown.mdx +++ b/docs/src/routes/guide/features/(0)markdown.mdx @@ -71,93 +71,193 @@ You can automatically generate a table of contents (ToC) for your markdown files Directives are custom blocks that can be used to highlight important information, warnings, tips, and more. They are similar to callouts or alerts in other documentation systems. -**Input** -```md +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md :::info Highlights information that users should take into account, even when skimming. ::: +```` +:::: -:::tip -Optional information to help a user be more successful. -::: - -:::important -Crucial information necessary for users to succeed. -::: - -:::warning -Critical content demanding immediate user attention due to potential risks. -::: - -:::danger -Negative potential consequences of an action. -::: - -:::details -This is a details block. -::: -``` - -**Output** +::::tab[HTML Output] :::info Highlights information that users should take into account, even when skimming. ::: +:::: +::::: + +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md +:::tip +Optional information to help a user be more successful. +::: +```` +:::: +::::tab[HTML Output] :::tip Optional information to help a user be more successful. ::: +:::: +::::: +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md :::important Crucial information necessary for users to succeed. ::: +```` +:::: +::::tab[HTML Output] +:::important +Crucial information necessary for users to succeed. +::: +:::: +::::: + +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md :::warning Critical content demanding immediate user attention due to potential risks. ::: +```` +:::: + +::::tab[HTML Output] +:::warning +Critical content demanding immediate user attention due to potential risks. +::: +:::: +::::: + +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md +:::danger +Negative potential consequences of an action. +::: +```` +:::: +::::tab[HTML Output] :::danger Negative potential consequences of an action. ::: +:::: +::::: + +:::::tab-group[features-demo-directives] +::::tab[Markdown] +````md :::details This is a details block. ::: +```` +:::: + +::::tab[HTML Output] +:::details +This is a details block. +::: +:::: +::::: ### Custom Directive Titles To set a custom title for a directive, use square brackets `[]` immediately after the directive type. -**Input** -```md +:::::tab-group[features-demo-directives-titles] +::::tab[Markdown] +````md :::info[Custom Title] Highlights information that users should take into account, even when skimming. ::: +```` +:::: + +::::tab[HTML Output] +:::info[Custom Title] +Highlights information that users should take into account, even when skimming. +::: +:::: +::::: + + + +:::::tab-group[features-demo-directives-titles] +::::tab[Markdown] +````md +:::tip[] +This is a tip with no title. +::: +```` +:::: +::::tab[HTML Output] :::tip[] This is a tip with no title. ::: +:::: +::::: + +:::::tab-group[features-demo-directives-titles] +::::tab[Markdown] +````md :::details[Click me to view] This is a details block. ::: -``` +```` +:::: -**Output** +::::tab[HTML Output] +:::details[Click me to view] +This is a details block. +::: +:::: +::::: -:::info[Custom Title] -Highlights information that users should take into account, even when skimming. +## Tabs + +::::::tab-group +:::::tab[Markdown] + +````mdx +::::tab-group[key] +:::tab[Title A] +Hey I'm A ::: -:::tip[] -This is a tip with no title. +:::tab[Title B] +Hi this is B ::: +:::: +```` +::::: -:::details[Click me to view] -This is a details block. +:::::tab[HTML Output] +::::tab-group +:::tab[Title A] +Hey I'm A +::: + +:::tab[Title B] +Hi this is B ::: +:::: +::::: +:::::: + +`[key]` is used for syncing and persistance. ## GitHub Flavored Markown @@ -167,59 +267,98 @@ In addition to the standard markdown syntax, SolidBase also supports several Git In addition to the directives above, SolidBase also supports [GitHub-flavored alerts](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts). These alerts can render as callouts with similar styles to the [directives above](#directives). -```md +:::::tab-group[features-demo-directives-gfm] +::::tab[Markdown] +````md > [!NOTE] > Highlights information that users should take into account, even when skimming. +```` +:::: -> [!TIP] -> Optional information to help a user be more successful. - -> [!IMPORTANT] -> Crucial information necessary for users to succeed. - -> [!WARNING] -> Critical content demanding immediate user attention due to potential risks. - -> [!CAUTION] -> Negative potential consequences of an action. -``` - +::::tab[HTML Output] {/* prettier-ignore */} > [!NOTE] > Highlights information that users should take into account, even when skimming. +:::: +::::: + +:::::tab-group[features-demo-directives-gfm] +::::tab[Markdown] +````md +> [!TIP] +> Optional information to help a user be more successful. +```` +:::: + +::::tab[HTML Output] {/* prettier-ignore */} > [!TIP] > Optional information to help a user be more successful. +:::: +::::: + +:::::tab-group[features-demo-directives-gfm] +::::tab[Markdown] +````md +> [!IMPORTANT] +> Crucial information necessary for users to succeed. +```` +:::: +::::tab[HTML Output] {/* prettier-ignore */} > [!IMPORTANT] > Crucial information necessary for users to succeed. +:::: +::::: +:::::tab-group[features-demo-directives-gfm] +::::tab[Markdown] +````md +> [!WARNING] +> Critical content demanding immediate user attention due to potential risks. + +```` +:::: + +::::tab[HTML Output] {/* prettier-ignore */} > [!WARNING] > Critical content demanding immediate user attention due to potential risks. +:::: +::::: +:::::tab-group[features-demo-directives-gfm] +::::tab[Markdown] +````md +> [!CAUTION] +> Negative potential consequences of an action. +```` +:::: + +::::tab[HTML Output] {/* prettier-ignore */} > [!CAUTION] > Negative potential consequences of an action. +:::: +::::: ### Autolinks -SolidBase is able to automatically detect and convert URLs into clickable links. This works for URLs containing the protocol (e.g., `https://example.com`) as well as those without (e.g., `www.example.com` or `example.com`). - -**Input** +SolidBase is able to automatically detect and convert URLs into clickable links. -```md -start.solidjs.com +::::tab-group +:::tab[Markdown] +````md https://github.com/kobaltedev/solidbase -``` - -**Output** - -start.solidjs.com +```` +::: +:::tab[HTML Output] https://github.com/kobaltedev/solidbase +::: +:::: ### Tables diff --git a/src/config/sidebar.ts b/src/config/sidebar.ts index 41b566f..e833e00 100644 --- a/src/config/sidebar.ts +++ b/src/config/sidebar.ts @@ -44,7 +44,6 @@ export function createFilesystemSidebar( const resolvedOptions: Required = { filter: (item) => { - console.log("AAAAAAAAA", item.matterData); return item.matterData?.excludeFromSidebar !== true; }, sort: (a, b) => { diff --git a/src/default-theme/Layout.module.css b/src/default-theme/Layout.module.css index bef378f..83f736c 100644 --- a/src/default-theme/Layout.module.css +++ b/src/default-theme/Layout.module.css @@ -110,7 +110,7 @@ display: flex; justify-content: space-between; align-items: center; - margin-bottom: .5rem; + margin: 1rem 0 .5rem; width: 100%; &:hover, @@ -151,10 +151,6 @@ font-weight: 500; } - &:has(h2) { - margin-bottom: 1rem; - } - &[data-expanded] { svg { transform: rotateX(180deg); @@ -208,7 +204,6 @@ & > ul { display: flex; flex-direction: column; - gap: 1rem; ul { padding-left: .5rem; From 3e64c84af946af975891cc9bea80b78fec01b37c Mon Sep 17 00:00:00 2001 From: jer3m01 Date: Mon, 13 Oct 2025 18:41:16 +0200 Subject: [PATCH 4/4] feat: update dave --- docs/src/routes/guide/dave.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/routes/guide/dave.mdx b/docs/src/routes/guide/dave.mdx index de98001..2a20e85 100644 --- a/docs/src/routes/guide/dave.mdx +++ b/docs/src/routes/guide/dave.mdx @@ -3,6 +3,6 @@ title: What are we missing? excludeFromSidebar: true --- -# Day 1088 of asking for an internal shitpost channel +# Day 1 of asking for solidconf [[toc]]