Skip to content

Conversation

@alexwarren
Copy link
Contributor

This PR builds all the Squiffy example files and makes them available via the website.

claude and others added 14 commits January 13, 2026 04:11
- Created site/scripts/build-examples.ts to automatically package all .squiffy examples using the packager
- Added build:examples script to site package.json that runs before main build
- Added dependencies: tsx, glob, and @textadventures/squiffy-packager to site
- Updated examples.mdx to include "Play" links that open packaged versions in new tabs
- Examples are output to site/public/examples/{name}/ as standalone HTML/JS/CSS
- Build script handles errors gracefully, continuing if individual examples fail
- 23 of 24 examples successfully packaged (animate example missing ui.js dependency)
- Fixed externalFiles.getContent() to resolve relative paths against basePath
- This fixes the animate example which uses @ui ui.js (relative path)
- All 24 examples now build successfully (was 23/24, now 24/24)
- Added examples/README.md explaining how to play examples online and locally
- README links to squiffystory.com/examples for easy access to built versions
- Created cli/src/index.ts to export externalFiles and other utilities
- Updated CLI package.json to export library functions via main/exports fields
- Fixed externalFiles.getContent() to resolve relative paths in CLI package
- Updated site build script to import externalFiles from @textadventures/squiffy-cli
- Removed duplicated externalFiles implementation from site/scripts/build-examples.ts
- All 24 examples build successfully with shared implementation

This eliminates code duplication and ensures consistent behavior across
the CLI and site build processes.
- Modified packageExample() to extract and return story title using getUiInfo()
- Added generateIndexPage() function to create a clean HTML index of all examples
- Index page features:
  - Responsive card layout with hover effects
  - Shows story title and folder path for each example
  - Alphabetically sorted examples
  - Links to squiffystory.com and documentation
- Examples are now browsable at /examples/ with links to each story
- Index page is automatically regenerated on each build
- Deduplicate examples by directory name before generating index
  (fixes issue where directories with multiple .squiffy files appeared twice)
- Changed all links to use explicit index.html paths instead of directory paths
  (fixes issue in dev mode where directory-only links don't work)
- Index now shows 22 unique examples instead of 24 with duplicates
- Links work correctly in both npm run dev and production builds

Changes:
- site/scripts/build-examples.ts: Filter unique examples before generating index
- site/scripts/build-examples.ts: Use ${ex.name}/index.html in href
- site/src/content/docs/examples.mdx: Update play links to use index.html
- Created examples/examples.json to explicitly list which examples to build
- Excludes test examples (warnings/) that aren't meant to be playable
- Handles multi-file examples correctly (import/test.squiffy is entry point)
- Build script now reads manifest instead of globbing for all .squiffy files
- Reduced from 24 builds (with duplicates) to 20 unique examples
- Updated examples/README.md to document the configuration approach

Benefits:
- Explicit control over published examples
- No more duplicates from multi-file directories
- Can add metadata (descriptions, featured flag) for future use
- Clear entry point for examples with multiple .squiffy files
- Added public/ to tsconfig.json exclude list
- Prevents astro check from checking generated example .js files
- Reduces build warnings from hundreds to just a few
- Generated files in public/examples/ are build artifacts, not source code

This eliminates the TypeScript warnings about the packaged example files
during the site build process.
The astro check command was consuming excessive memory (~4GB) when
analyzing the generated JavaScript files in public/examples/, causing
the build to crash. TypeScript errors are still caught during
development by the IDE and Astro dev server.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Sort examples with featured items at top, then alphabetically
- Display description from examples.json for each example card
- Add visual styling for featured examples (orange border, badge)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove visual distinction for featured examples (keep sort order only)
- Add "Play" and "View Source" links to each example card
- Source links point to GitHub examples directory

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@alexwarren alexwarren merged commit 7bef6f3 into textadventures:main Jan 15, 2026
5 checks passed
@alexwarren alexwarren deleted the claude/link-packaged-examples-qJS9J branch January 15, 2026 20:33
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.

2 participants