Create a Canvas UI of our Content and Data Models
json
{
"nodes":[
{"id":"754a8ef995f366bc","type":"group","x":-300,"y":-460,"width":610,"height":200,"label":"JSON Canvas"},
{"id":"8132d4d894c80022","type":"file","file":"readme.md","x":-280,"y":-200,"width":570,"height":560,"color":"6"},
{"id":"7efdbbe0c4742315","type":"file","file":"_site/logo.svg","x":-280,"y":-440,"width":217,"height":80},
{"id":"59e896bc8da20699","type":"text","text":"Learn more:\n\n- [Apps](/docs/apps.md)\n- [Spec](spec/1.0.md)\n- [Github](https://github.com/obsidianmd/jsoncanvas)","x":40,"y":-440,"width":250,"height":160},
{"id":"0ba565e7f30e0652","type":"file","file":"spec/1.0.md","x":360,"y":-400,"width":400,"height":400}
],
"edges":[
{"id":"6fa11ab87f90b8af","fromNode":"7efdbbe0c4742315","fromSide":"right","toNode":"59e896bc8da20699","toSide":"left"}
]
}
Implementation Details: Dynamic Message Grid & SVG Integration
Overview
This UI prompt is now directly informed by our final implementation of the dynamic message grid in Astro, which visualizes content and data models using modular components, JSON-driven data, and SVG-only icons for robust, themeable rendering.
Component Structure
- Section__IconHeaderMessage.astro: Entry point for the message grid. Iterates over message data and renders each card.
- IconHeaderMessage.astro: Renders individual message cards, with support for SVG icons and theming via Tailwind CSS.
- IconSVGWrapper.astro: Dedicated wrapper to ensure SVG icons render correctly, regardless of light/dark mode or asset path complexity.
- iconHeaderMessages.json: JSON file in
src/content/messages/
that defines the content and icon path for each message card.
SVG Handling: Challenges & Solutions
- Problem: Initial attempts at using mixed icon types (SVG, PNG) led to inconsistent rendering, path resolution errors, and theming issues.
- Solution: Standardized on SVG-only icons. Introduced
IconSVGWrapper.astro
to encapsulate SVG logic, ensuring icons are always found and rendered as intended, with correct theming. - Key Fixes:
- Verified all SVG asset paths and ensured they are referenced relative to the component or via Astro's asset pipeline.
- Updated Tailwind and Vite configs to support SVG imports where necessary.
How to Extend or Modify the Message Grid
- To add a new message card:
- Edit
src/content/messages/iconHeaderMessages.json
and add a new object with title, description, and SVG icon path. - Place the SVG asset in the designated icons directory (verify current location in the repo).
- No code changes are required in the Astro components unless the card layout or logic needs to change.
- To update an SVG icon:
- Replace the SVG file in the icons directory, or update the path in the JSON.
- Confirm the SVG renders correctly in both light and dark mode.
Testing & QA Checklist
- All message cards render with the correct icon and content.
- SVG icons display properly in both light and dark mode.
- Responsive layout: grid adapts to various screen sizes.
- No broken image paths or console errors.
Lessons Learned / Implementation Notes
- SVG-only approach ensures theme compatibility and asset reliability.
- Modular Astro components and JSON-driven content make the UI easy to extend for non-developers.
- Asset path issues are best resolved by using Astro's asset pipeline and verifying all references in JSON and component props.
References
- Changelog: See
content/changelog--code/2025-04-18_01.md
for a summary of this implementation. - Components:
src/components/basics/messages/
,src/components/basics/render-images/IconSVGWrapper.astro
- Content:
src/content/messages/iconHeaderMessages.json