Skip to content

feat: Convert config.js to config.yaml (Issue #55)#56

Merged
EmersonFras merged 7 commits intomainfrom
feat/issue-55/convert-config-to-yaml
Mar 19, 2026
Merged

feat: Convert config.js to config.yaml (Issue #55)#56
EmersonFras merged 7 commits intomainfrom
feat/issue-55/convert-config-to-yaml

Conversation

@EmersonFras
Copy link
Contributor

Summary

Replaces public/config.js with public/config.yaml as the sole configuration entry point for the catalog template. Configuration is fetched asynchronously at runtime via fetch('config.yaml') and parsed with js-yaml.

Changes Made

  • public/config.yaml - New YAML config file replacing config.js. Contains all the same settings (org name, branding, colors, API URL, additional repos, font) with inline comments.
  • public/config.js - Deleted.
  • main.js - Removed the synchronous CONFIG global check and top-level const destructuring. Added import jsYaml from 'js-yaml' and a module-scope configPromise that starts fetching config.yaml immediately when the module loads (before DOMContentLoaded), so the network request is in-flight while the DOM parses. Inside DOMContentLoaded, config is awaited before anything else runs; CSS custom properties, document title, font link, and favicon are all applied from the resolved config. A visible error banner and safe defaults are used as fallback if the fetch fails.
  • style.css - Added --color-accent-dark and --font-family to the :root block alongside the existing color defaults. These two properties had no :root fallback before, meaning they would render as unset during the async config fetch. The hardcoded values match the YAML defaults and are overridden by JS once config loads.
  • index.html - Removed <script src="config.js"> and three inline <script> blocks that synchronously applied config (CSS vars, font update, favicon). Kept the dark mode toggle script (it does not depend on CONFIG) and the static <link id="font-link"> tag with the Inter default.
  • scripts/export-tags.js - Replaced the regex + new Function() approach for extracting CONFIG from config.js with a direct jsYaml.load(fs.readFileSync('public/config.yaml')) call.

Closes #55

Copilot AI review requested due to automatic review settings March 18, 2026 18:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the catalog’s configuration from a JavaScript global (public/config.js) to a YAML file (public/config.yaml) that’s fetched at runtime and parsed with js-yaml, aiming to keep configuration comment-friendly while avoiding executing arbitrary JS.

Changes:

  • Add public/config.yaml and remove public/config.js as the configuration source.
  • Update main.js and index.html to asynchronously fetch/parse config and apply branding/CSS/font/favicon at runtime.
  • Update scripts/export-tags.js to read YAML directly, and add js-yaml as a dependency.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
public/config.yaml New YAML configuration file replacing JS config.
public/config.js Removed previous JS-based CONFIG global.
main.js Fetches/parses YAML config at runtime; applies UI settings after load with fallback behavior.
index.html Removes config.js + inline config scripts; relies on main.js for config application.
style.css Adds :root fallbacks for --color-accent-dark and --font-family during async config load.
scripts/export-tags.js Loads config via js-yaml instead of regex + new Function().
package.json Adds js-yaml dependency.
package-lock.json Lockfile updates reflecting js-yaml addition (and regenerated metadata).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@EmersonFras EmersonFras requested a review from egrace479 March 18, 2026 18:58
@egrace479 egrace479 added the structure Refactoring or architecture, general code organization label Mar 18, 2026
@egrace479
Copy link
Member

Looks good, though the README should also be updated to reflect the change.

Copy link
Member

@egrace479 egrace479 left a comment

Choose a reason for hiding this comment

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

LGTM!

@EmersonFras EmersonFras merged commit 14dd206 into main Mar 19, 2026
@EmersonFras EmersonFras deleted the feat/issue-55/convert-config-to-yaml branch March 19, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

structure Refactoring or architecture, general code organization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert config JS file to YAML

3 participants