Skip to content

fix(cms): fill a Webflow collection's date field with the day a page is first sent - #1600

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/webflow-required-date
Oct 27, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:fix/webflow-required-date

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Send to CMS fills a Webflow collection's date field. Ansvisor's own Webflow blog collection ("Blog Posts") requires a Date field. Send to CMS didn't fill one, so Settings › Integrations refused the collection:

The collection requires Date, which Send to CMS doesn't fill: make it optional in Webflow, or pick another collection

Many Webflow blog templates have such a required date.

  • A new part, date (server/src/lib/cms/webflow.js):
    • it goes to a Webflow DateTime field;
    • it counts as always filled (ALWAYS_FILLED), so a required date mapped to it no longer refuses the collection;
    • other required fields Send to CMS doesn't fill still do, with the same message.
  • The value (webflow-items.js, webflow-delivery.js):
    • A new item gets the day it's sent, as ISO 8601.
    • An item sent again keeps its own date, since a blog template uses it as the publish date. The update leaves the field out, as it does Webflow's other own fields.
  • The suggestion: the date is suggested only for a date field the collection requires. The one that reads as a date (publish / date / posted) comes first, else the collection's only required date. An optional date isn't filled unless someone maps it.
  • Webflow's own dates (created-on, updated-on, published-on) can't be mapped (OWN_FIELDS). getCollection already left them out.
  • Settings › Integrations › Webflow: a "Date (the day it's first sent)" row in "Which field takes what", with a short line under it once it's mapped.

The settings card is also touched by #1593 (token steps) and the set-up badge PR, on different lines. Whichever merges second may need a small merge of webflow-card.tsx and en.json.

Related issue

Part of #1331 (Send to CMS), found in Ansvisor's own live Webflow set-up.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/lib/cms/webflow.test.js src/lib/cms/webflow-items.test.js src/lib/cms/webflow-delivery.test.js
  2. cd web && yarn vitest run src/components/settings/webflow-card.test.tsx src/lib/webflow-client.test.ts
  3. On a server with Webflow set up, connect a site whose collection requires a Date field:
    • the Date row is suggested and Save works;
    • Send to CMS creates a draft item with today's date;
    • sending it again keeps that date.

Checked in the browser at 1024 px, light and dark. This server has no Webflow set up, so the card's reads were stubbed in the page: a connected site, and a "Blog Posts" collection with a required rich text, an optional summary and a required Date.

  • Picking the collection suggested Post Body, Post Summary and Date (required) for the new "Date (the day it's first sent)" row, with its line under it.
  • No "requires Date" problem was shown. Save sent { body, metaDescription, date } and said "Saved. Pages go to Blog Posts."
  • Nothing scrolls sideways.

Worth a look on the first live send: the update relies on Webflow's PATCH leaving out fields untouched. The send already updates items that way.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • server/: npm run format, npm run lint and npm test (2,945 tests);
  • web/: yarn format, yarn lint (0 errors), yarn typecheck, yarn test and yarn build.

In the full web run, one Library test that times a long list ("reads a long list's pages fifty at a time") failed under load. Run alone, it passes: 4,139 tests in all.

🤖 Generated with Claude Code

…is first sent

A Webflow blog template often requires a Date field. Send to CMS didn't
fill it, so the field map refused such a collection ("The collection
requires Date, which Send to CMS doesn't fill").

- A new part, `date`, goes to a DateTime field and counts as always
  filled.
- A new item is given the day it's sent (ISO 8601). One sent again keeps
  its own date, as a blog's publish date.
- Webflow's own dates (created-on, updated-on, published-on) can't be
  mapped.
- The date is suggested only for a date field the collection requires:
  the one that reads as a date, else its only one.
- Settings › Integrations shows the row, with a line on what goes there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, with follow-ups.

What I checked:

  • Own change. One commit on 5bbd162, the commit before #1593. It merges clean on main (15b5b5f) and with #1601. With both, the card, en.json and the card test merge without a conflict and the card test passes (20).
  • Webflow's field type and value.
    • Webflow's API v2 calls a date field DateTime, and it takes an ISO 8601 string. sentAt.toISOString() gives one in UTC with a Z, e.g. 2026-10-27T09:30:00.000Z.
    • Sending the moment, not a bare day at midnight UTC, is the right call. Webflow keeps the instant, and a template shows it in the site's own time zone. So the day shown is the site's day when the page was sent. A midnight-UTC date would show the day before on a site west of UTC.
    • created-on, updated-on and published-on are kept out of the map (OWN_FIELDS), on top of getCollection dropping fields that aren't editable.
  • First send vs. a send again (webflow-delivery.js:71, :81).
    • An update sends the fields without the date, so an item keeps its own (Webflow's PATCH leaves out fields as they are).
    • A new item, and an item made again after it was deleted in Webflow, get the date. Both are tested.
  • The suggestion and the check.
    • The date is suggested only for a required DateTime: the one named publish / date / posted, else the only one. Two required dates with neither named as a date are left to the person.
    • checkFieldMap takes date only on a DateTime, and a required date mapped to it no longer refuses the collection. Unmapped, it still does, with the same message.
    • The hint regexes are short and fixed, on a slug plus a name: nothing slow there.
  • Web. WEBFLOW_PARTS and WEBFLOW_PART_TYPES gain date. The card's row, picker filter, problem labels and fitting all read from them, so the row needs nothing else. parts.date and dateHint are in en.json.
  • Tests. Server: the 89 tests in src/lib/cms/, routes/cms.test.js and content-delivery.test.js pass. With main's webflow.js, webflow-items.js and webflow-delivery.js, the four new tests fail and the rest pass. Web: the card and client tests pass (21). With main's card, client and en.json, the new card test fails. CI's web job doesn't run web tests.
  • Before the API deploy. The web shows the Date row at once, but the API on prod doesn't know the part yet. It still refuses a collection that requires a date, with today's message, and drops a mapped optional date on save. Nothing that works today breaks. The Date row works once the API is deployed.

Follow-ups:

  1. Pages sent before the date was mapped stay undated (webflow-delivery.js:71). A brand that maps an optional date, or makes its date required in Webflow later, keeps an empty date on every item sent before. A send again leaves it empty. If that shows up, fill the date on an update only when the item has none. getItem already reads the item's fields.
  2. Merge with the Framer server PR (#1576, and #1579 on top of it). Both edit the end of fieldDataFor in webflow-items.js. #1576 moves the JSON-LD into jsonLdText. Whichever merges second keeps both: jsonLdText for the JSON-LD, and the date line after it.

@gkhngyk
gkhngyk merged commit 4ad32d3 into ansvisor:main Oct 27, 2026
6 checks passed
gkhngyk added a commit that referenced this pull request Oct 28, 2026
* fix(cms): give a Webflow item sent again a date when it has none

Follow-up from #1600 (item 1). Only a new item was given the day it's
sent; an item sent again kept its date. So a brand that maps an optional
date later, or makes its date required in Webflow, kept an empty date on
every item sent before, and a send again left it empty.

When the field map gives a date, sendToWebflow now reads the item before
updating it (getItem, which says which fields hold a value) and, when its
date is empty, sends today's with the update. An item that can't be read
is updated without a date, as before; without a date field nothing is
read.

The Send to CMS guide's field table lists the Date field (#1507's
follow-up) and says an item sent again keeps its date, or gets one.

fieldDataFor (webflow-items.js) is unchanged, so this doesn't meet the
Framer PRs' edit at its end (#1576, #1579).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(cms): say which Webflow items are given the day they're sent

Review follow-up. The comment above createItem still said only a new item
is given the day it's sent, but an item sent again with an empty date now
gets it too. It names both now. Comment only; webflow-items.js untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(cms): keep a Webflow item's date when the read didn't see its fields

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
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