Skip to content

Add JSON-LD structured data design spec#14

Merged
dereuromark merged 15 commits into
masterfrom
json-ld-spec
Mar 19, 2026
Merged

Add JSON-LD structured data design spec#14
dereuromark merged 15 commits into
masterfrom
json-ld-spec

Conversation

@dereuromark
Copy link
Copy Markdown
Owner

@dereuromark dereuromark commented Mar 19, 2026

Summary

Add JSON-LD structured data support to MetaHelper for Schema.org markup generation.

Features

  • BreadcrumbList schema - setBreadcrumbs() / getBreadcrumbs()
  • Article schema - setArticle() / getArticle()
  • Organization schema - setOrganization() / getOrganization() with global config merge support

API

// Breadcrumbs
$this->Meta->setBreadcrumbs([
    ['name' => 'Home', 'url' => '/'],
    ['name' => 'Blog', 'url' => '/blog'],
    ['name' => 'My Post'],
]);

// Article
$this->Meta->setArticle([
    'headline' => 'My Article',
    'author' => 'John Doe',
    'datePublished' => '2026-03-19',
]);

// Organization (supports global config merge)
$this->Meta->setOrganization([
    'name' => 'Acme Inc',
    'url' => 'https://acme.com',
]);

// Output included in out() automatically
echo $this->Meta->out();

Changes

  • Added $_jsonLd storage property and renderJsonLd() helper
  • Implemented setBreadcrumbs/getBreadcrumbs with validation
  • Implemented setArticle/getArticle with validation
  • Implemented setOrganization/getOrganization with global config merge
  • Integrated JSON-LD output into out() method
  • Added 17 new tests (30 total tests, 90 assertions)
  • Updated documentation

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 19, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.56%. Comparing base (a460509) to head (8ff8cb8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/View/Helper/MetaHelper.php 97.77% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##             master      #14      +/-   ##
============================================
+ Coverage     92.22%   93.56%   +1.33%     
- Complexity      118      153      +35     
============================================
  Files             1        1              
  Lines           283      373      +90     
============================================
+ Hits            261      349      +88     
- Misses           22       24       +2     

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

- Add setBreadcrumbs() method to set breadcrumb JSON-LD structured data
- Add getBreadcrumbs() method to retrieve rendered JSON-LD output
- Update renderJsonLd() to output compact JSON without pretty-print
- Fix test setUp with fallbacks() for generic route URL reversal
- Add fullBaseUrl configuration for full URL generation in tests
- Add HTTP_HOST to test request for proper host-aware URL building
- All 5 breadcrumb tests pass, PHPStan analysis clean
The test was comparing relative URLs but assertions were using fullBase.
Updated assertions to not use fullBase to match getCanonical() behavior
which doesn't use the full parameter by default.
@dereuromark dereuromark merged commit a068b7f into master Mar 19, 2026
8 checks passed
@dereuromark dereuromark deleted the json-ld-spec branch March 19, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants