mordoc 0.1.14 → 1.0.0
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.
- package/bin/cli.js +24 -71
- package/dist/cli/asset-rewrite.d.ts +40 -0
- package/dist/cli/asset-rewrite.d.ts.map +1 -0
- package/dist/cli/asset-rewrite.js +67 -0
- package/dist/cli/asset-rewrite.js.map +1 -0
- package/dist/cli/build.d.ts +45 -15
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +186 -101
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/dev.d.ts +26 -14
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +116 -159
- package/dist/cli/dev.js.map +1 -1
- package/dist/cli/pagefind-indexer.d.ts +15 -0
- package/dist/cli/pagefind-indexer.d.ts.map +1 -0
- package/dist/cli/pagefind-indexer.js +68 -0
- package/dist/cli/pagefind-indexer.js.map +1 -0
- package/dist/cli/paths.d.ts +26 -0
- package/dist/cli/paths.d.ts.map +1 -0
- package/dist/cli/paths.js +32 -0
- package/dist/cli/paths.js.map +1 -0
- package/dist/cli/ssg-runner.d.ts +58 -0
- package/dist/cli/ssg-runner.d.ts.map +1 -0
- package/dist/cli/ssg-runner.js +126 -0
- package/dist/cli/ssg-runner.js.map +1 -0
- package/dist/config/assets-loader.d.ts +11 -0
- package/dist/config/assets-loader.d.ts.map +1 -0
- package/dist/config/assets-loader.js +46 -0
- package/dist/config/assets-loader.js.map +1 -0
- package/dist/config/language-loader.d.ts +11 -0
- package/dist/config/language-loader.d.ts.map +1 -0
- package/dist/config/language-loader.js +61 -0
- package/dist/config/language-loader.js.map +1 -0
- package/dist/config/language.d.ts +11 -0
- package/dist/config/language.d.ts.map +1 -0
- package/dist/config/language.js +61 -0
- package/dist/config/language.js.map +1 -0
- package/dist/config/sidenav-loader.d.ts +14 -0
- package/dist/config/sidenav-loader.d.ts.map +1 -0
- package/dist/config/sidenav-loader.js +78 -0
- package/dist/config/sidenav-loader.js.map +1 -0
- package/dist/config/site-loader.d.ts +11 -0
- package/dist/config/site-loader.d.ts.map +1 -0
- package/dist/config/site-loader.js +72 -0
- package/dist/config/site-loader.js.map +1 -0
- package/dist/config/site.d.ts +11 -0
- package/dist/config/site.d.ts.map +1 -0
- package/dist/config/site.js +72 -0
- package/dist/config/site.js.map +1 -0
- package/dist/config/topnav-loader.d.ts +10 -0
- package/dist/config/topnav-loader.d.ts.map +1 -0
- package/dist/config/topnav-loader.js +78 -0
- package/dist/config/topnav-loader.js.map +1 -0
- package/dist/config/translations-loader.d.ts +7 -0
- package/dist/config/translations-loader.d.ts.map +1 -0
- package/dist/config/translations-loader.js +51 -0
- package/dist/config/translations-loader.js.map +1 -0
- package/dist/content/content-loader.d.ts +16 -0
- package/dist/content/content-loader.d.ts.map +1 -0
- package/dist/content/content-loader.js +126 -0
- package/dist/content/content-loader.js.map +1 -0
- package/dist/content/content-parser.d.ts +12 -0
- package/dist/content/content-parser.d.ts.map +1 -0
- package/dist/content/content-parser.js +54 -0
- package/dist/content/content-parser.js.map +1 -0
- package/dist/content/content-transformer.d.ts +17 -0
- package/dist/content/content-transformer.d.ts.map +1 -0
- package/dist/content/content-transformer.js +94 -0
- package/dist/content/content-transformer.js.map +1 -0
- package/dist/content/markdoc-config.d.ts +13 -0
- package/dist/content/markdoc-config.d.ts.map +1 -0
- package/dist/content/markdoc-config.js +210 -0
- package/dist/content/markdoc-config.js.map +1 -0
- package/dist/content/slug.d.ts +26 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +31 -0
- package/dist/content/slug.js.map +1 -0
- package/dist/pipeline.d.ts +61 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +123 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/types/assets.d.ts +15 -0
- package/dist/types/assets.d.ts.map +1 -0
- package/dist/types/assets.js +2 -0
- package/dist/types/assets.js.map +1 -0
- package/dist/types/content.d.ts +114 -32
- package/dist/types/content.d.ts.map +1 -1
- package/dist/types/content.js +1 -6
- package/dist/types/content.js.map +1 -1
- package/dist/types/language.d.ts +9 -0
- package/dist/types/language.d.ts.map +1 -0
- package/dist/types/language.js +2 -0
- package/dist/types/language.js.map +1 -0
- package/dist/types/navigation.d.ts +24 -36
- package/dist/types/navigation.d.ts.map +1 -1
- package/dist/types/navigation.js +1 -6
- package/dist/types/navigation.js.map +1 -1
- package/dist/types/pipeline.d.ts +70 -0
- package/dist/types/pipeline.d.ts.map +1 -0
- package/dist/types/pipeline.js +2 -0
- package/dist/types/pipeline.js.map +1 -0
- package/dist/types/site.d.ts +20 -0
- package/dist/types/site.d.ts.map +1 -0
- package/dist/types/site.js +2 -0
- package/dist/types/site.js.map +1 -0
- package/dist/utils/lang-utils.d.ts +23 -0
- package/dist/utils/lang-utils.d.ts.map +1 -0
- package/dist/utils/lang-utils.js +40 -0
- package/dist/utils/lang-utils.js.map +1 -0
- package/dist/utils/paths.d.ts +25 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +31 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/vite/plugin.d.ts +93 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +435 -0
- package/dist/vite/plugin.js.map +1 -0
- package/package.json +46 -61
- package/src/app/App.module.css +82 -0
- package/src/app/App.tsx +95 -0
- package/src/app/content/Content.module.css +357 -0
- package/src/app/content/Content.tsx +212 -0
- package/src/app/content/callout/Callout.module.css +110 -0
- package/src/app/content/callout/Callout.tsx +82 -0
- package/src/app/content/card/Card.module.css +146 -0
- package/src/app/content/card/Card.tsx +110 -0
- package/src/app/content/card/CardGrid.module.css +22 -0
- package/src/app/content/card/CardGrid.tsx +34 -0
- package/src/app/content/code-block/CodeBlock.module.css +237 -0
- package/src/app/content/code-block/CodeBlock.tsx +123 -0
- package/src/app/content/heading/Heading.module.css +52 -0
- package/src/app/content/heading/Heading.tsx +75 -0
- package/src/app/content/image/Image.module.css +113 -0
- package/src/app/content/image/Image.tsx +98 -0
- package/src/app/content/link/ContentLink.tsx +46 -0
- package/src/app/data-context.tsx +39 -0
- package/src/app/entry-server.tsx +58 -0
- package/src/app/footer/Footer.module.css +36 -0
- package/src/app/footer/Footer.tsx +28 -0
- package/src/app/globals.d.ts +40 -0
- package/src/app/header/Header.module.css +205 -0
- package/src/app/header/Header.tsx +188 -0
- package/src/app/header/LanguagePicker.module.css +97 -0
- package/src/app/header/LanguagePicker.tsx +174 -0
- package/src/app/header/SearchBar.module.css +92 -0
- package/src/app/header/SearchBar.tsx +37 -0
- package/src/app/header/SearchModal.module.css +185 -0
- package/src/app/header/SearchModal.tsx +245 -0
- package/src/app/header/Topnav.module.css +37 -0
- package/src/app/header/Topnav.tsx +30 -0
- package/src/app/index.css +119 -0
- package/src/app/index.html +13 -0
- package/src/app/landing/LandingPage.module.css +14 -0
- package/src/app/landing/LandingPage.tsx +62 -0
- package/src/app/landing/button/Button.module.css +37 -0
- package/src/app/landing/button/Button.tsx +50 -0
- package/src/app/landing/hero/Hero.module.css +108 -0
- package/src/app/landing/hero/Hero.tsx +81 -0
- package/src/app/landing/section/Section.module.css +100 -0
- package/src/app/landing/section/Section.tsx +61 -0
- package/src/app/lang-utils.ts +11 -0
- package/src/app/main.tsx +67 -0
- package/src/app/not-found/NotFound.module.css +92 -0
- package/src/app/not-found/NotFound.tsx +34 -0
- package/src/app/routes.tsx +86 -0
- package/src/app/sidenav/Sidenav.module.css +239 -0
- package/src/app/sidenav/Sidenav.tsx +182 -0
- package/src/app/skeleton/Skeleton.module.css +100 -0
- package/src/app/skeleton/Skeleton.tsx +75 -0
- package/src/app/toc/Toc.module.css +59 -0
- package/src/app/toc/Toc.tsx +77 -0
- package/src/app/tsconfig.json +18 -0
- package/src/app/virtual-modules.d.ts +74 -0
- package/dist/assets/fonts/inter/Inter-Italic-VariableFont_opsz,wght.ttf +0 -0
- package/dist/assets/fonts/inter/Inter-VariableFont_opsz,wght.ttf +0 -0
- package/dist/assets/fonts/inter/OFL.txt +0 -93
- package/dist/build/Builder.d.ts +0 -92
- package/dist/build/Builder.d.ts.map +0 -1
- package/dist/build/Builder.js +0 -394
- package/dist/build/Builder.js.map +0 -1
- package/dist/build/ClientBundler.d.ts +0 -48
- package/dist/build/ClientBundler.d.ts.map +0 -1
- package/dist/build/ClientBundler.js +0 -169
- package/dist/build/ClientBundler.js.map +0 -1
- package/dist/build/HtmlGenerator.d.ts +0 -46
- package/dist/build/HtmlGenerator.d.ts.map +0 -1
- package/dist/build/HtmlGenerator.js +0 -190
- package/dist/build/HtmlGenerator.js.map +0 -1
- package/dist/build/SearchIndexer.d.ts +0 -31
- package/dist/build/SearchIndexer.d.ts.map +0 -1
- package/dist/build/SearchIndexer.js +0 -116
- package/dist/build/SearchIndexer.js.map +0 -1
- package/dist/bundles/client.js +0 -126
- package/dist/cli/create-app.d.ts +0 -14
- package/dist/cli/create-app.d.ts.map +0 -1
- package/dist/cli/create-app.js +0 -241
- package/dist/cli/create-app.js.map +0 -1
- package/dist/client/App.d.ts +0 -17
- package/dist/client/App.d.ts.map +0 -1
- package/dist/client/App.js +0 -91
- package/dist/client/App.js.map +0 -1
- package/dist/client/contexts/ConfigContext.d.ts +0 -22
- package/dist/client/contexts/ConfigContext.d.ts.map +0 -1
- package/dist/client/contexts/ConfigContext.js +0 -27
- package/dist/client/contexts/ConfigContext.js.map +0 -1
- package/dist/client/contexts/ContentContext.d.ts +0 -31
- package/dist/client/contexts/ContentContext.d.ts.map +0 -1
- package/dist/client/contexts/ContentContext.js +0 -46
- package/dist/client/contexts/ContentContext.js.map +0 -1
- package/dist/client/contexts/SearchContext.d.ts +0 -38
- package/dist/client/contexts/SearchContext.d.ts.map +0 -1
- package/dist/client/contexts/SearchContext.js +0 -185
- package/dist/client/contexts/SearchContext.js.map +0 -1
- package/dist/client/contexts/ThemeContext.d.ts +0 -23
- package/dist/client/contexts/ThemeContext.d.ts.map +0 -1
- package/dist/client/contexts/ThemeContext.js +0 -53
- package/dist/client/contexts/ThemeContext.js.map +0 -1
- package/dist/client/hooks/useContent.d.ts +0 -12
- package/dist/client/hooks/useContent.d.ts.map +0 -1
- package/dist/client/hooks/useContent.js +0 -78
- package/dist/client/hooks/useContent.js.map +0 -1
- package/dist/client/hooks/useNavigation.d.ts +0 -15
- package/dist/client/hooks/useNavigation.d.ts.map +0 -1
- package/dist/client/hooks/useNavigation.js +0 -101
- package/dist/client/hooks/useNavigation.js.map +0 -1
- package/dist/client/hooks/useSearch.d.ts +0 -22
- package/dist/client/hooks/useSearch.d.ts.map +0 -1
- package/dist/client/hooks/useSearch.js +0 -64
- package/dist/client/hooks/useSearch.js.map +0 -1
- package/dist/client/main.d.ts +0 -5
- package/dist/client/main.d.ts.map +0 -1
- package/dist/client/main.js +0 -66
- package/dist/client/main.js.map +0 -1
- package/dist/components/Callout.d.ts +0 -9
- package/dist/components/Callout.d.ts.map +0 -1
- package/dist/components/Callout.js +0 -24
- package/dist/components/Callout.js.map +0 -1
- package/dist/components/Card.d.ts +0 -10
- package/dist/components/Card.d.ts.map +0 -1
- package/dist/components/Card.js +0 -15
- package/dist/components/Card.js.map +0 -1
- package/dist/components/CardGrid.d.ts +0 -8
- package/dist/components/CardGrid.d.ts.map +0 -1
- package/dist/components/CardGrid.js +0 -9
- package/dist/components/CardGrid.js.map +0 -1
- package/dist/components/CodeBlock.d.ts +0 -28
- package/dist/components/CodeBlock.d.ts.map +0 -1
- package/dist/components/CodeBlock.js +0 -80
- package/dist/components/CodeBlock.js.map +0 -1
- package/dist/components/ContentPage.d.ts +0 -9
- package/dist/components/ContentPage.d.ts.map +0 -1
- package/dist/components/ContentPage.js +0 -105
- package/dist/components/ContentPage.js.map +0 -1
- package/dist/components/Header.d.ts +0 -14
- package/dist/components/Header.d.ts.map +0 -1
- package/dist/components/Header.js +0 -30
- package/dist/components/Header.js.map +0 -1
- package/dist/components/Heading.d.ts +0 -16
- package/dist/components/Heading.d.ts.map +0 -1
- package/dist/components/Heading.js +0 -31
- package/dist/components/Heading.js.map +0 -1
- package/dist/components/Image.d.ts +0 -8
- package/dist/components/Image.d.ts.map +0 -1
- package/dist/components/Image.js +0 -24
- package/dist/components/Image.js.map +0 -1
- package/dist/components/Layout.d.ts +0 -14
- package/dist/components/Layout.d.ts.map +0 -1
- package/dist/components/Layout.js +0 -32
- package/dist/components/Layout.js.map +0 -1
- package/dist/components/MarkdocRenderer.d.ts +0 -15
- package/dist/components/MarkdocRenderer.d.ts.map +0 -1
- package/dist/components/MarkdocRenderer.js +0 -73
- package/dist/components/MarkdocRenderer.js.map +0 -1
- package/dist/components/MobileMenu.d.ts +0 -14
- package/dist/components/MobileMenu.d.ts.map +0 -1
- package/dist/components/MobileMenu.js +0 -45
- package/dist/components/MobileMenu.js.map +0 -1
- package/dist/components/PageNavigation.d.ts +0 -9
- package/dist/components/PageNavigation.d.ts.map +0 -1
- package/dist/components/PageNavigation.js +0 -23
- package/dist/components/PageNavigation.js.map +0 -1
- package/dist/components/SearchModal.d.ts +0 -9
- package/dist/components/SearchModal.d.ts.map +0 -1
- package/dist/components/SearchModal.js +0 -74
- package/dist/components/SearchModal.js.map +0 -1
- package/dist/components/SideNav.d.ts +0 -9
- package/dist/components/SideNav.d.ts.map +0 -1
- package/dist/components/SideNav.js +0 -66
- package/dist/components/SideNav.js.map +0 -1
- package/dist/components/TableOfContents.d.ts +0 -10
- package/dist/components/TableOfContents.d.ts.map +0 -1
- package/dist/components/TableOfContents.js +0 -151
- package/dist/components/TableOfContents.js.map +0 -1
- package/dist/config/ConfigLoader.d.ts +0 -50
- package/dist/config/ConfigLoader.d.ts.map +0 -1
- package/dist/config/ConfigLoader.js +0 -214
- package/dist/config/ConfigLoader.js.map +0 -1
- package/dist/config/StyleCompiler.d.ts +0 -17
- package/dist/config/StyleCompiler.d.ts.map +0 -1
- package/dist/config/StyleCompiler.js +0 -116
- package/dist/config/StyleCompiler.js.map +0 -1
- package/dist/config/ThemeGenerator.d.ts +0 -14
- package/dist/config/ThemeGenerator.d.ts.map +0 -1
- package/dist/config/ThemeGenerator.js +0 -129
- package/dist/config/ThemeGenerator.js.map +0 -1
- package/dist/content/ContentLoader.d.ts +0 -70
- package/dist/content/ContentLoader.d.ts.map +0 -1
- package/dist/content/ContentLoader.js +0 -146
- package/dist/content/ContentLoader.js.map +0 -1
- package/dist/content/ContentProcessor.d.ts +0 -84
- package/dist/content/ContentProcessor.d.ts.map +0 -1
- package/dist/content/ContentProcessor.js +0 -387
- package/dist/content/ContentProcessor.js.map +0 -1
- package/dist/content/RouteManager.d.ts +0 -69
- package/dist/content/RouteManager.d.ts.map +0 -1
- package/dist/content/RouteManager.js +0 -143
- package/dist/content/RouteManager.js.map +0 -1
- package/dist/styles/components/callout.d.ts +0 -11
- package/dist/styles/components/callout.d.ts.map +0 -1
- package/dist/styles/components/callout.js +0 -87
- package/dist/styles/components/callout.js.map +0 -1
- package/dist/styles/components/card.d.ts +0 -11
- package/dist/styles/components/card.d.ts.map +0 -1
- package/dist/styles/components/card.js +0 -179
- package/dist/styles/components/card.js.map +0 -1
- package/dist/styles/components/codeblock.d.ts +0 -11
- package/dist/styles/components/codeblock.d.ts.map +0 -1
- package/dist/styles/components/codeblock.js +0 -251
- package/dist/styles/components/codeblock.js.map +0 -1
- package/dist/styles/components/content.d.ts +0 -11
- package/dist/styles/components/content.d.ts.map +0 -1
- package/dist/styles/components/content.js +0 -333
- package/dist/styles/components/content.js.map +0 -1
- package/dist/styles/components/fonts.d.ts +0 -11
- package/dist/styles/components/fonts.d.ts.map +0 -1
- package/dist/styles/components/fonts.js +0 -34
- package/dist/styles/components/fonts.js.map +0 -1
- package/dist/styles/components/header.d.ts +0 -11
- package/dist/styles/components/header.d.ts.map +0 -1
- package/dist/styles/components/header.js +0 -293
- package/dist/styles/components/header.js.map +0 -1
- package/dist/styles/components/heading.d.ts +0 -11
- package/dist/styles/components/heading.d.ts.map +0 -1
- package/dist/styles/components/heading.js +0 -115
- package/dist/styles/components/heading.js.map +0 -1
- package/dist/styles/components/layout.d.ts +0 -11
- package/dist/styles/components/layout.d.ts.map +0 -1
- package/dist/styles/components/layout.js +0 -79
- package/dist/styles/components/layout.js.map +0 -1
- package/dist/styles/components/mobilemenu.d.ts +0 -11
- package/dist/styles/components/mobilemenu.d.ts.map +0 -1
- package/dist/styles/components/mobilemenu.js +0 -112
- package/dist/styles/components/mobilemenu.js.map +0 -1
- package/dist/styles/components/reset.d.ts +0 -11
- package/dist/styles/components/reset.d.ts.map +0 -1
- package/dist/styles/components/reset.js +0 -131
- package/dist/styles/components/reset.js.map +0 -1
- package/dist/styles/components/searchmodal.d.ts +0 -11
- package/dist/styles/components/searchmodal.d.ts.map +0 -1
- package/dist/styles/components/searchmodal.js +0 -333
- package/dist/styles/components/searchmodal.js.map +0 -1
- package/dist/styles/components/sidenav.d.ts +0 -11
- package/dist/styles/components/sidenav.d.ts.map +0 -1
- package/dist/styles/components/sidenav.js +0 -212
- package/dist/styles/components/sidenav.js.map +0 -1
- package/dist/styles/components/toc.d.ts +0 -11
- package/dist/styles/components/toc.d.ts.map +0 -1
- package/dist/styles/components/toc.js +0 -120
- package/dist/styles/components/toc.js.map +0 -1
- package/dist/styles/components/typography.d.ts +0 -11
- package/dist/styles/components/typography.d.ts.map +0 -1
- package/dist/styles/components/typography.js +0 -248
- package/dist/styles/components/typography.js.map +0 -1
- package/dist/styles/components/utility.d.ts +0 -11
- package/dist/styles/components/utility.d.ts.map +0 -1
- package/dist/styles/components/utility.js +0 -231
- package/dist/styles/components/utility.js.map +0 -1
- package/dist/styles/types.d.ts +0 -79
- package/dist/styles/types.d.ts.map +0 -1
- package/dist/styles/types.js +0 -7
- package/dist/styles/types.js.map +0 -1
- package/dist/styles/utils.d.ts +0 -21
- package/dist/styles/utils.d.ts.map +0 -1
- package/dist/styles/utils.js +0 -50
- package/dist/styles/utils.js.map +0 -1
- package/dist/styles/variables/main.d.ts +0 -15
- package/dist/styles/variables/main.d.ts.map +0 -1
- package/dist/styles/variables/main.js +0 -116
- package/dist/styles/variables/main.js.map +0 -1
- package/dist/types/config.d.ts +0 -43
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -7
- package/dist/types/config.js.map +0 -1
- package/dist/utils/language-utils.d.ts +0 -41
- package/dist/utils/language-utils.d.ts.map +0 -1
- package/dist/utils/language-utils.js +0 -79
- package/dist/utils/language-utils.js.map +0 -1
- package/dist/utils/slugify.d.ts +0 -20
- package/dist/utils/slugify.d.ts.map +0 -1
- package/dist/utils/slugify.js +0 -44
- package/dist/utils/slugify.js.map +0 -1
- package/templates/default/config/favicon.ico +0 -0
- package/templates/default/config/logo-dark.png +0 -0
- package/templates/default/config/logo.png +0 -0
- package/templates/default/config/sidenav.yaml +0 -36
- package/templates/default/config/site.json +0 -16
- package/templates/default/config/styles/main.json +0 -6
- package/templates/default/config/styles/typography.json +0 -6
- package/templates/default/content/en/changelog.md +0 -35
- package/templates/default/content/en/faq.md +0 -50
- package/templates/default/content/en/field-manual/engines.md +0 -59
- package/templates/default/content/en/field-manual/relativity.md +0 -46
- package/templates/default/content/en/field-manual/safety.md +0 -44
- package/templates/default/content/en/field-manual.md +0 -22
- package/templates/default/content/en/flight-school/navigation.md +0 -61
- package/templates/default/content/en/flight-school/primer.md +0 -64
- package/templates/default/content/en/flight-school.md +0 -48
- package/templates/default/content/en/index.md +0 -83
- package/templates/default/content/en/ship-systems/flux-sails.md +0 -33
- package/templates/default/content/en/ship-systems/photonic-core.md +0 -39
- package/templates/default/content/en/ship-systems.md +0 -25
- package/templates/default/package.json +0 -21
- package/templates/default/public/icons/academy.svg +0 -15
- package/templates/default/public/icons/manual.svg +0 -16
- package/templates/default/public/icons/relativity.svg +0 -16
- package/templates/default/public/icons/systems.svg +0 -14
- package/templates/default/public/icons/warning.svg +0 -14
- package/templates/default/public/images/flux-sails.svg +0 -33
- package/templates/default/public/images/photonic-core.svg +0 -44
- package/templates/default/public/images/starwake.svg +0 -49
package/bin/cli.js
CHANGED
|
@@ -1,81 +1,34 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// Entry point for the Mordoc CLI. This file is intentionally plain JS (not TS)
|
|
4
|
+
// so it can be executed directly by Node without a build step.
|
|
5
|
+
// The actual logic lives in compiled output under dist/.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const command = args[0];
|
|
9
|
-
const commandArgs = args.slice(1); // Arguments after the command
|
|
7
|
+
import { runDevCommand } from '../dist/cli/dev.js';
|
|
8
|
+
import { runBuildCommand } from '../dist/cli/build.js';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
function showHelp() {
|
|
13
|
-
console.log(`
|
|
14
|
-
Mordoc - Static Site Generator for Documentation
|
|
10
|
+
const command = process.argv[2];
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Options:
|
|
24
|
-
--help Show this help message
|
|
25
|
-
|
|
26
|
-
Examples:
|
|
27
|
-
mordoc build
|
|
28
|
-
mordoc build --verbose --drafts
|
|
29
|
-
mordoc dev
|
|
30
|
-
mordoc dev --port 8080
|
|
31
|
-
`);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Main CLI logic
|
|
35
|
-
async function main() {
|
|
36
|
-
// Show help if no command or --help flag
|
|
37
|
-
if (!command || command === '--help' || command === '-h') {
|
|
38
|
-
showHelp();
|
|
39
|
-
process.exit(0);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check if dist folder exists (TypeScript must be compiled first)
|
|
43
|
-
const distPath = path.join(__dirname, '../dist/cli');
|
|
44
|
-
if (!fs.existsSync(distPath)) {
|
|
45
|
-
console.error('Error: Mordoc is not built. Please run "tsc" first to compile TypeScript.');
|
|
12
|
+
if (command === 'dev') {
|
|
13
|
+
try {
|
|
14
|
+
await runDevCommand({ projectRoot: process.cwd() });
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error('\n✘ Dev server failed to start:\n');
|
|
17
|
+
console.error(err.message);
|
|
46
18
|
process.exit(1);
|
|
47
19
|
}
|
|
48
|
-
|
|
49
|
-
// Route to appropriate command handler
|
|
20
|
+
} else if (command === 'build') {
|
|
50
21
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
await buildHandler.build(options);
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
case 'dev': {
|
|
60
|
-
const devHandler = require('../dist/cli/dev.js');
|
|
61
|
-
const options = devHandler.parseDevArgs(commandArgs);
|
|
62
|
-
await devHandler.dev(options);
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
default:
|
|
67
|
-
console.error(`Unknown command: ${command}`);
|
|
68
|
-
showHelp();
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
} catch (error) {
|
|
72
|
-
console.error('Error:', error.message);
|
|
73
|
-
if (process.env.DEBUG) {
|
|
74
|
-
console.error(error.stack);
|
|
75
|
-
}
|
|
22
|
+
await runBuildCommand({ projectRoot: process.cwd() });
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error('\n✘ Build failed:\n');
|
|
25
|
+
console.error(err.stack ?? err.message);
|
|
76
26
|
process.exit(1);
|
|
77
27
|
}
|
|
28
|
+
} else {
|
|
29
|
+
console.log('Usage: mordoc <command>');
|
|
30
|
+
console.log('\nCommands:');
|
|
31
|
+
console.log(' dev Start the Mordoc dev server');
|
|
32
|
+
console.log(' build Render the project to static HTML in dist/');
|
|
33
|
+
process.exit(1);
|
|
78
34
|
}
|
|
79
|
-
|
|
80
|
-
// Run the CLI
|
|
81
|
-
main();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MordocData } from '../types/pipeline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Copies every non-null asset file out of the user's `config/assets/`
|
|
4
|
+
* to a flat `<clientOutDir>/_assets/` folder, then returns a new
|
|
5
|
+
* `MordocData` whose `assets` field references the served URLs instead
|
|
6
|
+
* of the original absolute disk paths.
|
|
7
|
+
*
|
|
8
|
+
* Why this exists right now:
|
|
9
|
+
* `loadAssets` produces absolute disk paths (e.g.
|
|
10
|
+
* `C:\Users\...\config\assets\favicon.ico`). Those paths land inside
|
|
11
|
+
* the bundled `virtual:mordoc/assets` module on the client and inside
|
|
12
|
+
* the React tree's serialized loader data on SSR. Neither has any
|
|
13
|
+
* business in deployed output — disk paths are useless to a browser
|
|
14
|
+
* and embedding them in HTML/JS leaks the build machine's filesystem
|
|
15
|
+
* layout. The moment a theme component reads `assets.favicon`, that
|
|
16
|
+
* leak becomes a visible bug. Rewriting now closes the gap before any
|
|
17
|
+
* theme exists; the cost is small and the alternative is a latent
|
|
18
|
+
* regression waiting for the first `<link rel="icon" href={...} />`.
|
|
19
|
+
*
|
|
20
|
+
* Why build-only:
|
|
21
|
+
* Dev rewrites asset paths at virtual-module generation time (plugin.ts
|
|
22
|
+
* `rewriteAssetsForDev`) and serves files via a `/_assets/*` middleware
|
|
23
|
+
* in dev.ts — no copy step needed there.
|
|
24
|
+
*
|
|
25
|
+
* Filename strategy:
|
|
26
|
+
* Output filename = basename of the source file. The current loader
|
|
27
|
+
* discovers exactly three known assets by convention (favicon, logo,
|
|
28
|
+
* logo-dark) so basename collisions are impossible by construction.
|
|
29
|
+
* When the asset surface grows beyond conventional discovery, this
|
|
30
|
+
* strategy will need a content-hash suffix to disambiguate.
|
|
31
|
+
*
|
|
32
|
+
* Note on `logoDark` falling back to `logo`:
|
|
33
|
+
* `loadAssets` returns the same source path for both when no separate
|
|
34
|
+
* dark logo exists. `fs.copyFile` is idempotent under repeated copies
|
|
35
|
+
* to the same destination, so the duplicate copy is harmless and the
|
|
36
|
+
* resulting URLs are identical — exactly the fall-through the loader
|
|
37
|
+
* intended.
|
|
38
|
+
*/
|
|
39
|
+
export declare function copyAndRewriteAssets(data: MordocData, clientOutDir: string): Promise<MordocData>;
|
|
40
|
+
//# sourceMappingURL=asset-rewrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-rewrite.d.ts","sourceRoot":"","sources":["../../src/cli/asset-rewrite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAcvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,CAAC,CAWrB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
/**
|
|
4
|
+
* Public URL prefix used for rewritten asset paths.
|
|
5
|
+
*
|
|
6
|
+
* Underscore-prefixed deliberately: Vite's client build emits its own
|
|
7
|
+
* code chunks into `dist/assets/` (no underscore) and we don't want a
|
|
8
|
+
* collision with that directory. `_assets` is conventional for "static
|
|
9
|
+
* resources copied verbatim, not bundler output".
|
|
10
|
+
*/
|
|
11
|
+
const ASSET_URL_PREFIX = '/_assets';
|
|
12
|
+
const ASSET_DIR_NAME = '_assets';
|
|
13
|
+
/**
|
|
14
|
+
* Copies every non-null asset file out of the user's `config/assets/`
|
|
15
|
+
* to a flat `<clientOutDir>/_assets/` folder, then returns a new
|
|
16
|
+
* `MordocData` whose `assets` field references the served URLs instead
|
|
17
|
+
* of the original absolute disk paths.
|
|
18
|
+
*
|
|
19
|
+
* Why this exists right now:
|
|
20
|
+
* `loadAssets` produces absolute disk paths (e.g.
|
|
21
|
+
* `C:\Users\...\config\assets\favicon.ico`). Those paths land inside
|
|
22
|
+
* the bundled `virtual:mordoc/assets` module on the client and inside
|
|
23
|
+
* the React tree's serialized loader data on SSR. Neither has any
|
|
24
|
+
* business in deployed output — disk paths are useless to a browser
|
|
25
|
+
* and embedding them in HTML/JS leaks the build machine's filesystem
|
|
26
|
+
* layout. The moment a theme component reads `assets.favicon`, that
|
|
27
|
+
* leak becomes a visible bug. Rewriting now closes the gap before any
|
|
28
|
+
* theme exists; the cost is small and the alternative is a latent
|
|
29
|
+
* regression waiting for the first `<link rel="icon" href={...} />`.
|
|
30
|
+
*
|
|
31
|
+
* Why build-only:
|
|
32
|
+
* Dev rewrites asset paths at virtual-module generation time (plugin.ts
|
|
33
|
+
* `rewriteAssetsForDev`) and serves files via a `/_assets/*` middleware
|
|
34
|
+
* in dev.ts — no copy step needed there.
|
|
35
|
+
*
|
|
36
|
+
* Filename strategy:
|
|
37
|
+
* Output filename = basename of the source file. The current loader
|
|
38
|
+
* discovers exactly three known assets by convention (favicon, logo,
|
|
39
|
+
* logo-dark) so basename collisions are impossible by construction.
|
|
40
|
+
* When the asset surface grows beyond conventional discovery, this
|
|
41
|
+
* strategy will need a content-hash suffix to disambiguate.
|
|
42
|
+
*
|
|
43
|
+
* Note on `logoDark` falling back to `logo`:
|
|
44
|
+
* `loadAssets` returns the same source path for both when no separate
|
|
45
|
+
* dark logo exists. `fs.copyFile` is idempotent under repeated copies
|
|
46
|
+
* to the same destination, so the duplicate copy is harmless and the
|
|
47
|
+
* resulting URLs are identical — exactly the fall-through the loader
|
|
48
|
+
* intended.
|
|
49
|
+
*/
|
|
50
|
+
export async function copyAndRewriteAssets(data, clientOutDir) {
|
|
51
|
+
const targetDir = path.join(clientOutDir, ASSET_DIR_NAME);
|
|
52
|
+
await fs.mkdir(targetDir, { recursive: true });
|
|
53
|
+
const rewritten = {
|
|
54
|
+
favicon: await copyAndRewriteOne(data.assets.favicon, targetDir),
|
|
55
|
+
logo: await copyAndRewriteOne(data.assets.logo, targetDir),
|
|
56
|
+
logoDark: await copyAndRewriteOne(data.assets.logoDark, targetDir),
|
|
57
|
+
};
|
|
58
|
+
return { ...data, assets: rewritten };
|
|
59
|
+
}
|
|
60
|
+
async function copyAndRewriteOne(sourcePath, targetDir) {
|
|
61
|
+
if (sourcePath === null)
|
|
62
|
+
return null;
|
|
63
|
+
const filename = path.basename(sourcePath);
|
|
64
|
+
await fs.copyFile(sourcePath, path.join(targetDir, filename));
|
|
65
|
+
return `${ASSET_URL_PREFIX}/${filename}`;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=asset-rewrite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-rewrite.js","sourceRoot":"","sources":["../../src/cli/asset-rewrite.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIlC;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAgB,EAChB,YAAoB;IAEpB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;IAC1D,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE/C,MAAM,SAAS,GAAmB;QAChC,OAAO,EAAE,MAAM,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;QAChE,IAAI,EAAE,MAAM,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC;QAC1D,QAAQ,EAAE,MAAM,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC;KACnE,CAAC;IAEF,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACxC,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,UAAyB,EACzB,SAAiB;IAEjB,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9D,OAAO,GAAG,gBAAgB,IAAI,QAAQ,EAAE,CAAC;AAC3C,CAAC"}
|
package/dist/cli/build.d.ts
CHANGED
|
@@ -1,20 +1,50 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build command - Generates static site from content
|
|
3
|
-
* Usage: mordoc build [options]
|
|
4
|
-
*/
|
|
5
1
|
export interface BuildCommandOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
verbose?: boolean;
|
|
9
|
-
drafts?: boolean;
|
|
10
|
-
clean?: boolean;
|
|
2
|
+
/** Absolute path to the user's project root. */
|
|
3
|
+
projectRoot: string;
|
|
11
4
|
}
|
|
12
5
|
/**
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
6
|
+
* Runs the full Mordoc production build for a project.
|
|
7
|
+
*
|
|
8
|
+
* Architecture mirrors `dev.ts`:
|
|
9
|
+
* - Vite's `root` is mordoc's own `src/app/` — the user's project
|
|
10
|
+
* contains no TSX/HTML that Vite ever sees as code. All user-side
|
|
11
|
+
* data flows through the mordoc plugin's virtual modules.
|
|
12
|
+
* - `publicDir` is pointed at `<projectRoot>/public/` for the client
|
|
13
|
+
* build so that author assets (referenced from markdown as
|
|
14
|
+
* `/images/foo.png` etc.) get copied into `dist/` verbatim. The SSR
|
|
15
|
+
* build sets `publicDir: false` to avoid copying the same files into
|
|
16
|
+
* the throwaway SSR intermediate.
|
|
17
|
+
* - `configFile: false` prevents Vite from picking up any stray
|
|
18
|
+
* `vite.config.js` the user might have lying around.
|
|
19
|
+
*
|
|
20
|
+
* Pipeline shape:
|
|
21
|
+
* 1. `runPipeline(projectRoot)` once, up front. The result is injected
|
|
22
|
+
* into both Vite plugin instances below so the pipeline doesn't run
|
|
23
|
+
* twice. This also gives us a single point to mutate the data later
|
|
24
|
+
* (e.g. asset URL rewriting) before either Vite pass starts.
|
|
25
|
+
* 2. Wipe the previous `dist/` and SSR cache. We do this manually
|
|
26
|
+
* rather than relying on Vite's `emptyOutDir` because both output
|
|
27
|
+
* directories live outside Vite's `root`, where Vite's auto-empty
|
|
28
|
+
* logic is intentionally cautious. Manual wipe keeps the behaviour
|
|
29
|
+
* explicit and the same for both passes.
|
|
30
|
+
* 3. Client build: bundles `main.tsx` + every route's lazy chunk into
|
|
31
|
+
* hashed `dist/assets/*.js`. `manifest: true` emits the chunk-graph
|
|
32
|
+
* manifest the SSG runner will read to inject per-route preloads.
|
|
33
|
+
* Vite also transforms `index.html` (rewriting the `<script>` tag
|
|
34
|
+
* from `/main.tsx` to the hashed entry) and writes it to
|
|
35
|
+
* `dist/index.html` — that becomes the SSG runner's per-route
|
|
36
|
+
* template.
|
|
37
|
+
* 4. SSR build: bundles `entry-server.tsx` for Node consumption into
|
|
38
|
+
* `node_modules/.mordoc/ssr/`. Vite preserves the dynamic
|
|
39
|
+
* `import('virtual:mordoc/page/...')` calls as runtime imports,
|
|
40
|
+
* code-split into sibling files, so the SSG runner can lazily load
|
|
41
|
+
* each route's content as it renders.
|
|
42
|
+
* 5. SSG runner: loads the SSR bundle, calls `render()` per route,
|
|
43
|
+
* writes the resulting HTML files. (Wired in a follow-up step.)
|
|
44
|
+
*
|
|
45
|
+
* The dev path is unaffected by any of this — its plugin instance still
|
|
46
|
+
* runs the pipeline itself, exactly as before. Build is the only caller
|
|
47
|
+
* that pre-loads `data`.
|
|
18
48
|
*/
|
|
19
|
-
export declare function
|
|
49
|
+
export declare function runBuildCommand(options: BuildCommandOptions): Promise<void>;
|
|
20
50
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;CACrB;AA0BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0GjF"}
|
package/dist/cli/build.js
CHANGED
|
@@ -1,111 +1,196 @@
|
|
|
1
|
-
|
|
1
|
+
import { build as viteBuild } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs/promises';
|
|
5
|
+
import { runPipeline } from '../pipeline.js';
|
|
6
|
+
import { mordocVitePlugin } from '../vite/plugin.js';
|
|
7
|
+
import { getAppRoot } from '../utils/paths.js';
|
|
8
|
+
import { runSsg } from './ssg-runner.js';
|
|
9
|
+
import { copyAndRewriteAssets } from './asset-rewrite.js';
|
|
10
|
+
import { runPagefindIndexer } from './pagefind-indexer.js';
|
|
11
|
+
function getOutDirs(projectRoot) {
|
|
12
|
+
return {
|
|
13
|
+
clientOutDir: path.join(projectRoot, 'dist'),
|
|
14
|
+
ssrOutDir: path.join(projectRoot, 'node_modules', '.mordoc', 'ssr'),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
2
17
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
18
|
+
* Runs the full Mordoc production build for a project.
|
|
19
|
+
*
|
|
20
|
+
* Architecture mirrors `dev.ts`:
|
|
21
|
+
* - Vite's `root` is mordoc's own `src/app/` — the user's project
|
|
22
|
+
* contains no TSX/HTML that Vite ever sees as code. All user-side
|
|
23
|
+
* data flows through the mordoc plugin's virtual modules.
|
|
24
|
+
* - `publicDir` is pointed at `<projectRoot>/public/` for the client
|
|
25
|
+
* build so that author assets (referenced from markdown as
|
|
26
|
+
* `/images/foo.png` etc.) get copied into `dist/` verbatim. The SSR
|
|
27
|
+
* build sets `publicDir: false` to avoid copying the same files into
|
|
28
|
+
* the throwaway SSR intermediate.
|
|
29
|
+
* - `configFile: false` prevents Vite from picking up any stray
|
|
30
|
+
* `vite.config.js` the user might have lying around.
|
|
31
|
+
*
|
|
32
|
+
* Pipeline shape:
|
|
33
|
+
* 1. `runPipeline(projectRoot)` once, up front. The result is injected
|
|
34
|
+
* into both Vite plugin instances below so the pipeline doesn't run
|
|
35
|
+
* twice. This also gives us a single point to mutate the data later
|
|
36
|
+
* (e.g. asset URL rewriting) before either Vite pass starts.
|
|
37
|
+
* 2. Wipe the previous `dist/` and SSR cache. We do this manually
|
|
38
|
+
* rather than relying on Vite's `emptyOutDir` because both output
|
|
39
|
+
* directories live outside Vite's `root`, where Vite's auto-empty
|
|
40
|
+
* logic is intentionally cautious. Manual wipe keeps the behaviour
|
|
41
|
+
* explicit and the same for both passes.
|
|
42
|
+
* 3. Client build: bundles `main.tsx` + every route's lazy chunk into
|
|
43
|
+
* hashed `dist/assets/*.js`. `manifest: true` emits the chunk-graph
|
|
44
|
+
* manifest the SSG runner will read to inject per-route preloads.
|
|
45
|
+
* Vite also transforms `index.html` (rewriting the `<script>` tag
|
|
46
|
+
* from `/main.tsx` to the hashed entry) and writes it to
|
|
47
|
+
* `dist/index.html` — that becomes the SSG runner's per-route
|
|
48
|
+
* template.
|
|
49
|
+
* 4. SSR build: bundles `entry-server.tsx` for Node consumption into
|
|
50
|
+
* `node_modules/.mordoc/ssr/`. Vite preserves the dynamic
|
|
51
|
+
* `import('virtual:mordoc/page/...')` calls as runtime imports,
|
|
52
|
+
* code-split into sibling files, so the SSG runner can lazily load
|
|
53
|
+
* each route's content as it renders.
|
|
54
|
+
* 5. SSG runner: loads the SSR bundle, calls `render()` per route,
|
|
55
|
+
* writes the resulting HTML files. (Wired in a follow-up step.)
|
|
56
|
+
*
|
|
57
|
+
* The dev path is unaffected by any of this — its plugin instance still
|
|
58
|
+
* runs the pipeline itself, exactly as before. Build is the only caller
|
|
59
|
+
* that pre-loads `data`.
|
|
5
60
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
61
|
+
export async function runBuildCommand(options) {
|
|
62
|
+
const { projectRoot } = options;
|
|
63
|
+
const appRoot = getAppRoot();
|
|
64
|
+
const publicDir = path.join(projectRoot, 'public');
|
|
65
|
+
const { clientOutDir, ssrOutDir } = getOutDirs(projectRoot);
|
|
66
|
+
console.log('\n Mordoc build');
|
|
67
|
+
console.log(` Project: ${projectRoot}\n`);
|
|
68
|
+
console.log('→ running pipeline...');
|
|
69
|
+
const rawData = await runPipeline(projectRoot);
|
|
70
|
+
console.log(` ${rawData.pages.length} page(s) discovered\n`);
|
|
71
|
+
console.log('→ wiping previous output...');
|
|
72
|
+
await fs.rm(clientOutDir, { recursive: true, force: true });
|
|
73
|
+
await fs.rm(ssrOutDir, { recursive: true, force: true });
|
|
74
|
+
// Asset rewrite has to happen before either Vite pass: both bundles
|
|
75
|
+
// import `virtual:mordoc/assets` (transitively, via `main.tsx`'s
|
|
76
|
+
// ShellData assembly), and the SSG runner builds its `shellData`
|
|
77
|
+
// from the same `MordocData`. One rewrite, three consistent views.
|
|
78
|
+
// Note: this also creates `dist/_assets/` with the copied files.
|
|
79
|
+
// Vite's subsequent client build runs with `emptyOutDir: false` so
|
|
80
|
+
// those copies survive.
|
|
81
|
+
console.log('→ copying assets...');
|
|
82
|
+
const data = await copyAndRewriteAssets(rawData, clientOutDir);
|
|
83
|
+
console.log('→ building client bundle...');
|
|
84
|
+
await viteBuild({
|
|
85
|
+
configFile: false,
|
|
86
|
+
root: appRoot,
|
|
87
|
+
publicDir,
|
|
88
|
+
plugins: [
|
|
89
|
+
react(),
|
|
90
|
+
mordocVitePlugin({ projectRoot, data }),
|
|
91
|
+
],
|
|
92
|
+
build: {
|
|
93
|
+
outDir: clientOutDir,
|
|
94
|
+
// We wiped above; suppress Vite's "outDir is outside root" guard.
|
|
95
|
+
// Also keeps `dist/_assets/` from being deleted between this
|
|
96
|
+
// build and the next phase.
|
|
97
|
+
emptyOutDir: false,
|
|
98
|
+
manifest: true,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
console.log('→ building SSR bundle...');
|
|
102
|
+
await viteBuild({
|
|
103
|
+
configFile: false,
|
|
104
|
+
root: appRoot,
|
|
105
|
+
// The SSR pass produces a Node-loadable bundle in a throwaway
|
|
106
|
+
// intermediate; copying author assets into it is wasted I/O and
|
|
107
|
+
// would put them under `node_modules/.mordoc/ssr/` rather than
|
|
108
|
+
// `dist/`. Disable publicDir entirely for this pass.
|
|
109
|
+
publicDir: false,
|
|
110
|
+
plugins: [
|
|
111
|
+
react(),
|
|
112
|
+
mordocVitePlugin({ projectRoot, data }),
|
|
113
|
+
],
|
|
114
|
+
build: {
|
|
115
|
+
outDir: ssrOutDir,
|
|
116
|
+
emptyOutDir: false,
|
|
117
|
+
ssr: 'entry-server.tsx',
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
// Declare the SSR output directory as an ESM scope.
|
|
121
|
+
//
|
|
122
|
+
// Vite emits the SSR bundle in ESM syntax (because mordoc's own
|
|
123
|
+
// package.json has `"type": "module"`, which Vite uses to pick the
|
|
124
|
+
// SSR output format). Without a package.json here, Node's loader
|
|
125
|
+
// walks up looking for `"type": "module"` and — because the bundle
|
|
126
|
+
// lives under the user project's `node_modules/.mordoc/ssr/`, and
|
|
127
|
+
// `node_modules/` acts as a package-scope boundary — falls back to
|
|
128
|
+
// CommonJS. The first `import { ... } from "..."` then SyntaxErrors.
|
|
129
|
+
//
|
|
130
|
+
// Dropping a one-liner package.json next to the bundle declares the
|
|
131
|
+
// scope unambiguously and is the standard pattern other SSR-emitting
|
|
132
|
+
// frameworks (Astro, SvelteKit, Nuxt, Remix) use for the same reason.
|
|
133
|
+
// The cleanup step at the end of this command wipes ssrOutDir
|
|
134
|
+
// entirely, so this file vanishes along with the rest.
|
|
135
|
+
await fs.writeFile(path.join(ssrOutDir, 'package.json'), '{"type":"module"}\n', 'utf-8');
|
|
136
|
+
console.log('\n→ rendering routes to static HTML...');
|
|
137
|
+
await runSsg({ data, clientOutDir, ssrOutDir });
|
|
138
|
+
// The SSR bundle is a build-time intermediate; once the SSG runner has
|
|
139
|
+
// finished rendering every route there's no consumer left for it.
|
|
140
|
+
// Wiping it keeps `node_modules/.mordoc/` from accumulating stale
|
|
141
|
+
// chunks across builds and reinforces the "anything not in dist/ is
|
|
142
|
+
// not deployable" mental model.
|
|
143
|
+
console.log('\n→ cleaning up SSR intermediate...');
|
|
144
|
+
await fs.rm(ssrOutDir, { recursive: true, force: true });
|
|
145
|
+
console.log('\n→ verifying output...');
|
|
146
|
+
await verifyBuildOutput(data, clientOutDir);
|
|
147
|
+
console.log('\n→ building search index...');
|
|
148
|
+
await runPagefindIndexer(data, clientOutDir);
|
|
149
|
+
console.log('\n✔ build complete');
|
|
150
|
+
console.log(` output → ${clientOutDir}\n`);
|
|
151
|
+
}
|
|
14
152
|
/**
|
|
15
|
-
*
|
|
153
|
+
* Defensive post-build checks.
|
|
154
|
+
*
|
|
155
|
+
* The SSG runner already throws on the obvious failure modes
|
|
156
|
+
* (`writeFile` errors, missing render export). These checks catch
|
|
157
|
+
* subtler regressions:
|
|
158
|
+
*
|
|
159
|
+
* 1. Every route in the pipeline produced a corresponding HTML file.
|
|
160
|
+
* Defense-in-depth — the runner walks `data.pages` to write, and
|
|
161
|
+
* this walks `data.pages` to read; a future refactor that skips
|
|
162
|
+
* a route silently would surface here.
|
|
163
|
+
*
|
|
164
|
+
* 2. The rendered root HTML still contains literal `$$mdtype` markers
|
|
165
|
+
* (the Markdoc Tag fingerprint) inside the hydration `<script>`.
|
|
166
|
+
* If the value is absent, the substitution mangled it (string form
|
|
167
|
+
* of `String.replace` collapsed `$$` → `$`), which would manifest
|
|
168
|
+
* on the client as the "Objects are not valid as a React child"
|
|
169
|
+
* crash the moment hydration tried to re-render. Cheapest possible
|
|
170
|
+
* regression test for that bug; runs in milliseconds.
|
|
171
|
+
* Skipped when no page has Markdoc content (empty project).
|
|
16
172
|
*/
|
|
17
|
-
async function
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
projectRoot,
|
|
29
|
-
outputDir,
|
|
30
|
-
clean: options.clean ?? true,
|
|
31
|
-
includeDrafts: options.drafts ?? false,
|
|
32
|
-
verbose: options.verbose ?? false,
|
|
33
|
-
});
|
|
34
|
-
// Execute build
|
|
35
|
-
await builder.build();
|
|
36
|
-
// Calculate build time
|
|
37
|
-
const buildTime = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
38
|
-
console.log(`\n⚡ Build completed in ${buildTime}s`);
|
|
39
|
-
process.exit(0);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('\n❌ Build failed:');
|
|
43
|
-
console.error(error.message);
|
|
44
|
-
if (options.verbose) {
|
|
45
|
-
console.error('\nStack trace:');
|
|
46
|
-
console.error(error.stack);
|
|
173
|
+
async function verifyBuildOutput(data, clientOutDir) {
|
|
174
|
+
for (const page of data.pages) {
|
|
175
|
+
const routePath = page.entry.routePath;
|
|
176
|
+
const expectedPath = routePath === '/'
|
|
177
|
+
? path.join(clientOutDir, 'index.html')
|
|
178
|
+
: path.join(clientOutDir, routePath.slice(1), 'index.html');
|
|
179
|
+
try {
|
|
180
|
+
await fs.access(expectedPath);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
throw new Error(`mordoc build: expected ${expectedPath} for route "${routePath}", but the file is missing.`);
|
|
47
184
|
}
|
|
48
|
-
process.exit(1);
|
|
49
185
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const arg = args[i];
|
|
58
|
-
switch (arg) {
|
|
59
|
-
case '--output':
|
|
60
|
-
case '-o':
|
|
61
|
-
options.outputDir = args[++i];
|
|
62
|
-
break;
|
|
63
|
-
case '--verbose':
|
|
64
|
-
case '-v':
|
|
65
|
-
options.verbose = true;
|
|
66
|
-
break;
|
|
67
|
-
case '--drafts':
|
|
68
|
-
case '-d':
|
|
69
|
-
options.drafts = true;
|
|
70
|
-
break;
|
|
71
|
-
case '--no-clean':
|
|
72
|
-
options.clean = false;
|
|
73
|
-
break;
|
|
74
|
-
case '--help':
|
|
75
|
-
case '-h':
|
|
76
|
-
showBuildHelp();
|
|
77
|
-
process.exit(0);
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
if (arg.startsWith('-')) {
|
|
81
|
-
console.warn(`Warning: Unknown option ${arg}`);
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
186
|
+
const hasRenderableContent = data.pages.length > 0;
|
|
187
|
+
if (hasRenderableContent) {
|
|
188
|
+
const rootHtml = await fs.readFile(path.join(clientOutDir, 'index.html'), 'utf-8');
|
|
189
|
+
if (!rootHtml.includes('$$mdtype')) {
|
|
190
|
+
throw new Error('mordoc build: rendered dist/index.html does not contain "$$mdtype". ' +
|
|
191
|
+
'The hydration data may have been mangled by string-form String.replace; ' +
|
|
192
|
+
'check that all SSR template substitutions use the replacement-function form.');
|
|
84
193
|
}
|
|
85
194
|
}
|
|
86
|
-
return options;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Show help text for build command
|
|
90
|
-
*/
|
|
91
|
-
function showBuildHelp() {
|
|
92
|
-
console.log(`
|
|
93
|
-
mordoc build - Generate static documentation site
|
|
94
|
-
|
|
95
|
-
Usage:
|
|
96
|
-
mordoc build [options]
|
|
97
|
-
|
|
98
|
-
Options:
|
|
99
|
-
-o, --output <dir> Output directory (default: dist)
|
|
100
|
-
-v, --verbose Enable verbose logging
|
|
101
|
-
-d, --drafts Include draft content in build
|
|
102
|
-
--no-clean Don't clean output directory before build
|
|
103
|
-
-h, --help Show this help message
|
|
104
|
-
|
|
105
|
-
Examples:
|
|
106
|
-
mordoc build
|
|
107
|
-
mordoc build --output build
|
|
108
|
-
mordoc build --verbose --drafts
|
|
109
|
-
`);
|
|
110
195
|
}
|
|
111
196
|
//# sourceMappingURL=build.js.map
|
package/dist/cli/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,MAAM,sBAAsB,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAwB3D,SAAS,UAAU,CAAC,WAAmB;IACrC,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;QAC5C,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,CAAC;KACpE,CAAC;A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