discovery: emit Gutenberg block markup for Squarespace 7.1 sqs-block HTML#67
Open
davipontesblog wants to merge 1 commit into
Open
Conversation
…HTML Squarespace 7.1's per-post item.body is a deeply-nested layout of <div class="sqs-layout"><div class="row"><div class="col"> <div class="sqs-block ...">...</div></div></div></div>. Passed straight into <content:encoded>, WordPress wraps the entire body in a single Classic block during import — editor can't reorder images, can't swap individuals, can't use the native gallery lightbox. New src/adapters/squarespace-blocks.ts exposes squarespaceHtmlToGutenberg(html) which walks every top-level sqs-block element and emits the matching Gutenberg block markup: sqs-block image-block → core/image sqs-block gallery-block → core/gallery (linkTo:media → core lightbox) sqs-block html-block → core/heading / paragraph / list / quote / separator sqs-block embed-block/video → core/embed (with provider slug) sqs-block quote-block → core/quote sqs-block horizontal-rule-block → core/separator sqs-block spacer-block → dropped (Gutenberg handles spacing) unrecognised sqs-block → core/html (lossless fallback) Prefers data-image over src for lazy-loaded images (same root cause as the DOM-fallback fix). Gallery items get an <a href> wrapper and linkTo:media so core's native lightbox triggers. Wired into squarespace.ts extractPage() right before the bodyText quality scoring. No-op when input has no sqs-block markers, so the DOM-fallback path is unaffected. 12 new unit tests; full suite still passes (416 tests). Found while migrating walkaboutchronicles.com — every post body was a single uneditable Classic block. See DISCOVERIES.md for full context.
borkweb
added a commit
that referenced
this pull request
Jun 5, 2026
## Summary Absorbs PR #67's sqs-block→Gutenberg transform as an `AdapterBlocks` capability attached to the squarespace adapter. The transform fires at reconstruct time (not extraction), so the extraction layer stays unchanged. Returns `null` for HTML with no `sqs-block` markers, making it safe to call on every post body. ## Why Without this, every Squarespace 7.1 post imported as a single Classic block. Gallery lightbox, per-image editing, and block reordering were all unavailable until the user manually ran "Convert to blocks". ## How `blocks.ts` ports all helpers from PR #67 verbatim, with two interface adaptations: the top-level function takes a `BlockRecipeContext` second arg (per the `AdapterBlocks` seam contract) and returns `null` instead of the input string in both passthrough branches. The export is an `AdapterBlocks` object (`{ htmlToBlocks }`) wired into `squarespaceAdapter.blocks` in `index.ts`. ## Testing - 13 vitest tests (TDD: red → green) covering image with `data-image` preference, captioned image, 3-image gallery with `linkTo:media`, heading+paragraph+list, ordered list, YouTube embed with provider slug, spacer drop, horizontal rule, unrecognised block fallback, block-order preservation, and adapter attachment. - `npx tsc --noEmit` clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Squarespace 7.1's per-post
item.bodyis a deeply-nested layout of<div class="sqs-layout"><div class="row"><div class="col"><div class="sqs-block ...">….Passed straight into
<content:encoded>, WordPress wraps the entire body ina single Classic block during import: the editor can't reorder images, can't
swap individuals, can't toggle the native gallery lightbox.
New
src/adapters/squarespace-blocks.tsexposessquarespaceHtmlToGutenberg(html)which walks every top-levelsqs-blockelement and emits the matching Gutenberg block markup:
sqs-block image-blockcore/imagesqs-block gallery-blockcore/gallery(linkTo:media→ core lightbox)sqs-block html-blockcore/heading/core/paragraph/core/list/core/quotesqs-block embed-block/video-blockcore/embed(with provider slug)sqs-block quote-blockcore/quotesqs-block horizontal-rule-block/line-blockcore/separatorsqs-block spacer-blocksqs-block …core/html(lossless fallback)Prefers
data-imageoversrcfor lazy-loaded images (same root cause asthe DOM-fallback fix in the other PR). Gallery items get an
<a href>wrapperand
linkTo:mediaso core's native click-to-zoom lightbox triggers without athird-party plugin.
Wired into
squarespace.tsextract()→extractPage()right before thebodyText quality scoring. No-op when input has no
sqs-blockmarkers, sothe DOM-fallback path is unaffected.
How I found it
While migrating walkaboutchronicles.com — every imported post body was a
single uneditable Classic block. We first built a PHP version of this
mapping inside our migration plugin (https://github.com/davipontesblog/sqs71-to-gutenberg)
and ported the learnings here.
Tested against
blocks on a Studio site)
npx vitest run— 416 passed, 2 skipped)npx tsc --noEmitcleansquarespaceHtmlToGutenbergDiscovery log entry added to DISCOVERIES.md