Skip to content

Conversation

@gocanto
Copy link
Collaborator

@gocanto gocanto commented Oct 2, 2025

Go Live

  • add the new env ENV_SPA_IMAGES_DIR var.

Summary

  • Download and resize post cover images into the SEO storage cache before moving them under the SPA output directory
  • Adjust post SEO metadata to use /post/{slug} canonicals and mark the OG type as article.

Summary by CodeRabbit

  • New Features

    • Automatic generation of optimised Open Graph images for posts (1200×630) with correct MIME type for richer social sharing previews.
    • Improved SEO metadata for posts: Open Graph type now “article” and canonical post URLs use dedicated “/post” paths.
  • Tests

    • Added tests covering post image preparation and validation.
  • Chores

    • Updated dependencies to include a new image processing library.

Summary by CodeRabbit

  • New Features

    • SEO now prepares Open Graph images from post covers (local or remote), resizing and serving with correct MIME types.
    • Open Graph type for posts set to “article”; image MIME included in metadata.
    • Added dedicated post detail URL and updated canonical URL generation for posts.
    • Support for configuring a SPA images directory via environment settings.
  • Bug Fixes

    • Export process now removes stale files before writing new output.
  • Tests

    • Added comprehensive tests for image fetching, resizing, saving, and SEO image preparation.
  • Chores

    • Added an indirect image-related dependency.

@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Introduces SEO post image preparation and MIME handling, updates OG type options, adds a post detail URL, revises post canonical pathing, and removes stale export files before writing. Wires a new SpaImagesDir env variable through env/kernel/tests. Adds a new pkg/images utility with fetch/resize/save/move helpers and comprehensive tests. Updates tests accordingly.

Changes

Cohort / File(s) Summary
SEO generator and data updates
metal/cli/seo/generator.go, metal/cli/seo/data.go, metal/cli/seo/defaults.go
Adds optional post image preparation with MIME propagation; sets OG type "article"; includes ImageType in OG data; adjusts canonical post URL to use WebPostDetailUrl; removes stale export file before write; allows TagOgData.Type "website" or "article"; adds WebPostDetailUrl = "/post".
SEO images module
metal/cli/seo/images.go, metal/cli/seo/images_test.go
New image preparation flow for post covers: fetch (local/remote), resize to 1200x630, save under SPA images dir, compute site URL, derive MIME; tests for missing URL and site URL building.
Images utilities package
pkg/images/image.go, pkg/images/image_test.go
New public image utilities: Fetch, Resize, DetermineExtension, BuildFileName, Save (PNG/JPEG), Move, MIMEFromExtension, DefaultJPEGQuality; extensive tests covering I/O, formats, resizing, MIME/extension resolution, save/move behavior.
SEO tests (generator/client)
metal/cli/seo/generator_test.go, metal/cli/seo/client_test.go
Adds tests for local/remote post image preparation, MIME assertion, file creation, and export behavior; integrates SpaImagesDir in client test setup.
Env and kernel wiring
metal/env/seo.go, metal/kernel/factory.go, metal/kernel/kernel_test.go, metal/cli/seo/testhelpers_test.go
Adds required SpaImagesDir to SeoEnvironment; populates from ENV_SPA_IMAGES_DIR; updates tests and test helpers to provide SpaImagesDir.
Module dependency
go.mod
Adds indirect dependency golang.org/x/image v0.31.0.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller as Build Trigger
  participant Gen as SEO Generator
  participant Img as images pkg
  participant FS as Filesystem
  participant HTTP as Remote Server
  participant Site as Site URL Builder

  Caller->>Gen: BuildForPost(post)
  note over Gen: Initialize imageType = image/png
  Gen->>Gen: preparePostImage(post)
  alt Cover URL missing
    Gen-->>Gen: return error
    note right of Gen: Continue without image
  else Cover URL present
    Gen->>Img: Fetch(coverURL)
    alt http/https
      Img->>HTTP: GET coverURL
      HTTP-->>Img: 200 OK + image bytes
    else file/local
      Img->>FS: Open file
      FS-->>Img: Image bytes
    end
    Img-->>Gen: image, format
    Gen->>Img: Resize(1200x630)
    Gen->>FS: Ensure SPA images dir
    Gen->>Img: DetermineExtension / BuildFileName
    Gen->>Img: Save(path, img, ext)
    Gen->>Gen: siteURLFor(relPath)
    Gen-->>Gen: prepared{URL, MIME}
  end
  Gen->>Gen: Build OG data (Type=article, ImageType)
  Gen->>FS: os.MkdirAll(outdir)
  Gen->>FS: os.Remove(out) (ignore if not exists)
  Gen->>FS: Write file
  FS-->>Gen: OK
  Gen-->>Caller: Result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

codex

Poem

A bunny buffs a post’s bright sheen,
Crops and scales to perfect scene.
New paths hop in, old files out—
URLs tidy, without a doubt.
With MIME in paw and ears held high,
It ships the image—swift as sky. 🥕📸

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely states the implementation of local SEO image processing for posts, directly reflecting the core feature of the changes introduced without unnecessary detail.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e074060 and 8ea6f19.

📒 Files selected for processing (11)
  • metal/cli/seo/client_test.go (2 hunks)
  • metal/cli/seo/generator.go (4 hunks)
  • metal/cli/seo/generator_test.go (3 hunks)
  • metal/cli/seo/images.go (1 hunks)
  • metal/cli/seo/images_test.go (1 hunks)
  • metal/cli/seo/testhelpers_test.go (1 hunks)
  • metal/env/seo.go (1 hunks)
  • metal/kernel/factory.go (1 hunks)
  • metal/kernel/kernel_test.go (2 hunks)
  • pkg/images/image.go (1 hunks)
  • pkg/images/image_test.go (1 hunks)

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.

@gocanto gocanto marked this pull request as draft October 2, 2025 08:00
@gemini-code-assist
Copy link

Summary of Changes

Hello @gocanto, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the SEO capabilities for blog posts by introducing a robust image processing system. It ensures that post cover images are appropriately sized and optimized for web display, and correctly configured with SEO-friendly metadata. This change streamlines the image handling process and enhances the discoverability and presentation of post content on search engines and social media platforms.

Highlights

  • Image Processing Pipeline: Implemented a new workflow to download, resize, and optimize post cover images, storing them in a dedicated SEO cache before moving them to the final SPA output directory.
  • SEO Metadata Enhancement: Adjusted post SEO metadata to utilize /post/{slug} canonical URLs and explicitly mark the Open Graph (OG) type as 'article' for better search engine indexing.
  • New Image Utility File: Introduced a new file, metal/cli/seo/images.go, to encapsulate all image fetching, resizing, and saving logic.
  • Comprehensive Unit Tests: Added new unit tests to cover the functionality of the image processing workflow, ensuring its reliability and correctness.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a valuable SEO enhancement by processing post cover images locally. The implementation is well-structured, with image handling logic cleanly separated into a new file and accompanied by a unit test. My review focuses on improving performance by reusing the HTTP client, enhancing error wrapping for better diagnostics, increasing the robustness of file operations, and expanding test coverage to include remote image fetching. Overall, these are solid changes that will improve the site's SEO capabilities.

@gocanto gocanto added testing and removed codex labels Oct 2, 2025
@gocanto gocanto added testing and removed testing labels Oct 2, 2025
@gocanto gocanto changed the title Add local SEO image processing for posts feat: Add local SEO image processing for posts Oct 10, 2025
@gocanto gocanto marked this pull request as ready for review October 10, 2025 03:29
@gocanto gocanto merged commit 04c1afa into main Oct 10, 2025
2 of 3 checks passed
@gocanto gocanto deleted the codex/implement-image-handling-for-seo-posts branch October 10, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants