|
| 1 | +# Migrating from Docusaurus to Jaspr |
| 2 | + |
| 3 | +## 1. Scaffold the Jaspr project |
| 4 | + |
| 5 | +```bash |
| 6 | +dart pub global activate jaspr_cli |
| 7 | +jaspr create --template=docs site_jaspr |
| 8 | +``` |
| 9 | + |
| 10 | +This gives you a Jaspr static site pre-configured with `jaspr_content`, which includes a `DocsLayout` with sidebar, header, dark/light mode, markdown parsing, and syntax highlighting out of the box. |
| 11 | + |
| 12 | +## 2. Migrate your content |
| 13 | + |
| 14 | +Your current docs are 10 Markdown files in `site/docs/` with YAML frontmatter (`sidebar_position`, `title`, `description`). These can largely be copied over as-is -- `jaspr_content` uses a `FilesystemLoader` that reads `.md` files from a content directory and supports frontmatter. |
| 15 | + |
| 16 | +The current sidebar is auto-generated from the filesystem in Docusaurus. In Jaspr, the sidebar is defined explicitly in Dart code: |
| 17 | + |
| 18 | +```dart |
| 19 | +sidebar: Sidebar(groups: [ |
| 20 | + SidebarGroup(links: [ |
| 21 | + SidebarLink(text: 'Overview', href: '/'), |
| 22 | + ]), |
| 23 | + SidebarGroup(title: 'Workflows', links: [ |
| 24 | + SidebarLink(text: 'Dart Package', href: '/workflows/dart_package'), |
| 25 | + SidebarLink(text: 'Flutter Package', href: '/workflows/flutter_package'), |
| 26 | + // ... etc |
| 27 | + ]), |
| 28 | +]), |
| 29 | +``` |
| 30 | + |
| 31 | +## 3. Recreate the custom homepage |
| 32 | + |
| 33 | +The current homepage (`site/src/pages/index.tsx`) is a custom React component with a hero banner, CTA button, and blog section. In Jaspr, you'd build this as a `StatelessComponent` using Jaspr's HTML element functions (`div`, `a`, `img`, etc.) with typed `Styles` for CSS. |
| 34 | + |
| 35 | +## 4. Migrate theming |
| 36 | + |
| 37 | +The custom CSS (`site/src/css/custom.css`) defines brand colors, Poppins font, and dark mode overrides. In Jaspr, theming is done via `ContentTheme`: |
| 38 | + |
| 39 | +```dart |
| 40 | +theme: ContentTheme( |
| 41 | + primary: ThemeColor(Color('#2a48df'), dark: Color('#66fbd1')), |
| 42 | + background: ThemeColor(Colors.white, dark: Color('#0b0d0e')), |
| 43 | +), |
| 44 | +``` |
| 45 | + |
| 46 | +## 5. Update the deployment workflow |
| 47 | + |
| 48 | +Replace the Node/Docusaurus build steps in `.github/workflows/site_deploy.yaml` with Dart/Jaspr: |
| 49 | + |
| 50 | +```yaml |
| 51 | +- uses: dart-lang/setup-dart@v1 |
| 52 | +- run: dart pub global activate jaspr_cli |
| 53 | +- run: jaspr build |
| 54 | +# Output goes to build/jaspr/ instead of site/build/ |
| 55 | +``` |
| 56 | + |
| 57 | +## Key differences to be aware of |
| 58 | + |
| 59 | +| Aspect | Docusaurus (current) | Jaspr | |
| 60 | +|---|---|---| |
| 61 | +| Sidebar | Auto-generated from filesystem | Manual definition in Dart | |
| 62 | +| Custom pages | React/TSX components | Dart `StatelessComponent` | |
| 63 | +| Styling | CSS/CSS Modules | Typed `Styles` in Dart + optional CSS | |
| 64 | +| Markdown extensions | MDX (JSX in Markdown) | Custom components registered in Dart | |
| 65 | +| Search | Algolia integration available | No built-in search | |
| 66 | +| Docs versioning | Built-in | Not available | |
| 67 | + |
| 68 | +## Tradeoffs |
| 69 | + |
| 70 | +The main benefit is staying entirely within the Dart ecosystem. The main costs are losing Docusaurus's auto-generated sidebar, built-in search integration, and the broader plugin ecosystem. The site is relatively straightforward (10 doc pages, one custom homepage), so the migration scope is manageable. |
0 commit comments