Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to nuxt-og-image #1400

Merged
merged 29 commits into from
May 13, 2024
Merged

feat: migrate to nuxt-og-image #1400

merged 29 commits into from
May 13, 2024

Conversation

danielroe
Copy link
Owner

No description provided.

Copy link

vercel bot commented Apr 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
roe-dev ✅ Ready (Inspect) Visit Preview May 13, 2024 5:38pm
roe.dev ✅ Ready (Inspect) Visit Preview May 13, 2024 5:38pm

Copy link

coderabbitai bot commented Apr 9, 2024

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (14)
  • budget.json is excluded by !**/*.json
  • package.json is excluded by !**/*.json
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-building-your-own-vue-rich-text-component-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-contributing-to-nuxt-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-creating-your-own-sitemap-module-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-good-ux-and-giving-birth-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-introduction-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-open-invitation-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-blog-serverless-functions-nuxt-zeit-now-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-talks-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-uses-1-linux.png is excluded by !**/*.png, !**/*.png
  • test/e2e/ssr.spec.ts-snapshots/pages-image-for-work-1-linux.png is excluded by !**/*.png, !**/*.png

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Enhancements have been made to boost SEO capabilities by refining prerender routes, configuring Open Graph images, updating testing for efficiency, and ensuring compliance with web standards.

Changes

File Path Change Summary
nuxt.config.ts Removed /og/og.jpg from prerender routes, added site object with url, configured ogImage, included nuxt-og-image module.
src/components/OgImage/DefaultImage.vue Added DefaultImage.vue with props for title, date, and tags.
src/modules/og-tweaks.ts Introduced modifications for tweaking OG image handling and managing plugins.
test/unit/bundle.spec.ts Adjusted file size expectations, added new packages to dependency analysis.

🐰✨
In the realm of bits and bytes,
Our changes bring new delights.
Images shine, tags align,
Testing ensures a design so fine.
Code dances, tests endure,
In this digital adventure pure.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

src/components/OgImage/DefaultImage.vue Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 87e3831 and 0658ff0.
Files ignored due to path filters (2)
  • package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !pnpm-lock.yaml, !**/*.yaml
Files selected for processing (2)
  • nuxt.config.ts (2 hunks)
  • test/unit/bundle.spec.ts (6 hunks)
Additional comments not posted (7)
nuxt.config.ts (3)

95-95: Ensure that the removal of /og/og.jpg from prerender routes aligns with the new strategy for handling OG images.

Verification successful

The removal of /og/og.jpg from prerender routes does not appear to affect its accessibility or functionality in the contexts where it is used, such as in social media meta tags and RSS feeds. The image is still accessible and returns a successful HTTP status, indicating that it is properly hosted and can be retrieved without issues.

  • src/app.vue: The image is used for social media sharing and is accessible.
  • src/server/routes/rss.xml.get.ts: The image is used in the RSS feed and remains accessible.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the removal of `/og/og.jpg` from prerender routes does not affect other functionalities.

# Test: Search for any references to `/og/og.jpg` in the project.
rg --type ts --type js '/og/og.jpg'

Length of output: 166



Script:

#!/bin/bash
# Description: Check if the image at 'https://roe.dev/og/og.jpg' is still accessible or if it results in a 404 error.

# Test: Use curl to check the HTTP status code of the image URL.
curl -o /dev/null -s -w "%{http_code}\n" https://roe.dev/og/og.jpg

Length of output: 72


199-201: The addition of the site object with a url property is a good centralization of site-related configurations.


203-218: The new ogImage configuration enhances the handling of OG images. Verify that the compatibility settings (css-inline, chromium, etc.) are correctly implemented and do not break existing functionalities.

test/unit/bundle.spec.ts (4)

82-82: Updated server bundle size expectation to "671k". Ensure this reflects the actual changes in the server's code or dependencies.


87-87: Updated node modules bundle size expectation to "7342k". Confirm that this size is accurate and accounts for all new dependencies.


Line range hint 100-232: Addition of numerous new dependencies such as @babel/parser, @vue/compiler-core, etc. Ensure these are necessary for the project and do not introduce redundancy or conflicts.


214-214: Addition of source-map-js. Verify its integration and usage within the project, ensuring it does not affect performance negatively.

Verification successful

Based on the results from the executed scripts, it appears that source-map-js is only mentioned in the test/unit/bundle.spec.ts file and is not imported or required anywhere else in the codebase. This suggests that the package might only be referenced in the context of testing and does not integrate into the main application logic. Therefore, it is unlikely to impact the performance of the project negatively.

Final Assessment:

  • The addition of source-map-js is confined to the test specifications and does not influence the main application's performance.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration and usage of `source-map-js`.

# Test: Search for usage of `source-map-js` in the project.
rg --type ts --type js 'source-map-js'

Length of output: 88



Script:

#!/bin/bash
# Description: Search for imports or requires of `source-map-js` in the entire codebase.

# Search for explicit import or require statements of `source-map-js`.
rg --type ts --type js 'import .*source-map-js' 'require(.source-map-js.)'

Length of output: 141



Script:

#!/bin/bash
# Description: Correctly search for imports or requires of `source-map-js` in the entire codebase.

# Correctly search for explicit import or require statements of `source-map-js`.
rg --type ts --type js '(import .*source-map-js)|(require\(.*source-map-js.*\))'

Length of output: 82

nuxt.config.ts Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (1)
src/modules/og-tweaks.ts (1)

24-41: Consider implementing or removing commented-out code.

The commented-out code for handling OG image endpoints suggests future enhancements. If these are not planned for immediate implementation, consider removing the comments to keep the codebase clean.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0658ff0 and 469b0e7.
Files selected for processing (3)
  • src/components/OgImage/DefaultImage.vue (1 hunks)
  • src/modules/og-tweaks.ts (1 hunks)
  • test/unit/bundle.spec.ts (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • test/unit/bundle.spec.ts
Additional Context Used
GitHub Check Runs (1)
test failure (5)

src/modules/og-tweaks.ts: [failure] 2-2:
'InputPluginOption' is defined but never used. Allowed unused vars must match /^_/u

Additional comments not posted (3)
src/components/OgImage/DefaultImage.vue (2)

3-15: Ensure prop types and defaults are correctly defined.

Props title, date, and tags are well-defined with appropriate types and default values. This ensures robustness in prop handling.


19-52: Review the template structure and conditional rendering.

The template uses conditional rendering effectively for date and tags, ensuring elements are only displayed when relevant data is available. This enhances the UI's adaptability and cleanliness.

src/modules/og-tweaks.ts (1)

4-42: Ensure the module setup is robust and maintainable.

The module setup uses hooks effectively to customize the behavior of Nuxt components and plugins. This modular approach enhances flexibility and maintainability.

src/modules/og-tweaks.ts Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 469b0e7 and 7ccd444.
Files selected for processing (1)
  • test/unit/bundle.spec.ts (8 hunks)
Files skipped from review as they are similar to previous changes (1)
  • test/unit/bundle.spec.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 7ccd444 and 5710dbe.
Files selected for processing (1)
  • test/e2e/ssr.spec.ts (1 hunks)
Additional comments not posted (1)
test/e2e/ssr.spec.ts (1)

39-39: Ensure the ogURL is not null before using it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5710dbe and f646f06.
Files selected for processing (3)
  • src/modules/og-tweaks.ts (1 hunks)
  • test/e2e/ssr.spec.ts (2 hunks)
  • test/unit/bundle.spec.ts (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • test/e2e/ssr.spec.ts
  • test/unit/bundle.spec.ts
Additional comments not posted (4)
src/modules/og-tweaks.ts (4)

4-7: Module definition and metadata setup look good.


11-16: Logic to manipulate the components directory list is implemented correctly.


19-22: Filtering of Nitro plugins to adjust runtime behavior is implemented effectively.


36-40: Proper cleanup of the custom Rollup plugin from the configuration ensures no residual effects.

Comment on lines +24 to +34
// Purge OG image endpoints for runtime (as they are fully prerendered)
nuxt.hook('nitro:config', config => {
(config.rollupConfig!.plugins as InputPluginOption[]).push({
name: 'purge-the-handler',
transform (code, id) {
if (id.includes('runtime/nitro/routes/image') || (code.includes('defineEventHandler') && id.includes('nuxt-site-config'))) {
return 'import { defineEventHandler } from "h3"; export default defineEventHandler(() => {})'
}
},
})
})
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The paths and conditions specified in the custom Rollup plugin do not match any existing files in the repository, except for the reference within the plugin's own configuration. This suggests that the plugin might not be functioning as intended if it's supposed to target specific existing files.

  • Please check if the paths runtime/nitro/routes/image and nuxt-site-config are correct and if the files are supposed to exist in the repository. If they are, ensure they are correctly named and located.
Analysis chain

Implementation of custom Rollup plugin to purge specific OG image handlers is innovative.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the paths and conditions in the custom Rollup plugin target the correct files.

# Test: Search for the files and handlers mentioned in the conditions. Expect: Only the intended files are affected.
rg --type typescript $'runtime/nitro/routes/image|nuxt-site-config'

Length of output: 103



Script:

#!/bin/bash
# Description: Re-verify that the paths and conditions in the custom Rollup plugin target the correct files using the correct file type.

# Test: Search for the files and handlers mentioned in the conditions without specifying an unrecognized file type.
rg 'runtime/nitro/routes/image|nuxt-site-config' --glob '*.ts'

Length of output: 224

@danielroe danielroe merged commit ad3e0b3 into main May 13, 2024
8 checks passed
@danielroe danielroe deleted the feat/og-image branch May 13, 2024 17:40
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.

1 participant