Skip to content

Comments

feat: Add PublishedAt and URLField helper utilities#415

Merged
ainsleyclark merged 6 commits intomainfrom
claude/add-payload-helper-fields-dfM5C
Feb 17, 2026
Merged

feat: Add PublishedAt and URLField helper utilities#415
ainsleyclark merged 6 commits intomainfrom
claude/add-payload-helper-fields-dfM5C

Conversation

@ainsleyclark
Copy link
Contributor

Summary

This PR adds two new reusable field helper utilities to the payload-helper package: PublishedAt and URLField. These helpers provide pre-configured Payload CMS fields with sensible defaults and common functionality.

Key Changes

  • PublishedAt: A new date field helper that automatically:

    • Sets the current date as the default value
    • Populates the field when a document is first published
    • Configures the field with sidebar positioning and day-only date picker
    • Supports field overrides for customization
  • URLField: A new virtual text field helper that:

    • Generates URLs dynamically via a custom generation function
    • Automatically appends ?draft=true query parameter when in draft mode
    • Displays as read-only in the admin interface
    • Supports async generation functions and field overrides
  • Exports: Updated common/index.ts and main index.ts to export both new utilities and their TypeScript types

Implementation Details

  • Both utilities follow the existing pattern of accepting optional overrides parameter for field customization
  • PublishedAt uses a beforeChange hook to set the date when status changes to published
  • URLField uses an afterRead hook to dynamically generate the URL based on document data
  • Comprehensive test coverage included for both utilities (127 and 81 test cases respectively)
  • Uses Payload's deepMerge utility for proper field override handling in URLField

https://claude.ai/code/session_01NwyDXYNHC8fkcbWpmRpBfg

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@claude

This comment has been minimized.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.94%. Comparing base (7f6b060) to head (6cb4dd9).
⚠️ Report is 502 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #415      +/-   ##
==========================================
+ Coverage   64.59%   69.94%   +5.35%     
==========================================
  Files         154      185      +31     
  Lines        6064     7394    +1330     
==========================================
+ Hits         3917     5172    +1255     
+ Misses       2064     2025      -39     
- Partials       83      197     +114     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

When generate() returned undefined and draft mode was active, the hook
would produce the string "undefined?draft=true". Now returns undefined
early when generate yields no value.

https://claude.ai/code/session_01NwyDXYNHC8fkcbWpmRpBfg
@claude

This comment has been minimized.

…date exports (#416)

- PublishedAt: replace spread overrides with deepMerge for proper nested merging
- URLField: use URL API to correctly append draft param when URL has existing query string
- common/index.ts: re-export PublishedAt and URLField from common entry point
- Changeset: reword description to match actual PR scope

https://claude.ai/code/session_019KQTSWuJGhcoeP1WmXkaLZ

Co-authored-by: Claude <noreply@anthropic.com>
@claude

This comment has been minimized.

@ainsleyclark ainsleyclark merged commit 4bc9eec into main Feb 17, 2026
5 of 6 checks passed
@ainsleyclark ainsleyclark deleted the claude/add-payload-helper-fields-dfM5C branch February 17, 2026 14:03
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