Skip to content

Add site data files for templates#67

Open
samdark wants to merge 1 commit into
masterfrom
add-site-data-files
Open

Add site data files for templates#67
samdark wants to merge 1 commit into
masterfrom
add-site-data-files

Conversation

@samdark

@samdark samdark commented Jun 13, 2026

Copy link
Copy Markdown
Member

Summary

  • parse content/data/*.yaml and *.yml into SiteConfig data
  • expose the parsed map as in entry and generated page templates
  • keep data files out of collection discovery and track them for incremental rebuilds
  • document content/data and mark the roadmap item done

Tests

  • make test -- --filter SiteConfigParserTest
  • make test -- --filter ContentParserTest
  • make test -- --filter EntryRendererTest
  • make psalm
  • make test

Copilot AI review requested due to automatic review settings June 13, 2026 09:04
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@samdark, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 38 minutes and 19 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c954ffe0-5f8d-4e62-8f3c-634ebd5d9780

📥 Commits

Reviewing files that changed from the base of the PR and between 315ad8d and 16c16fc.

📒 Files selected for processing (17)
  • docs/content.md
  • docs/templates.md
  • roadmap.md
  • src/Build/AuthorPageWriter.php
  • src/Build/CollectionListingWriter.php
  • src/Build/DateArchiveWriter.php
  • src/Build/EntryRenderer.php
  • src/Build/NotFoundPageWriter.php
  • src/Build/TaxonomyPageWriter.php
  • src/Console/BuildCommand.php
  • src/Content/Model/SiteConfig.php
  • src/Content/Parser/ContentParser.php
  • src/Content/Parser/SiteConfigParser.php
  • src/Content/Parser/SiteDataParser.php
  • tests/Unit/Build/EntryRendererTest.php
  • tests/Unit/Content/Parser/ContentParserTest.php
  • tests/Unit/Content/Parser/SiteConfigParserTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-site-data-files

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds support for “site data” YAML files under content/data/ by parsing them into SiteConfig::$data and exposing that map to entry + generated page templates, while ensuring content/data is excluded from collection/entry discovery and tracked for incremental rebuilds.

Changes:

  • Parse content/data/*.yaml|*.yml into SiteConfig::$data (via new SiteDataParser).
  • Expose $data to templates rendered by EntryRenderer and various page writers (taxonomy, archives, authors, listings, 404).
  • Exclude data/ from content parsing and include its YAML files in the build’s tracked “config files”; update docs/roadmap and add tests.

Reviewed changes

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

Show a summary per file
File Description
tests/Unit/Content/Parser/SiteConfigParserTest.php Adds tests for parsing site data files + friendly error on invalid YAML.
tests/Unit/Content/Parser/ContentParserTest.php Verifies content/data is not treated as a collection/entries source.
tests/Unit/Build/EntryRendererTest.php Verifies templates can read $data provided by the renderer.
src/Content/Parser/SiteDataParser.php New parser to load YAML site data files from content/data/.
src/Content/Parser/SiteConfigParser.php Loads parsed site data into SiteConfig when parsing config.yaml.
src/Content/Parser/ContentParser.php Excludes data/ from collection discovery and entry parsing.
src/Content/Model/SiteConfig.php Adds public array $data = [] to hold site data.
src/Console/BuildCommand.php Tracks `content/data/*.yaml
src/Build/TaxonomyPageWriter.php Passes $data into taxonomy templates.
src/Build/NotFoundPageWriter.php Passes $data into the 404 template.
src/Build/EntryRenderer.php Passes $data into entry templates.
src/Build/DateArchiveWriter.php Passes $data into archive templates.
src/Build/CollectionListingWriter.php Passes $data into collection listing templates.
src/Build/AuthorPageWriter.php Passes $data into author templates.
roadmap.md Marks the site-data-to-templates roadmap item as done.
docs/templates.md Documents $data as an available template variable.
docs/content.md Documents content/data/ structure and usage.

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

Comment on lines +51 to +58
$parsed = @yaml_parse($content);
if ($parsed === false) {
throw new InvalidContentConfigException(
"Invalid YAML in site data file: $path",
$path,
'Fix the YAML syntax in content/data/*.yaml, then run the build again.',
);
}
);
}

$key = basename($item->getFilename(), '.' . $extension);
Comment thread docs/templates.md
| `$uiLanguages` | `list<string>` | Available UI languages exposed by the site |
| `$uiCatalogs` | `array<string, array<string, string>>` | Theme UI catalogs for client-side switching |
| `$ui` | `YiiPress\I18n\UiText` | Injected localized UI-text helper for bundled theme labels |
| `$data` | `array<string, mixed>` | Site data loaded from `content/data/*.yaml` |
Comment thread roadmap.md
- [x] Theme system — installable/distributable themes
- [x] Template partials/includes support
- [x] Template helper functions documentation
- [x] Site data files exposed to templates (`content/data/*.yaml` as `$data`)
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