Skip to content

Fix hero section theme persistence issue#70

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-69
Draft

Fix hero section theme persistence issue#70
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-69

Conversation

Copy link

Copilot AI commented May 28, 2025

Issue

Users who selected the dark theme when building their site reported that the hero section appeared all white after being hosted for a week.

Root Cause

When exporting a site, if the user selected a theme color in the UI but the JSON data still had "primaryColor": null, the client-side code wasn't properly defaulting to "indigo" after the site had been hosted for some time.

Changes

  1. Modified the encode function in packages/mytemplate/src/types/Data.res to always write the actual color value instead of null:

    • Changed from ("primaryColor", nullable(string, t.primaryColorString)) to ("primaryColor", string(primaryColor(t)))
    • This ensures the exported JSON always contains either the user's selected color or "indigo" as the default
    • Fixes the root cause by preventing null values in the exported data
  2. Updated the CDN references from version 0.7 to @latest in src/utils/Config.res:

    -    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mytemplate.xyz@0.7/build/index.css"/>
    -    <script src="https://cdn.jsdelivr.net/npm/mytemplate.xyz@0.7/build/index.js"></script>
    +    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/mytemplate.xyz@latest/build/index.css"/>
    +    <script src="https://cdn.jsdelivr.net/npm/mytemplate.xyz@latest/build/index.js"></script>

These changes ensure theme persistence by making the color selection explicit in the exported HTML data rather than relying on client-side defaults.

Fixes #69.


💡 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.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 28, 2025

Deploying mytemplate-xyz with  Cloudflare Pages  Cloudflare Pages

Latest commit: 853fe4e
Status:🚫  Build failed.

View logs

Co-authored-by: bodhish <14979190+bodhish@users.noreply.github.com>
Copilot AI changed the title [WIP] The hero part appears to be all white after being hosted for a week Fix hero section theme persistence issue May 28, 2025
Copilot AI requested a review from bodhish May 28, 2025 17:56
@bodhish
Copy link
Owner

bodhish commented Oct 27, 2025

@copilot do you want to try building it again from scratch

Co-authored-by: bodhish <14979190+bodhish@users.noreply.github.com>
Copy link
Author

Copilot AI commented Oct 27, 2025

@copilot do you want to try building it again from scratch

I've rebuilt the fix from scratch with a cleaner approach (commit 853fe4e).

Key changes:

  1. Simplified solution: Instead of parsing and manipulating JSON at export time, I modified the encode function in Data.res to always write the actual color value (defaulting to "indigo" when not set) rather than writing null
  2. Updated CDN version: Changed from @0.7 to @latest to ensure sites use the most recent client-side code
  3. Removed unnecessary complexity: Eliminated the ensurePrimaryColor function and package-lock.json that were added in the previous attempt

This approach is cleaner because it fixes the root cause - ensuring the exported JSON never contains "primaryColor": null - rather than trying to patch it during export.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.jsdelivr.net
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

The hero part appears to be all white after being hosted for a week

2 participants