Skip to content

fix(cli): first-consumer polish - templates, theme sync, footer extraction - #9

Merged
Shewart merged 9 commits into
mainfrom
feat/cli-init-create-mode
Jul 18, 2026
Merged

fix(cli): first-consumer polish - templates, theme sync, footer extraction#9
Shewart merged 9 commits into
mainfrom
feat/cli-init-create-mode

Conversation

@Shewart

@Shewart Shewart commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Bundle of small fixes discovered while dogfooding shelldocs init in a real external repo (shell-tech). None of these are architectural changes — they're the "wait, why doesn't ___ work" edges that only surface when you use the CLI outside its own test suite.

What's in it

Templates

  • DocsPage.razor template emits 6 explicit @using directives (ShellDocs.Components, .Chrome, .Content, .Layouts, ShellDocs.Core, ShellDocs.Markdown). Fresh consumer projects don't inherit ShellDocs namespaces from _Imports.razor the way the preview project does — the DocsPage template was failing to compile with CS0246: NavigationGraph could not be found.
  • Welcome Home.razor template also declares @using ShellDocs.Components.Chrome so it can render <DocsFooter />.

PatchAppRazor fixed for the real dotnet new blazor output shape

  • Regex now matches both <script src="_framework/blazor.web.js"> and the <script src="@Assets["_framework/blazor.web.js"]"> variant .NET 10 templates emit. Previous regex missed the wrapped form, so shelldocs.js + the Shiki module never got injected into the head — dead theme sync, dead syntax highlighting.
  • Auto-adds @rendermode="InteractiveServer" to bare <Routes />. Fresh Blazor Web App renders static SSR by default when this attribute is missing, which meant <ThemeToggle> clicks did nothing (no interactivity).
  • Auto-strips the fresh template's <link> tags for Bootstrap CSS and default app.css. Bootstrap's code { color: #d63384 } was painting every inline <code> in the welcome page pink; the token system carries the correct styling.

Theme sync survives enhanced navigation

  • shelldocs.js now registers a document.addEventListener('enhancedload', applyTheme). Blazor's enhanced nav swaps the DOM on route change and strips the .dark class from <html> (server response doesn't know about the user's localStorage). Re-applying from localStorage on the enhancedload event keeps the theme sticky across navigation.
  • Exposed as window.shelldocsApplyTheme for cases where explicit re-apply is useful.

Site name inference

  • CreateMode now strips a trailing .Docs from the folder-derived site name. docs/shell-tech.Docs/ (project folder) → shell-tech (brand shown in header/footer). Was previously writing o.SiteName = "shell-tech.Docs" verbatim.
  • Explicit path (shelldocs init packages/my-cool-site) uses the folder name as-is; only strips .Docs when it's the auto-inferred suffix.

Strip fresh template's demo pages in create mode

  • New StripFreshTemplate helper called from CreateMode (not AttachMode, on purpose — attach leaves your existing app alone).
  • Deletes Counter.razor, Weather.razor, Home.razor.css, Components/Layout/NavMenu.razor (+ .css), Components/Layout/MainLayout.razor.css.
  • Overwrites MainLayout.razor with a bare @inherits LayoutComponentBase\n@Body (routes.razor still references it as DefaultLayout; every real page overrides via @layout HomeLayout or @layout DocsLayout).
  • Writes a new Home.razor — fumadocs-style welcome page (centered hero + CTA to /docs/introduction + three cards explaining how to customize this page / add pages / register components).

Footer extracted from HomeLayout into a <DocsFooter /> component

  • New src/ShellDocs.Components/Chrome/DocsFooter.razor + .razor.css — takes Version, TwitterHandle, Columns (RenderFragment slot for custom columns; falls back to default Resources + Support columns).
  • HomeLayout now renders <DocsHeader /> + <main>@Body</main>, nothing else. Footer is opt-in per page — consumer drops <DocsFooter /> anywhere they want it.
  • Preview app's Home / Blog / Showcase all render <DocsFooter /> explicitly with the same visual result as before.
  • Scaffolded welcome Home.razor includes <DocsFooter Version="0.1.0-alpha" /> so new projects still get a default footer that consumers can freely delete or customize.

Rationale: the previous baked-in footer in HomeLayout carried ShellDocs-specific opinions (X socials pointing at @shellui_, links to Showcase/Blog pages consumers don't have). Extraction removes those opinions from the framework — consumers now own their footer content and layout.

Version bump plumbing

  • Directory.Build.props gains <Version>0.1.0-alpha</Version> so dotnet pack produces 0.1.0-alpha-versioned .nupkgs matching the version string InitCommand writes into scaffolded csprojs. Was previously defaulting to 1.0.0.

Test plan

  • dotnet build shelldocs.slnx — clean
  • dotnet test shelldocs.slnx — 94 passing
  • Fresh dotnet new blazor + shelldocs init --yes end-to-end — all patches apply, project builds, /docs/introduction renders
  • Theme toggle flips both light↔dark; theme survives / → /docs/introduction navigation
  • Inline <code> in Home.razor renders with token-system styling (no Bootstrap pink)
  • Footer renders on Home, Blog, Showcase with per-page control

Shewart added 9 commits July 18, 2026 15:06
…or improved project scaffolding and integration with existing Blazor projects
…ay, including social links and customizable columns
…k/light mode across enhanced navigation events
…nhancements for improved user onboarding experience
…g the split of `shelldocs init` into create and attach modes for improved project scaffolding.
…d names and assertions for improved clarity and functionality
@Shewart
Shewart merged commit 765153a into main Jul 18, 2026
1 check passed
@Shewart
Shewart deleted the feat/cli-init-create-mode branch July 20, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant