Skip to content

Commit 17a52cc

Browse files
committed
docs: shelldocs preview, and --base-href fixing links
New CLI page for shelldocs preview, linked from build, deployment, the quick start and the CLI package page. The build and deployment pages say --base-href now puts the subpath in front of root-relative links.
1 parent c3f2077 commit 17a52cc

9 files changed

Lines changed: 104 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ content/
5959
authoring/ frontmatter, code fences, razor:preview, inline tags, navigation
6060
components/ one page per content primitive
6161
guides/ component libraries, versioning, redirects, search, llms.txt, not-found, deployment
62-
cli/ init, add, dev, build
62+
cli/ init, add, dev, build, preview
6363
theming.md
6464
packages/ one overview per NuGet package
6565
wwwroot/
6666
favicon.svg, favicon.png, apple-touch-icon.png
6767
brand/mark.svg the logo, read into LogoSvg in Program.cs
68-
demos/ static pages shown with <IframePreview>
68+
demos/ static pages shown with <IframePreview> (theme frame, colour presets)
6969
cli-replay.js the terminal replay on the home page
7070
copy-button.js copy buttons marked with data-copy
7171
Llms/

‎content/docs/cli/build.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Rewrites the base href, replaces `404.html` with the home page, and adds the sit
5959
</Step>
6060
</Steps>
6161

62-
The project stays a normal Blazor Web App. Nothing about it changes for the export.
62+
The project stays a normal Blazor Web App. Nothing about it changes for the export. To check the result before deploying, run [`shelldocs preview`](/docs/cli/preview).
6363

6464
## Custom pages
6565

@@ -83,12 +83,14 @@ Without the flag none of these are written, so a local build never produces a si
8383

8484
### `--base-href`
8585

86-
For a site served from a subpath. Rewrites the `base` tag in every HTML file so assets resolve under the subpath. Include the leading and trailing slash.
86+
For a site served from a subpath. Rewrites the `base` tag in every HTML file so assets resolve under the subpath, and puts the subpath in front of every root-relative `href`, `src` and `data-src`, so links in the sidebar, header, breadcrumb, page content and prev/next stay inside the site. Include the leading and trailing slash.
8787

8888
```bash
8989
shelldocs build --base-href /my-repo/
9090
```
9191

92+
Before `0.1.18-alpha` only the `base` tag changed, and root-relative links such as `/docs/introduction` led out of the subpath. [`shelldocs preview`](/docs/cli/preview) serves the export under the subpath, to check it.
93+
9294
### `--spa-fallback`
9395

9496
Replaces `404.html` with a copy of the root `index.html`, so a host that serves `404.html` for unknown URLs shows the home page instead of the not-found page.
@@ -125,5 +127,6 @@ Search, the sidebar, tabs and the rest of the chrome work in the export: `shelld
125127

126128
<CardGrid Columns="2">
127129
<LinkCard Title="Deployment" Description="GitHub Pages workflow, custom domains, and .NET hosting." Href="/docs/guides/deployment" />
130+
<LinkCard Title="shelldocs preview" Description="Serve the export locally, as a static host would." Href="/docs/cli/preview" />
128131
<LinkCard Title="shelldocs dev" Description="Iterate locally before you publish." Href="/docs/cli/dev" />
129132
</CardGrid>

‎content/docs/cli/meta.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"title": "CLI",
3-
"pages": ["init", "add", "dev", "build"]
3+
"pages": ["init", "add", "dev", "build", "preview"]
44
}

‎content/docs/cli/preview.md‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: shelldocs preview
3+
description: Serve the output of shelldocs build locally, the way a static host would, to check an export before deploying it.
4+
order: 5
5+
---
6+
7+
# `shelldocs preview`
8+
9+
`shelldocs preview` serves the static site that [`shelldocs build`](/docs/cli/build) wrote, the way GitHub Pages, Netlify and Cloudflare Pages serve it. Use it to check an export before you deploy: links, the not-found page, search, a site built for a subpath.
10+
11+
## Synopsis
12+
13+
```bash
14+
shelldocs preview [--dir <dir>] [--output <path>] [--port <n>] [--base-href <path>]
15+
```
16+
17+
## Default use
18+
19+
Build, then preview, from the docs project folder:
20+
21+
```bash
22+
shelldocs build
23+
shelldocs preview
24+
```
25+
26+
The export in `./publish` is served at `http://localhost:5050`. Press `Ctrl+C` to stop.
27+
28+
## How it serves
29+
30+
<TypeTable>
31+
<TypeRow Name="A file" Type="200" Description="Served as it is, with a content type from its extension." />
32+
<TypeRow Name="A folder" Type="200" Description="Its index.html. Every page of an export is a folder with an index.html." />
33+
<TypeRow Name="{path}.html" Type="200" Description="Used when there is no file or folder of that name." />
34+
<TypeRow Name="Anything else" Type="404" Description="The export's 404.html, with a 404 status, as most static hosts do." />
35+
</TypeTable>
36+
37+
Nothing is cached, so after a rebuild a reload shows the new output. Requests can't reach files outside the export.
38+
39+
## Sites built for a subpath
40+
41+
An export built with `--base-href /my-repo/` is served under that path. `shelldocs preview` reads the base from the export's `index.html`, so it needs no flag:
42+
43+
```bash
44+
shelldocs build --base-href /my-repo/
45+
shelldocs preview
46+
```
47+
48+
The site is at `http://localhost:5050/my-repo/`, and `/` redirects there. Pass `--base-href` to serve under another path than the one the build wrote.
49+
50+
## Options
51+
52+
<TypeTable>
53+
<TypeRow Name="--dir" Type="string" Default="current folder" Description="Project folder. --output is relative to it." />
54+
<TypeRow Name="--output" Type="string" Default="publish" Description="The static site to serve, as passed to shelldocs build." />
55+
<TypeRow Name="--port" Type="int" Default="5050" Description="Port to listen on." />
56+
<TypeRow Name="--base-href" Type="string?" Default="the export's base href" Description="Path to serve the site under." />
57+
</TypeTable>
58+
59+
## Exit codes
60+
61+
<TypeTable>
62+
<TypeRow Name="0" Type="ok" Description="Stopped with Ctrl+C." />
63+
<TypeRow Name="1" Type="error" Description="No index.html in the output folder. Run shelldocs build first, or point --output at its folder." />
64+
</TypeTable>
65+
66+
The command needs the ASP.NET Core runtime, which any machine that builds a Blazor site already has. It was added in `0.1.18-alpha`, replacing an unfinished `preview <name>` placeholder.
67+
68+
## See also
69+
70+
<CardGrid Columns="2">
71+
<LinkCard Title="shelldocs build" Description="Write the static site this command serves." Href="/docs/cli/build" />
72+
<LinkCard Title="Deployment" Description="What works on a static host, and how to publish." Href="/docs/guides/deployment" />
73+
</CardGrid>

‎content/docs/getting-started/installation.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dotnet add package ShellDocs.Tokens --prerelease
7171
## The package family
7272

7373
<TypeTable>
74-
<TypeRow Name="ShellDocs.CLI" Type="global tool" Description="shelldocs init, add, dev, build. Installed once, works from any directory." />
74+
<TypeRow Name="ShellDocs.CLI" Type="global tool" Description="shelldocs init, add, dev, build, preview. Installed once, works from any directory." />
7575
<TypeRow Name="ShellDocs.Components" Type="RCL" Description="The chrome (layout, sidebar, search, header) and content primitives (Callout, Card, Steps, CodeGroup, TypeTable, more)." />
7676
<TypeRow Name="ShellDocs.Tokens" Type="RCL" Description="Shared CSS variables. shadcn-compatible names for interop with ShellUI and other design systems." />
7777
<TypeRow Name="ShellDocs.Core" Type="library (transitive)" Description="Navigation graph, search index, markdown plain-text extraction." />

‎content/docs/getting-started/quick-start.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Other templates:
7777
shelldocs build --output publish
7878
```
7979

80-
Prerenders every page into `publish/` as static files. Upload the folder to any static host. See [Deployment](/docs/guides/deployment) for a GitHub Pages workflow and for what needs a server instead.
80+
Prerenders every page into `publish/` as static files. Check them with `shelldocs preview`, which serves the folder at `http://localhost:5050` the way a static host would, then upload the folder to any static host. See [Deployment](/docs/guides/deployment) for a GitHub Pages workflow and for what needs a server instead.
8181
</Step>
8282
</Steps>
8383

‎content/docs/guides/deployment.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ The output goes to `./publish`. Every flag is covered in [shelldocs build](/docs
5858
- `--site-url` adds `sitemap.xml`, `robots.txt` and social-preview meta tags.
5959
- `--base-href` is needed only when the site is served from a subpath, such as a GitHub project page at `/my-repo/`.
6060

61+
Before uploading, check the export with [`shelldocs preview`](/docs/cli/preview). It serves `publish` at `http://localhost:5050` the way a static host does, including `404.html` for unknown URLs and the subpath of a `--base-href` build.
62+
63+
```bash
64+
shelldocs preview
65+
```
66+
6167
## GitHub Pages
6268

6369
This workflow builds on every push to `main` and can be run by hand.
@@ -141,6 +147,8 @@ For a site served at `https://your-org.github.io/my-repo/`, drop the `CNAME` ste
141147
shelldocs build --base-href /my-repo/
142148
```
143149

150+
The build puts `/my-repo/` in front of every root-relative link, and `shelldocs preview` serves the export at `http://localhost:5050/my-repo/` to check it.
151+
144152
## Other static hosts
145153

146154
Any host that serves a folder works: point it at `publish`. Many hosts' own build environments don't include the .NET SDK, so the dependable setup is to run `shelldocs build` in CI and upload the output, as the workflow above does.
@@ -169,6 +177,7 @@ Any platform that runs ASP.NET Core works: a container, a virtual machine, or a
169177

170178
<CardGrid Columns="2">
171179
<LinkCard Title="shelldocs build" Description="Every flag and what the build does." Href="/docs/cli/build" />
180+
<LinkCard Title="shelldocs preview" Description="Check the export locally before deploying." Href="/docs/cli/preview" />
172181
<LinkCard Title="Redirects" Description="How redirects are written into a static export." Href="/docs/guides/redirects" />
173182
<LinkCard Title="Search" Description="How search works without a server." Href="/docs/guides/search" />
174183
<LinkCard Title="Not-found page" Description="DocsNotFound and the 404.html the build writes." Href="/docs/guides/not-found" />

‎content/docs/introduction.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The whole thing renders : Callout with icon and variant styling, live Button com
6464
## The three packages you'll touch most
6565

6666
<TypeTable>
67-
<TypeRow Name="ShellDocs.CLI" Type="global tool" Description="shelldocs init, add, dev, build. Installed once, works from any directory." />
67+
<TypeRow Name="ShellDocs.CLI" Type="global tool" Description="shelldocs init, add, dev, build, preview. Installed once, works from any directory." />
6868
<TypeRow Name="ShellDocs.Components" Type="Razor Class Library" Description="The chrome (layout, sidebar, search, header) and content primitives (Callout, Card, Steps, CodeGroup, TypeTable, more)." />
6969
<TypeRow Name="ShellDocs.Tokens" Type="Razor Class Library" Description="Shared CSS variables : palette + spacing scale. shadcn-compatible names for interop with ShellUI and other design systems." />
7070
</TypeTable>

‎content/docs/packages/cli.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: ShellDocs.CLI
3-
description: The command-line tool. shelldocs init, add, dev, build. The daily-driver surface for scaffolding, authoring, and shipping.
3+
description: The command-line tool. shelldocs init, add, dev, build, preview. The daily-driver surface for scaffolding, authoring, and shipping.
44
order: 3
55
---
66

@@ -24,13 +24,14 @@ The `--prerelease` flag is required while ShellDocs is on `0.x.y-alpha` versions
2424
dotnet tool update -g ShellDocs.CLI --prerelease
2525
```
2626

27-
## The four commands
27+
## The five commands
2828

2929
<TypeTable>
3030
<TypeRow Name="init" Type="command" Description="Scaffold a fresh ShellDocs site OR augment an existing Blazor project. Two modes: create (default) and attach (--attach)." />
3131
<TypeRow Name="add" Type="command" Description="Scaffold a starter .md page from a template (component / guide / page) into content/." />
3232
<TypeRow Name="dev" Type="command" Description="Start the dev server with hot-reload on .md / .razor / .cs changes." />
3333
<TypeRow Name="build" Type="command" Description="Export a static site: prerenders every page, writes redirects, optional sitemap and social meta tags." />
34+
<TypeRow Name="preview" Type="command" Description="Serve the exported site locally the way a static host would, to check it before deploying." />
3435
</TypeTable>
3536

3637
## `shelldocs init`
@@ -88,6 +89,14 @@ shelldocs build --output publish --base-href "/my-repo/" # for GH Pages subpat
8889

8990
Publishes the project, starts it locally, saves every page as static HTML, writes redirect pages, a `404.html`, the search index and the [llms.txt files](/docs/guides/llms-txt), and copies the assets. `--site-url` adds a sitemap, a robots file and social meta tags; `--base-href` handles subpath hosting; `--spa-fallback` replaces `404.html` with the home page. See [shelldocs build](/docs/cli/build).
9091

92+
## `shelldocs preview`
93+
94+
```bash
95+
shelldocs preview # serve ./publish at http://localhost:5050
96+
```
97+
98+
Serves the export the way a static host does: folders serve their `index.html`, unknown URLs get `404.html`, and a site built with `--base-href` is served under that path. See [shelldocs preview](/docs/cli/preview).
99+
91100
## Version discipline
92101

93102
`shelldocs init` scaffolds package references at the CLI's own version, read from its assembly. A project scaffolded with CLI `0.1.18-alpha` references the `0.1.18-alpha` packages. In CI, pin the tool to the same version your project references.

0 commit comments

Comments
 (0)