Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 24, 2025

This PR implements a comprehensive Webflow strategy for the crosspost project, enabling users to post content to Webflow CMS collections via the Webflow API v2.

Features

Core Functionality

  • CMS Integration: Posts content to Webflow CMS collections using the official API v2
  • OAuth Authentication: Supports OAuth access tokens with proper scope validation
  • Image Support: Uploads images as Webflow assets and references them in collection items
  • Error Handling: Comprehensive error handling with descriptive messages for API failures
  • AbortSignal Support: Proper cancellation support following crosspost patterns

API Integration Details

  • Uses Webflow CMS API v2 endpoints (/collections/{id}/items and /sites/{id}/assets)
  • Implements proper authentication headers and request formatting
  • Handles rate limiting scenarios and provides guidance for production use
  • Supports custom API base URLs for testing and future API versions

Strategy Implementation

import { WebflowStrategy } from "@humanwhocodes/crosspost";

const strategy = new WebflowStrategy({
    accessToken: "your-oauth-token",
    siteId: "your-site-id", 
    collectionId: "your-collection-id"
});

// Post with images
await strategy.post("Hello Webflow!", {
    images: [{ data: imageData, alt: "Description" }]
});

Documentation

The implementation includes comprehensive documentation covering:

  • API References: Links to official Webflow documentation for collection items, OAuth, and app registration
  • Authentication Requirements: OAuth scopes, application registration process
  • Rate Limits: Best practices for production usage and retry strategies
  • Configuration: Required parameters and collection structure requirements
  • Limitations: Current constraints and future enhancement opportunities

Testing

Added 24 comprehensive test cases covering:

  • Constructor validation and error handling
  • Message posting with various scenarios
  • Image upload functionality and error cases
  • API error responses and network failures
  • AbortSignal cancellation support
  • Request body validation and slug generation
  • Response URL generation

All existing tests continue to pass (314 total tests passing).

Implementation Notes

  • Follows established crosspost strategy patterns for consistency
  • Uses proper TypeScript/JSDoc type definitions
  • Implements automatic slug generation from message content
  • Handles long messages by truncating names while preserving full content
  • Maps images to common Webflow field patterns (main-image and images arrays)

The strategy is production-ready and integrates seamlessly with the existing crosspost ecosystem.

Fixes #117.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Strategy for Posting to Webflow Add Webflow strategy for posting to CMS collections Jul 24, 2025
Copilot AI requested a review from nzakas July 24, 2025 16:38
Copilot finished work on behalf of nzakas July 24, 2025 16:38
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.

Strategy for Posting to Webflow

2 participants