Skip to content

Demo-Supplied Docs Widgets

Goal: Let documentation pages request reusable demo-backed card widgets by explicit category while keeping widget metadata and preview source content in packages/demos.

Non-goals: The portal still owns Astro markup and styling. The widget API does not replace the runnable demos catalog or change demo runtime behavior.

Expected behavior: getDemoWidgetsByCategory('gantt-helper-sources') returns the Gantt helper cards with titles, descriptions, tags, source-preview files, and preview links pointing at the demos portal.

API/config/data model: Add docs widget types with category, title, description, tags, previewHref, optional links, and files. Expose them from @revolist/revogrid-demos/docs-widgets. Resolve the demos portal origin from PUBLIC_DEMO_PORTAL_URL or DEMO_PORTAL_URL, with https://demo.rv-grid.com as the fallback.

Interactions/lifecycle: Widgets are static build-time data resolved from the demos raw source registry. Missing source files should fail through the existing registry lookup.

Rendering/performance notes: Portal components receive already-populated source strings and render them with the existing CodePreview component.

Edge cases: Unknown categories return an empty array. File filtering is optional and defaults to returning the full category. Empty or trailing-slash demo portal URLs are normalized before preview hrefs are generated.

Tests:

  • Build @revolist/revogrid-demos to verify source registry and exports.
  • Build @revolist/revogrid-portal to verify Astro can import and render the API.