[#291] Added SEO modules and social sharing cards. - #293
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (16)
Comment |
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #293 +/- ##
===========================================
+ Coverage 81.49% 83.85% +2.36%
===========================================
Files 23 24 +1
Lines 416 477 +61
===========================================
+ Hits 339 400 +61
Misses 77 77 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
|
Code coverage (threshold: 80%) Per-class coverage |
Closes #291
Closes #292
Checklist before requesting a review
[#123] Verb in past tense.#123added to descriptionChangedsectionChanged
Before this branch the site published a
description, atitleand acanonicallink, and nothing else. There were noog:*tags, notwitter:*tags and no structured data anywhere, so a link pasted into X, LinkedIn or Slack rendered as a bare URL.metatag_open_graphandmetatag_twitter_cardswere already installed but had no tags configured, which is why #292 reports the cards pulling nothing.Added
schema_metatag(withschema_organization,schema_web_site,schema_article) andredirect_404. The first publishes JSON-LD through the metatag defaults that already exist, so it adds no second configuration surface. The second records 404 paths at/admin/config/search/redirect/404so real lost traffic can be turned into redirects. Deliberately not added:yoast_seo,seo_checklist,linkcheckerandmetatag_hreflang- reasoning indocs/seo.md.Configured the Open Graph, Twitter Card and structured data defaults.
globalcarries the site-level values, the card type and handle, and theOrganizationandWebSitemarkup;node__blogaddsog:type: article, the article timestamps and theArticlemarkup. Every page now emits a complete card, and blog posts additionally emit anArticle+Organization+WebSiteJSON-LD graph.Resolved the card image in
MetatagsAlterHookrather than in configuration. A metatag default whose token resolves to nothing is dropped rather than falling back to its parent, and most pages have no thumbnail - the homepage,/about-usand most projects included - so a token-only setup would leave exactly the most-shared URLs with no image. The hook uses the node'sfield_c_n_thumbnailthrough a newsocial_shareimage style (1200x630, focal point aware) and falls back to a site-wide card otherwise. It passes over a thumbnail that no image toolkit can derive (the image field accepts SVG) or whose file is absent from the environment, and it leaves an image an editor set by hand entirely alone. The URL it produces is absolute, because only the Open Graph and Twitter tags declareabsolute_urland get a host prepended for them - a relative fallback reached theArticlestructured data unchanged, which schema.org rejects.Derived the social title and description from
titleanddescriptionin the same hook. This keeps one source of truth for the wording, and it is the only way those tags reach the front page at all:metatag_get_default_tags()treats the front page, 403 and 404 as special pages and stops after the global and special defaults, never reading the entity or bundle defaults. The homepage had noog:descriptionbefore this.Implemented the alter as a hook class,
Drupal\do_base\Hook\MetatagsAlterHook, matching thesrc/Hook/*Hook.phppattern the module already uses forFormAlterHookandLibraryInfoAlterHook. It takesEntityTypeManagerInterface,ConfigFactoryInterface,ModuleExtensionListandRequestStackthrough the constructor, so nothing in the resolution path reaches for a static\Drupal::call.do_base.moduleis untouched by this branch.Added two brand assets to
do_base.social-share.jpg(1200x630) is the fallback card: the wordmark over the dark navy page background, under the site's positioning line with its accent phrase in coral. It is rendered from HTML carrying the same colour tokens, Lexend weights and letter spacing as the branding styleguide, so it matches the brand rather than approximating it.logo.png(600x142) is theOrganizationlogo for the structured data, which requires a raster image where the brand logo exists only as SVG.Added tests at three levels.
MetatagsAlterHookTestdrives the hook in-process and covers every branch of the resolver - thumbnail, no thumbnail, no thumbnail field, media holding no image, SVG source, missing file, each editor-override permutation, the text mirroring, and the structured data image - reaching 100% of the class.SocialCardTestproves the same behaviour end to end through rendered pages, and the Behat feature asserts the rendered tags and JSON-LD against the real configuration and theme. The in-process test matters for more than coverage: a functional test exercises this code inside a separate HTTP request, where nothing can observe which branch ran.Documented the stack in
docs/seo.md, including why publication dates come fromcreated(it is the field the blog listing already sorts and presents by, and structured data is expected to agree with what a visitor sees).Screenshots
The fallback card, served for any page without a thumbnail:
Before / After