Repository navigation
feat: Add Aspire sample detail pages - #1089
Conversation
165e329 to
dd1afe7
Compare
There was a problem hiding this comment.
Pull request overview
Adds dedicated /reference/samples/{sample}/ detail pages rendered from upstream sample READMEs, refreshes the sample catalog (15 → 26 samples) with AppHost-aware metadata and thumbnails, and revamps the samples grid filter UX (tag counts, embedded clear icons, URL-synced filters, accessible empty state). Also switches the shared markdown API response helper from text/markdown to text/plain.
Changes:
- New
SampleDetail.astro+SampleReadmeBlocks.astrorender samples with hero, AppHost code block, Steps, GitHub alerts → Asides, Mermaid, and a zoomable screenshot gallery. - New routes
/reference/samples/[sample]/index.astroand/reference/samples/[sample].md.ts, with middleware updated to redirect trailing slashes for sample.mdURLs. - Sample card + grid redesign with AppHost pills, clickable cards, URL-synced search/tag filters, and a collapsible tag wall on mobile.
Reviewed changes
Copilot reviewed 18 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/src/components/SampleDetail.astro | New detail component: hero, AppHost code, README rendering, screenshots gallery. |
| src/frontend/src/components/SampleReadmeBlocks.astro | New recursive renderer for README blocks with Steps/Asides/Mermaid/Code support. |
| src/frontend/src/components/SampleCard.astro | Plain-text descriptions, AppHost pill, clickable card → detail page. |
| src/frontend/src/components/SampleGrid.astro | New filter UX: tag counts, clear-all link, URL sync, mobile collapse, embedded clear icon. |
| src/frontend/src/utils/samples.ts | New shared types + helpers (AppHost labels/icons, slug, markdown builder, plain-text helper). |
| src/frontend/src/utils/sample-tags.ts | Adds typescript tag label. |
| src/frontend/src/utils/api-markdown-shared.ts | Switches markdown response Content-Type to text/plain. |
| src/frontend/src/pages/reference/samples/[sample]/index.astro | Generates per-sample detail pages from samples.json. |
| src/frontend/src/pages/reference/samples/[sample].md.ts | Generates per-sample raw markdown endpoint. |
| src/frontend/src/middleware.ts | Extends nested markdown-pattern to cover samples. |
| src/frontend/scripts/update-samples.ts | Adds AppHost detection + raw README capture for all samples. |
| src/frontend/config/sidebar/reference.topics.ts | Adds id: 'reference' to topic config. |
| src/frontend/package.json + pnpm-lock.yaml | Adds [email protected] dependency. |
| tests/unit/custom-components.vitest.test.ts | Adds SampleDetail render coverage and updates SampleGrid/SampleCard assertions. |
| tests/unit/api-markdown.vitest.test.ts | Updates content-type expectation to text/plain. |
| tests/typecheck/component-props.contracts.ts | Adds SampleDetail prop contract checks. |
| tests/e2e/custom-components.spec.ts | E2E for URL-synced sample filters. |
| tests/e2e/api-markdown-routes.spec.ts | Adds sample .md route + new content-type expectation. |
Files not reviewed (1)
- src/frontend/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dd1afe7 to
709bc0b
Compare
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Drop the decorative circle in favor of a small connected-nodes SVG that echoes Aspire's distributed-app story without copying TopicHero's grid plus floating-icon language. Highlights: - Animated dashed edges with a slow flow shader simulate data movement. - Five nodes positioned in a balanced layout; one pulses per sample, picked by hashing the sample slug so every page feels distinct. - Dual radial glows (primary at upper-right, secondary at lower-left) warm the hero without grid scaffolding. - Kicker becomes an inline pill with a tag-driven Starlight icon (Docker, db, Azure, dashboard, C#, TypeScript, or rocket fallback) to give each hero a quick visual cue about the sample's stack. - Existing CTAs, summary, tags, and accessibility hooks unchanged. - Animations gated behind prefers-reduced-motion. Co-authored-by: Copilot <[email protected]>
Fetch the sample directories' file tree once via the GitHub git-trees API and classify each sample as TypeScript (apphost.ts), file-based C# (apphost.cs), or csproj C# (*AppHost.csproj). Promote the detected language to a sample tag so the TypeScript filter chip lights up in the samples grid. Render the AppHost flavor as a pill on the sample card and as a sibling pill alongside the 'Aspire sample' kicker on the detail hero, with a dedicated TypeScript color treatment. Co-authored-by: Copilot <[email protected]>
The starlight-page-actions plugin fetches '<currentPath>.md' for both Copy Markdown and Open in Markdown, so a dynamic .md route at every sample slug has to exist. Generate one by mirroring the C#/TypeScript API reference pattern with a [sample].md.ts companion to the existing [sample]/index.astro route, prerendered per static path. Store the original upstream README (readmeRaw) in samples.json so the markdown payload stays portable when pasted into an LLM or opened in a browser. Relative image paths are rewritten to absolute raw.githubusercontent.com URLs so screenshots render anywhere the markdown is consumed. Flip 'pageActions: true' in the StarlightPage frontmatter of the detail page so the Copy / Open / Share buttons show up. Co-authored-by: Copilot <[email protected]>
- Drop the leading paragraph from the rendered README when it matches the hero summary so the descriptive sentence only appears once on each sample detail page. - Always use a neutral 'rocket' icon for the 'Aspire sample' kicker pill so the language signal lives entirely on the AppHost pill. - Switch the .csproj AppHost icon to inline angle-brackets (XML-ish) so the C# logo glyph no longer collides with the 'C#' word in the label. - Apply official brand colors to the AppHost pills: #512BD4 for C# (csproj and file-based) and #3178C6 for TypeScript, on both SampleCard and SampleDetail. - Drop the redundant 'C#' word from the short label for file-based AppHosts since the seti C# glyph already carries the language signal. Co-authored-by: Copilot <[email protected]>
Add an AppHost code section that renders right after the hero on every sample detail page so visitors immediately see the orchestration entry point for the sample they are looking at. - update-samples generator: extend the AppHost detection to return both the kind and the actual entry-point file path (prefers AppHost.cs over Program.cs adjacent to a *AppHost.csproj, picks apphost.ts for TS, and the standalone AppHost.cs for file-based AppHosts). - Fetch the entry-point file contents during generation and persist appHostCode + appHostPath alongside the existing appHost kind. Trim trailing whitespace and normalize line endings so the JSON stays stable across runs. - SampleDetail renders a new <section class='sample-apphost'> above the README with the section heading 'The <filename> entry point', a 'View on GitHub' link that points at the blob URL of the source file, and the code itself in an expressive-code <Code> block using the language inferred from the file extension (typescript / csharp / xml). - Add appHostCodeLang and appHostCodeTitle helpers so the lang and the rendered title can be derived without per-component duplication. - Add a SampleDetail vitest assertion covering the new section, the blob-URL source link, and the language attribute on the code block. Co-authored-by: Copilot <[email protected]>
Starlight's <Steps> component is meant for top-level numbered procedures. When a README has a numbered sub-list inside an outer step, the recursive <Astro.self ...> call inside SampleReadmeBlocks would wrap the inner ordered list in another <Steps>, producing double indents, large duplicate bullet circles, and a broken visual rhythm.
Thread a
ested prop through the recursive renders. The top-level invocation from SampleDetail (default alse) still wraps ordered lists in <Steps>; recursive renders pass
ested={true}, which renders nested ordered lists as plain <ol> and unordered lists as plain <ul> without the Starlight step chrome. The blockquote branch propagates the current
ested value so quoted procedures keep their containing context.
Extends the SampleDetail vitest fixture with a nested ordered list and asserts the rendered HTML contains exactly one sl-steps class — one for the outer procedure, zero for the inner steps.
Co-authored-by: Copilot <[email protected]>
Previously, .sample-hero had no max-width while .sample-readme and .sample-apphost were each capped at 56rem. The hero stretched to fill the Starlight content area while the code block and README rendered noticeably narrower, producing a stepped right edge between the hero card and everything below it. Move the 56rem cap onto the .sample-detail wrapper so all three children inherit the same column. Removes the duplicate max-width from .sample-readme and .sample-apphost since they now derive their width from the shared parent. Co-authored-by: Copilot <[email protected]>
* SampleCard: AppHost flavor badge now sits in the bottom-left corner opposite the View on GitHub link; footer uses margin-left: auto instead of a spacer div. The appHostIconName helper moved to utils/samples.ts so the card and detail page share one source. * SampleDetail: View on GitHub CTA now uses the GitHub mark on the leading edge instead of the trailing external-site arrow, matching the in-page footer link treatment. * SampleReadmeBlocks: README image groups no longer leave dangling paragraphs orphaned underneath the gallery. Trailing text after a grouped image set is now folded back into the gallery caption block so sections like /reference/samples/aspire-with-javascript/ render cleanly. Co-authored-by: Copilot <[email protected]>
The middleware-level trailing-slash redirect for .md routes was hard-coded to /reference/api/(csharp|typescript)/..., so navigating to /reference/samples/<slug>.md without a trailing slash always returned 404 instead of redirecting. Extend the regex to cover samples as well. While here, switch markdownResponse() to text/plain; charset=utf-8 so all .md endpoints (csharp, typescript, samples) render inline in a new tab on Chrome, Edge, and Safari. The browsers treat text/markdown as a binary download type, which made the "View as Markdown" page action save the file instead of opening it. The Copy Markdown action uses fetch().then(r => r.text()) so the Content-Type change has no effect there. Co-authored-by: Copilot <[email protected]>
* Search box now has the standard X icon clear button embedded in the input (mirrors InpageSearch), hidden via the HTML hidden attribute until the user types. The UA-provided type="search" clear is suppressed so there is only one affordance. * Tag chips are quiet by default (transparent background, 1px gray-5 border, 0.78rem text, inline muted count). Active chips fill with a 14% mix of the accent color so they are the only loud item in the row. Tighter sizing on viewports up to 480px. * On viewports up to 768px the chip row collapses to ~4.5rem with a subtle bottom-fade mask and a chevron "Show all N tags" toggle. If a hidden chip is already active on URL hydrate, the row auto-expands so users can see what is filtering their view. * Replaced the duplicate "Filtered by" bar with a single subtle "Clear all" underlined text link in the results header. The active chips themselves remain the source of truth for active filters. * Search and tag state now syncs to ?q=<query>&tags=<slug,slug> via history.replaceState. Hydrating from the URL silently drops unknown tag slugs and ignores whitespace-only queries; updates use replaceState so the back/forward stack stays clean. Test updates: * custom-components.vitest.test.ts: assert the new data-clear-all link, the aria-label="Clear search" X icon, and that the readFiltersFromUrl/URLSearchParams/history.replaceState hooks ship in the rendered HTML. * custom-components.spec.ts: new Playwright case that loads /reference/samples/?q=redis&tags=databases,not-a-real-tag, asserts the input prefill, the active chip state, that unknown slugs are dropped from the URL, that toggling another tag appends to ?tags=, and that Clear all resets every filter and removes ?q=/?tags= from location.search. Co-authored-by: Copilot <[email protected]>
The shared `readMarkdown()` helper asserts the content-type from `markdownResponse()`. We switched that response to `text/plain; charset=utf-8` (so browsers display raw markdown inline instead of triggering a download); the test was still asserting `text/markdown` and failing on CI for the TypeScript function and member route cases. Update the assertion to match the new behavior. Co-authored-by: Copilot <[email protected]>
Reverts the SSR-only text/plain switch on .md endpoints. The production preview server (astro preview / sirv) infers Content-Type from the .md extension as text/markdown, so the markdownResponse() helper's text/plain header only took effect under SSR / astro dev. CI runs Playwright against astro preview and therefore saw text/markdown, failing the assertion across all 12 api-markdown route cases. The page-actions "Copy Markdown" button consumes the body as text directly and does not depend on the Content-Type. Browser inline display of "View Markdown" is a hosting-server concern; align the helper, unit assertion, and e2e assertion all back to text/markdown so they reflect what is actually served. Co-authored-by: Copilot <[email protected]>
The sample detail page set tableOfContents: false on its StarlightPage frontmatter. Without a TOC, Starlight does not set the html[data-has-toc] attribute that our custom topic-sidebar CSS in Sidebar.astro relies on to inline the collapse/expand toggle into the mobile "On this page" bar at 50-100rem viewport widths. The toggle therefore floated at the top of the content column and visually overlapped the page H1 at 1024x600 (the title wrapped just below the toggle, putting its first character behind the button glyph). Other topic-nav pages such as /integrations/frameworks/go/go-get-started/ work correctly because their MDX frontmatter enables a TOC by default. Enable a real TOC (minHeadingLevel: 2, maxHeadingLevel: 3) on the sample detail page. The page has substantive H2 headings (the hero "Clone, run, and explore this sample" plus the README's h2/h3 sections) so a TOC is genuinely useful, not just a layout workaround. Verified at 1024x600: toggle anchors to (330, 63) inline with the mobile TOC bar and the H1 renders cleanly at (346, 152) — identical to the working integration page layout. Co-authored-by: Copilot <[email protected]>
The inline-with-TOC override in Sidebar.astro that anchors the
collapse/expand toggle inside the mobile "On this page" bar at
50-100rem only fires when html[data-has-toc] is set. Landing pages
such as /deployment/ set tableOfContents: false in their frontmatter,
so without a TOC bar the toggle falls back to its floating-tab base
position at the top of the article column where its leftmost ~48px
overlap the page H1 at narrow widths — the H1 also starts at the
article column's left edge, and at 1024x600 the two visibly collide
("A" in "Aspire deployment overview" sits behind the toggle glyph).
Hide the topic-sidebar and api-ref toggles in the 50-100rem and
72-100rem ranges respectively when html[data-has-toc] is absent. At
>= 100rem the article column has enough horizontal room that the
floating-tab position clears the H1, and the existing hide rules
already drop the toggles below their respective mobile-menu
breakpoints, so the new rules target exactly the broken range.
Add an e2e regression test against /deployment/ that asserts the
toggle is hidden on no-TOC topic-nav landing pages at 50-100rem
viewports. Mirrors the existing 'sidebar collapse toggle does not
overlap the mobile On this page control' test alongside which it
sits.
Co-authored-by: Copilot <[email protected]>
Replaces the previous hide-toggle approach (d91c18a) with one that keeps the collapse/expand control accessible. On no-TOC topic-nav pages at 50-100rem and no-TOC api-ref pages at 72-100rem, anchor the toggle into a synthesized TOC-bar-height row at the top of the article column (matching the inline-with-TOC treatment used on TOC pages), and pad the first .content-panel > .sl-container by 3rem so the H1 starts below the toggle instead of behind it. The padding rule lives in site.css rather than Sidebar.astro because Astro's component-scoped styles add [data-astro-cid-*] attributes to selectors targeting non-component-owned elements like .content-panel, making the rule never match. The Sidebar.astro anchor rule uses literal 3rem rather than var(--sl-mobile-toc-height, 3rem) because Starlight defines the variable as 0rem outside [data-has-toc] scope, defeating the CSS fallback. Update the regression test to assert the toggle stays visible AND that its bounding box does not overlap the page-title H1, instead of asserting it is hidden. Co-authored-by: Copilot <[email protected]>
microsoft/aspire-samples#1656 (Upgrade Aspire samples to 13.4) renamed the TypeScript AppHost entry point from apphost.ts to apphost.mts (Aspire 13.4's new default layout, with the generated SDK moving from ./.modules/ to ./.aspire/modules/) and bumped the file-based AppHost samples from [email protected] to @13.4.0. Re-run pnpm update:samples to pick up the upstream changes. Eleven samples (golang-api, node-express-redis, polyglot-task-queue, python-fastapi-postgres, python-openai-agent, python-script, rag-document-qa-svelte, vite-csharp-postgres, vite-react-fastapi, vite-yarp-static, image-gallery already file-based) refreshed; all TypeScript samples now correctly resolve appHostPath to apphost.mts and the file-based AppHost samples carry the 13.4.0 SDK pin. Teach the data pipeline about the new file shape so detection survives both the legacy .ts and current .mts conventions: * scripts/update-samples.ts: detectAppHost regex now matches apphost.m?ts so the TypeScript AppHost takes precedence over the .cs fallback (previously the regex only matched apphost.ts, which caused every renamed sample to be misclassified as AppHost: null in the first attempt and lose its typescript tag). The TAG_RULES TypeScript pattern matches apphost.m?ts and .m?tsx? for the same reason. * src/utils/samples.ts: appHostCodeLang treats .mts as typescript so the rendered AppHost code block on /reference/samples/<slug>/ still uses TypeScript syntax highlighting after the rename. Verified live on /reference/samples/{golang-api,node-express-redis,vite-react-fastapi}/: code block title shows apphost.mts, language is typescript, and the GitHub link resolves to the renamed file. Unit tests (api-markdown + custom-components, 75 passed) and lint clean. Co-authored-by: Copilot <[email protected]>
c8f1c2a to
63d00f1
Compare
Sample detail pages are short, predominantly card/grid-driven, and don't benefit from the inline `On this page` rail. Set tableOfContents: false in the [sample]/index.astro StarlightPage frontmatter so the page renders without the right-hand TOC and without the collapsed mobile TOC bar. The collapse/expand sidebar toggle continues to render cleanly at 1024-1600px: the no-TOC anchor rule in Sidebar.astro and the matching padding rule in site.css (added in c8142ad) detect `html:not([data-has-toc])` and reserve a synthesized TOC-bar-height row at the top of the article column so the H1 starts below the toggle instead of behind it. Verified live on /reference/samples/{golang-api,aspire-shop,vite-react-fastapi}/: hasToc=false, toggle visible at (330, 63, 48, 48), H1 at y=152, no overlap. Co-authored-by: Copilot <[email protected]>
marked carries both a ext field and a okens array on strong/em/del/link inline tokens (e.g. `**foo**` lexes to `{type:'strong', text:'foo', tokens:[{type:'text', text:'foo'}]}`). The previous implementation pushed `node.text` AND walked `node.tokens`, doubling characters from emphasized spans. That silently broke two downstream helpers:
- dropLeadingSummaryParagraph: README first paragraphs that contained any inline emphasis no longer matched the summary head's startsWith check, so the leading sentence was rendered twice (hero summary + body paragraph).
- paragraphIsShortLabel: an emphasized label longer than ~30 chars measured as >60 after doubling, was rejected as `not short`, and survived as an orphan paragraph in front of its extracted screenshot.
Fix per reviewer suggestion: leaf-only token types (text, codespan) push their text field; wrapping types (em, strong, del, link) only recurse into tokens so the inner text/codespan contribute characters once. Replace `as any` casts with typed unions.
Add a regression test that exercises both downstream code paths with an emphasized first paragraph and a 49-char emphasized label preceding a standalone image.
Addresses #1089 (comment)
Co-authored-by: Copilot <[email protected]>
Setting tableOfContents: false on sample pages also removed Starlight's mobile-only `On this page` dropdown at narrow and medium widths, leaving readers with no way to jump between headings on phone/tablet/sub-desktop layouts. Re-enable tableOfContents so the mobile dropdown returns, then suppress only the desktop right-rail TOC (which the prior request specifically wanted gone) by hiding .right-sidebar-panel at >=100rem. The mobile dropdown is nested inside the same .right-sidebar wrapper as the right-rail panel, so the suppression has to target the panel specifically and leave the wrapper intact; also force .lg\\:sl-hidden visible at >=100rem since Starlight would otherwise hide the mobile dropdown at that breakpoint. Widen --sl-content-width on sample pages at >=100rem so the hero/code reclaim the column the right-rail would have occupied instead of leaving an empty band on the right. Verified visually at 600px (mobile), 1024px (1024x600 user-reported breakpoint), 1280px (medium-wide), and 1700px (wide). Non-sample docs pages keep the right-rail TOC at >=100rem (no regression). Co-authored-by: Copilot <[email protected]>
|
Ran the doc-tester pass locally on the samples pages. The grid loads with 26 samples, card titles navigate to local detail pages, View on GitHub stays external, tag filtering works, and both Clear all and the empty-state Reset all filters reset back to 26 samples. All 26 generated sample detail routes returned 200 with an H1 and GitHub CTA, and the narrow viewport still exposed “On this page”. A few upstream sample summary typos now render visibly on aspire.dev:
Maybe these belong in |
Adam Ratzman (adamint)
left a comment
There was a problem hiding this comment.
doc-tester pass looks good to me. The sample grid, generated detail pages, filtering, reset behavior, and narrow viewport checks all worked locally.
* Fix typos in sample README summaries These typos surface on aspire.dev's new sample detail pages (microsoft/aspire.dev#1089), where the sample summaries are pulled directly from each upstream README. - aspire-shop: `catlog` -> `catalog` (paginated catalog of products) - aspire-with-python: `JavaSript` -> `JavaScript` - container-build: `a Aspire application` / `a Aspire app` -> `an Aspire ...` (title + intro paragraph) - database-containers: `a Aspire application` / `a Aspire app` -> `an Aspire ...` (title + intro paragraph) Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Addresses follow-up feedback on #1089 (#1089 (comment)) where small typos in upstream sample READMEs render on the new sample detail pages: - aspire-shop: `catlog` -> `catalog` - aspire-with-python: `JavaSript` -> `JavaScript` - container-build: title + intro `a Aspire application` / `a Aspire app` -> `an Aspire application` / `an Aspire app` - database-containers: title + intro `a Aspire application` / `a Aspire app` -> `an Aspire application` / `an Aspire app` Patches each sample's `title`/`description`/`readme`/`readmeRaw` fields in `samples.json` so the live site stops showing the typos immediately. Long-term fix for the upstream READMEs is in microsoft/aspire-samples#1667; once that merges, the next `update-samples` run will produce identical output (so this patch is idempotent with the upstream fix). Co-authored-by: David Pine <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
src/frontend/src/data/samples.jsonfrommicrosoft/aspire-samples@main, bringing the catalog from 15 to 26 samples./reference/samples/{sample}/detail pages with README content, tags, thumbnails, and GitHub CTAs.og:image, and WCAG AA-compliant CTAs.Validation
pnpm exec vitest run --config vitest.config.ts tests/unit/custom-components.vitest.test.ts -t "Sample" --reporter=dotpnpm lint