11import { defineConfig } from "@solidjs/start/config" ;
2- import remarkFrontmatter from "remark-frontmatter" ;
3- import rehypeRaw from "rehype-raw" ;
4- import { nodeTypes } from "@mdx-js/mdx" ;
5- import remarkGfm from "remark-gfm" ;
6- import remarkExpressiveCode , {
7- ExpressiveCodeTheme ,
8- } from "remark-expressive-code" ;
9- import rehypeSlug from "rehype-slug" ;
10- import rehypeAutoLinkHeadings from "rehype-autolink-headings" ;
112
12- // @ts -expect-error missing types
13- import pkg from "@vinxi/plugin-mdx" ;
3+ import { createWithSolidBase , defineTheme } from "@kobalte/solidbase/config" ;
144
15- const { default : vinxiMdx } = pkg ;
165import tree from "./.solid/tree" ;
176import entries from "./.solid/flat-entries" ;
187import solidstartEntries from "./.solid/solid-start-flat-entries" ;
@@ -27,7 +16,7 @@ function docsData() {
2716 const resolveVirtualModuleId = "\0" + virtualModuleId ;
2817
2918 return {
30- name : "solid:collection" ,
19+ name : virtualModuleId ,
3120 resolveId ( id : string ) {
3221 if ( id === virtualModuleId ) {
3322 return resolveVirtualModuleId ;
@@ -50,61 +39,73 @@ function docsData() {
5039 } ;
5140}
5241
53- export default defineConfig ( {
54- middleware : "src/middleware/index.ts" ,
55- server : {
56- preset : "netlify" ,
57- prerender : {
58- crawlLinks : true ,
59- autoSubfolderIndex : false ,
60- failOnError : true ,
61- // eslint-disable-next-line no-useless-escape
62- ignore : [ / \{ \g e t P a t h } / , / .* ?e m o j i S v g \( .* / ] ,
42+ const theme = defineTheme ( {
43+ componentsPath : import . meta. resolve ( "./src/solidbase-theme" ) ,
44+ } ) ;
45+ export default defineConfig (
46+ createWithSolidBase ( theme ) (
47+ {
48+ ssr : true ,
49+ middleware : "src/middleware/index.ts" ,
50+ server : {
51+ preset : "netlify" ,
52+ prerender : {
53+ crawlLinks : true ,
54+ autoSubfolderIndex : false ,
55+ failOnError : true ,
56+ // eslint-disable-next-line no-useless-escape
57+ ignore : [ / \{ \g e t P a t h } / , / .* ?e m o j i S v g \( .* / ] ,
58+ } ,
59+ } ,
60+ vite : {
61+ plugins : [ docsData ( ) , heroCodeSnippet ( ) ] ,
62+ } ,
6363 } ,
64- } ,
65- extensions : [ "mdx" , "md" , "tsx" ] ,
66- vite : ( ) => ( {
67- plugins : [
68- docsData ( ) ,
69- vinxiMdx . withImports ( { } ) ( {
70- define : {
71- "import.meta.env" : "'import.meta.env'" ,
64+ {
65+ title : "Solid Docs" ,
66+ editPath : "https://github.com/solidjs/solid-docs/edit/main/:path" ,
67+ markdown : {
68+ expressiveCode : {
69+ themes : [ "min-light" , "material-theme-ocean" ] ,
70+ themeCssSelector : ( theme ) => `[data-theme=" ${ theme . type } "]` ,
71+ frames : false ,
7272 } ,
73- jsx : true ,
74- jsxImportSource : "solid-js" ,
75- providerImportSource : "solid-mdx" ,
76- rehypePlugins : [
77- [
78- rehypeRaw ,
79- {
80- passThrough : nodeTypes ,
81- } ,
82- ] ,
83- [ rehypeSlug ] ,
84- [
85- rehypeAutoLinkHeadings ,
86- {
87- behavior : "wrap" ,
88- properties : {
89- className : "heading" ,
90- } ,
91- } ,
92- ] ,
93- ] ,
94- remarkPlugins : [
95- remarkFrontmatter ,
96- remarkGfm ,
97- [
98- remarkExpressiveCode ,
99- {
100- themes : [ "min-light" , "material-theme-ocean" ] ,
101- themeCSSSelector : ( theme : ExpressiveCodeTheme ) =>
102- `[data-theme="${ theme . name } "]` ,
103- } ,
104- ] ,
105- ] ,
106- } ) ,
107- { enforce : "pre" } ,
108- ] ,
109- } ) ,
110- } ) ;
73+ toc : {
74+ minDepth : 2 ,
75+ } ,
76+ } ,
77+ }
78+ )
79+ ) ;
80+
81+ import { readFile } from "node:fs/promises" ;
82+ import { codeToHtml } from "shiki" ;
83+
84+ function heroCodeSnippet ( ) {
85+ const virtualModuleId = "solid:hero-code-snippet" ;
86+ const resolveVirtualModuleId = "\0" + virtualModuleId ;
87+
88+ return {
89+ name : virtualModuleId ,
90+ resolveId ( id : string ) {
91+ if ( id === virtualModuleId ) {
92+ return resolveVirtualModuleId ;
93+ }
94+ } ,
95+ async load ( id : string ) {
96+ if ( id === resolveVirtualModuleId ) {
97+ const snippet = await readFile (
98+ "./src/ui/layout/hero-code-snippet.code" ,
99+ "utf-8"
100+ ) ;
101+
102+ const highlightedCode = await codeToHtml ( snippet . trim ( ) , {
103+ lang : "tsx" ,
104+ theme : "material-theme-ocean" ,
105+ } ) ;
106+
107+ return `export const highlightedCode = \`${ highlightedCode } \`` ;
108+ }
109+ } ,
110+ } ;
111+ }
0 commit comments