Skip to content

Conversation

@gocanto
Copy link
Contributor

@gocanto gocanto commented Aug 5, 2025

Summary by CodeRabbit

  • New Features

    • Added a "Contact Sponsor" feature that opens a pre-filled email draft when clicking on a sponsor widget.
    • Introduced build visualization support, allowing users to generate and view build statistics when running a new build script.
  • Improvements

    • Enhanced syntax highlighting for code blocks with support for multiple programming languages and aliases.
    • Improved app performance by enabling lazy loading of all route components.
  • Other Changes

    • Removed the /subscribe page from the site.

@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

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

This update introduces dynamic syntax highlighting initialization, lazy-loads route components, and adds a mailto contact feature for sponsors. The build process now optionally supports bundle visualization. The .gitignore is updated to exclude stats.html, and package dependencies are adjusted for visualization and data generation tools.

Changes

Cohort / File(s) Change Summary
Build and Dependency Configuration
.gitignore, package.json, vite.config.ts
.gitignore now ignores stats.html. package.json adds the rollup-plugin-visualizer and a build:stats script, and reorders some devDependencies. vite.config.ts conditionally includes the visualizer plugin based on an environment variable.
Syntax Highlighting Initialization
src/public.ts, src/pages/PostPage.vue
src/public.ts introduces initializeHighlighter, dynamically importing and registering language modules for highlight.js. src/pages/PostPage.vue updates highlight logic to use this function and adjusts imports accordingly.
Router Lazy Loading and Route Removal
src/router.ts
All route components are now dynamically imported for lazy loading, and the /subscribe route is removed. Static imports are eliminated.
Sponsor Email Feature
src/partials/WidgetSponsorPartial.vue
Adds a click handler that opens a pre-filled email draft to contact a sponsor, constructing the subject and body from sponsor data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SponsorWidget
    participant EmailClient

    User->>SponsorWidget: Clicks sponsor widget
    SponsorWidget->>SponsorWidget: Construct mailto URL with sponsor info
    SponsorWidget->>EmailClient: Opens mailto link (pre-fills email)
Loading
sequenceDiagram
    participant User
    participant PostPage
    participant Highlighter
    participant DataFetcher

    User->>PostPage: Navigates to post
    PostPage->>Highlighter: initializeHighlighter()
    Highlighter->>Highlighter: Dynamically import/register languages
    Highlighter-->>PostPage: Initialization complete
    PostPage->>DataFetcher: Fetch post data
    PostPage->>Highlighter: highlight code blocks
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested labels

codex

Poem

A whisk of code, a hop of change,
Now sponsors send mail—how very strange!
Routes load on cue, the bundle’s in view,
Syntax shines bright with highlighting anew.
With every commit, this garden grows tall—
A rabbit’s delight, reviewing it all! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/dynamic-import

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
🪧 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

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

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 focuses on optimizing the application's build process and enhancing its loading performance. It achieves this by introducing a new tool for bundle analysis, implementing code splitting for various application routes, and refining a specific library import to reduce the overall bundle footprint.

Highlights

  • Build Analysis Integration: I've integrated rollup-plugin-visualizer into the Vite configuration (vite.config.ts), allowing for detailed analysis of the final build bundle. This tool is configured to run without automatically opening the visualization report.
  • Route-based Code Splitting: All Vue router components in src/router.ts have been updated to use dynamic import() statements. This enables lazy loading of routes, which will improve the application's initial load performance by only loading component code when it's needed.
  • Dependency Management and Optimization: The package.json and package-lock.json files have been updated to reflect the addition of rollup-plugin-visualizer and @faker-js/faker as development dependencies. Additionally, the import for highlight.js in src/pages/PostPage.vue has been refined to import only the core library, contributing to a smaller bundle size.
  • Route Removal: The /subscribe route has been removed from the application's routing configuration in src/router.ts.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 or fill out our survey to provide feedback.

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 some excellent build optimizations, primarily by lazy-loading route components, which will significantly improve initial load times. The attempt to optimize highlight.js imports is also a good idea. I've left a couple of comments:

  • A critical issue in PostPage.vue where the change to highlight.js imports breaks syntax highlighting.
  • A medium-severity suggestion for vite.config.ts to make the inclusion of the build visualizer conditional, improving build hygiene for production environments.

@gocanto gocanto added the testing label Aug 5, 2025
@gocanto gocanto changed the title optimise build Optimise production build Aug 5, 2025
@gocanto gocanto marked this pull request as ready for review August 5, 2025 06:41
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

🧹 Nitpick comments (3)
src/partials/WidgetSponsorPartial.vue (1)

31-40: Consider making the recipient email configurable.

The email functionality is well-implemented with proper URL encoding. However, the hardcoded recipient email (otnacog@gmail.com) reduces maintainability.

Consider making the email configurable:

+interface Sponsor {
+	title: string;
+	description: string;
+	email?: string;
+}

const sponsor: Sponsor = {
	title: 'Build The Site/App You Want!',
	description: 'Your website should be an asset, not an engineering challenge.',
+	email: 'otnacog@gmail.com',
};

const sendEmail = () => {
-	const recipient = 'otnacog@gmail.com';
+	const recipient = sponsor.email || 'otnacog@gmail.com';
vite.config.ts (1)

17-17: Parameterise open flag & normalise env-var parsing

open: true will try to launch a browser every time the stats build runs (CI/CD jobs, headless Docker, etc.).
Consider:

  1. Normalising the env-var so 1 / true / yes all enable the plugin.
  2. Making the open setting controlled by a second flag (default false) to avoid unwanted browser launches.
-import { visualizer } from 'rollup-plugin-visualizer';
+import { visualizer } from 'rollup-plugin-visualizer';

-plugins: [vue(), tailwindcss(), ...(process.env.VITE_VISUALIZER === 'true'
-  ? [visualizer({ open: true })]
-  : [])],
+
+const enableVisualizer =
+  ['true', '1', 'yes'].includes(String(process.env.VITE_VISUALIZER).toLowerCase());
+const openVisualizer =
+  ['true', '1', 'yes'].includes(String(process.env.VITE_VISUALIZER_OPEN).toLowerCase());
+
+plugins: [
+  vue(),
+  tailwindcss(),
+  ...(enableVisualizer ? [visualizer({ open: openVisualizer })] : []),
+],

This keeps the current behaviour but plays nicely with non-interactive environments.

package.json (1)

13-14: Use cross-env for cross-platform environment variables

"build:stats": "VITE_VISUALIZER=true vite build" works on POSIX shells but fails on Windows’ default shell.
Switching to cross-env guarantees the script works for every contributor and CI runner.

-    "build:stats": "VITE_VISUALIZER=true vite build"
+    "build:stats": "cross-env VITE_VISUALIZER=true vite build"

(You’ll need to npm i -D cross-env if it’s not already present).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e0f5e9 and e9a444f.

⛔ Files ignored due to path filters (46)
  • package-lock.json is excluded by !**/package-lock.json
  • public/images/recommendation/amrith-g.jpeg is excluded by !**/*.jpeg
  • public/images/recommendation/dawid-makowski.jpeg is excluded by !**/*.jpeg
  • public/images/talks/001.jpg is excluded by !**/*.jpg
  • public/images/talks/002.jpg is excluded by !**/*.jpg
  • public/images/talks/003.jpg is excluded by !**/*.jpg
  • src/images/1-about.png is excluded by !**/*.png
  • src/images/1-me.jpg is excluded by !**/*.jpg
  • src/images/avatar-01.jpg is excluded by !**/*.jpg
  • src/images/avatar-02.jpg is excluded by !**/*.jpg
  • src/images/avatar-03.jpg is excluded by !**/*.jpg
  • src/images/avatar-04.jpg is excluded by !**/*.jpg
  • src/images/avatar-05.jpg is excluded by !**/*.jpg
  • src/images/book.png is excluded by !**/*.png
  • src/images/default-avatar.jpg is excluded by !**/*.jpg
  • src/images/education-icon-01.svg is excluded by !**/*.svg
  • src/images/education-icon-02.svg is excluded by !**/*.svg
  • src/images/popular-post-01.jpg is excluded by !**/*.jpg
  • src/images/popular-post-02.jpg is excluded by !**/*.jpg
  • src/images/post-image.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-01.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-02.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-03.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-04.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-05.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-06.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-07.jpg is excluded by !**/*.jpg
  • src/images/post-thumb-08.jpg is excluded by !**/*.jpg
  • src/images/profile/001.png is excluded by !**/*.png
  • src/images/profile/about.jpg is excluded by !**/*.jpg
  • src/images/profile/me.jpg is excluded by !**/*.jpg
  • src/images/profile/me.png is excluded by !**/*.png
  • src/images/project-icon-01.svg is excluded by !**/*.svg
  • src/images/project-icon-02.svg is excluded by !**/*.svg
  • src/images/project-icon-03.svg is excluded by !**/*.svg
  • src/images/project-icon-04.svg is excluded by !**/*.svg
  • src/images/project-icon-05.svg is excluded by !**/*.svg
  • src/images/project-icon-06.svg is excluded by !**/*.svg
  • src/images/project-icon-07.svg is excluded by !**/*.svg
  • src/images/project-icon-08.svg is excluded by !**/*.svg
  • src/images/reference-01.jpg is excluded by !**/*.jpg
  • src/images/reference-02.jpg is excluded by !**/*.jpg
  • src/images/testimonial-01.jpg is excluded by !**/*.jpg
  • src/images/testimonial-02.jpg is excluded by !**/*.jpg
  • src/images/testimonial-03.jpg is excluded by !**/*.jpg
  • src/images/testimonial-04.jpg is excluded by !**/*.jpg
📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • package.json (3 hunks)
  • src/pages/PostPage.vue (2 hunks)
  • src/partials/WidgetSponsorPartial.vue (2 hunks)
  • src/public.ts (2 hunks)
  • src/router.ts (1 hunks)
  • vite.config.ts (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: Test Format Workflow
src/partials/WidgetSponsorPartial.vue

[error] 1-35: Code formatting changes detected in the file. The git diff shows modifications that likely caused the pipeline to fail. Please ensure code is formatted correctly and committed.

🔇 Additional comments (6)
src/public.ts (1)

68-106: Excellent implementation of dynamic syntax highlighting.

This function effectively addresses the bundle optimization goals by:

  • Using dynamic imports to reduce initial bundle size
  • Implementing a singleton pattern to prevent duplicate registrations
  • Loading languages in parallel for better performance
  • Providing convenient aliases for common language variants

The implementation properly addresses the previous review concern about language registration.

src/pages/PostPage.vue (3)

117-117: Proper integration with optimized highlight.js.

The import change to highlight.js/lib/core correctly supports the new dynamic language loading system.


191-192: Correct initialization sequence.

The async call to initializeHighlighter before fetching post data ensures languages are properly registered before syntax highlighting is needed.


185-185: Updated highlighting call is correct.

The change from hljs.highlightElement to highlight.highlightElement properly aligns with the new import structure.

src/router.ts (1)

25-42: Excellent implementation of lazy loading.

Converting all route components to dynamic imports enables effective code splitting and reduces the initial bundle size. This directly supports the production build optimization objectives.

.gitignore (1)

3-3: Appropriate exclusion of generated build analysis files.

Adding stats.html to gitignore is correct for excluding build visualization files generated by the rollup-plugin-visualizer.

@gocanto gocanto merged commit f48a990 into main Aug 5, 2025
1 of 5 checks passed
@gocanto gocanto deleted the feature/dynamic-import branch October 3, 2025 04:01
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