Skip to content

fix(editor): support template and field query params and prefill (#75) - #138

Merged
anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:fix#75
Oct 17, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:fix#75

Conversation

@bhushan4work

Copy link
Copy Markdown
Contributor

Closes #75

Description

  • Fix template selection from URL query parameters.
  • Prefill editor fields from supported query parameters, including title and description.
  • Support Smart Autofill URL prefill via ?autofill=.
  • Ignore unknown template IDs and unsupported query parameters safely.
  • Prevent hydration mismatches by applying URL parameters after mount.
  • Update README documentation to reflect the supported behavior.

How I Tested This

  • npm run check
  • npm run test
  • Manually verify template selection, field prefill, Smart Autofill prefill, and unknown parameters on /create and /create/{category} using npm run dev.

AI Assistance

none

Type of Change

  • Bug fix
  • New template
  • New feature
  • Documentation
  • Tests
  • Refactoring
  • Performance improvement
  • Other (describe below)

Screenshots

Not applicable; no visual changes.

Checklist

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bhushan4work, the editor part works. I ran it on top of dev in headless Chrome: ?template=quote-centered-serif opens Centered Serif (also from /create/blog), ?title=Hello&description=World fills both fields, an unknown template id or key is ignored, ?autofill= opens Smart Autofill with the URL in it, edits stay after that, and the console has no hydration warnings. On dev the same links still open Minimal Dark. npm run check, all 483 tests and the build pass.

Three things before I merge:

  • The README line still says you can "share or bookmark any configuration". Nothing writes the editor state back to the URL, so a bookmark taken after editing loses the edits. I left a suggestion for that line below.
  • Please drop the "README.md:33 accuracy" test and the "gallery cards link to /create?template=id" test. The first one pins line 33 of the README word for word, so any edit above that line breaks it. The second builds the link inside the test, so it passes whatever templates.astro does.
  • A value that isn't a number goes through as a string for number fields. /create?template=ecommerce-product-card&rating=abc puts "abc" in rating, the slider shows NaN and React logs "Received NaN" twice. Can you skip values where Number.isFinite is false, in both branches of parseEditorQueryParams, and add a test for it?

Comment thread README.md Outdated
- **Social Preview Checker**: Paste any URL to analyze its meta tags and see platform previews
- **Client-side Rendering**: Satori runs in the browser for instant preview during editing. Zero server calls while editing.
- **URL-based State**: All editor state is encoded in URL params — share or bookmark any configuration
- **URL-based State**: Prefill editor state via URL params — share or bookmark any configuration

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **URL-based State**: Prefill editor state via URL params — share or bookmark any configuration
- **Prefill from the URL**: Links like `/create?template=quote-centered-serif&quote=Hello` open the editor with that template and text filled in

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bhushan4work, that's everything. /create?template=ecommerce-product-card&rating=abc now keeps the default rating and the console stays clean, the template links still open the right template, and the README line reads right. npm run check, all 482 tests and the build pass. Merging.

@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 17, 2026
@anurag629
anurag629 merged commit ff987f1 into codercops:dev Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the editor open the template linked from the gallery (read ?template= and field params)

2 participants