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

Renewal v1 #44

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

Renewal v1 #44

wants to merge 38 commits into from

Conversation

staticWagomU
Copy link
Owner

@staticWagomU staticWagomU commented Jun 29, 2024

リニューアルプロジェクトはこのブランチで進めていくこととする!!!

Summary by CodeRabbit

  • New Features

    • Introduced Google Fonts optimization for improved font loading performance.
    • Added new plugins for enhanced markdown processing capabilities, including remarkBudoux for Japanese text processing.
    • Introduced a new outward icon for navigation links in the header.
    • Redesigned blog index page to a modern timeline layout.
  • Dependencies

    • Updated various dependencies to their latest versions, including @astrojs/mdx, @astrojs/rss, and added @playform/compress, @playform/inline, and astro-google-fonts-optimizer.
  • Removals

    • Removed the vanillaExtractPlugin to streamline plugin usage in the project.
  • Improvements

    • Renamed formatting scripts for clarity and consistency.
    • Restructured the project workspace for better package management.
    • Established coding style guidelines through a new .editorconfig file.
    • Enhanced global CSS styles for better layout and design consistency.

Copy link

coderabbitai bot commented Jun 29, 2024

Warning

Rate limit exceeded

@staticWagomU has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between a5c38da and ca477a9.

Walkthrough

The updates introduce a new .editorconfig file for standardized code formatting, modify the astro.config.mjs to restructure plugins and enhance markdown processing capabilities, and update the package.json dependencies. The BaseHead.astro file integrates a new component for optimizing Google Fonts, while the Header.astro file adds a new CV link with an outward icon. Additionally, a new OutowardIcon.astro file is created, and the remark-budoux functionality is introduced for processing Japanese text in markdown. New packages for remark-budoux and rehype-wrap-h2-with-section are also added.

Changes

File Summary of Changes
.editorconfig Added configuration for code formatting, specifying indentation, end-of-line characters, and trimming rules.
astro.config.mjs Removed vanillaExtractPlugin, added new plugins to integrations, and expanded markdown processing capabilities.
package.json Updated and added dependencies, streamlined formatting scripts, and removed textlint-related packages.
src/components/BaseHead.astro Integrated GoogleFontsOptimizer for optimizing Google Fonts loading.
src/components/Header.astro Added a link to an external CV with an outward icon and removed a style block.
src/components/Icon/OutowardIcon.astro Introduced a new component for rendering an outward SVG icon.
src/pages/blog/[...slug].astro Modified getStaticPaths to retrieve post data using find method based on the slug.
src/pages/blog/index.astro Replaced table layout with a timeline-style presentation for blog posts.
src/styles/global.css Updated body, preformatted text, and code block styles; introduced CSS variables for color management.
tools/remark-budoux/index.js Added a function for processing Japanese text in markdown using the Budoux library.
tools/remark-budoux/package.json Created a new package file specifying metadata and dependencies for remark-budoux.
tools/remark-code-quote/package.json Introduced a new package file with metadata for remark-code-quote.
tools/rehype-wrap-h2-with-section/package.json Introduced a new package with metadata and a test script.

Poem

In the land of Astro, where configs reside,
New plugins are dancing, with elegance and pride.
Fonts optimized, like a rabbit in flight,
Codebase is tidy, everything feels right.
Outdated tools bid a soft goodbye,
Hello to updates, as new sparks fly. 🌠


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>, please review it.
    • 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 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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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

@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 bef47ab and fd68233.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (2)
  • astro.config.mjs (1 hunks)
  • package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • package.json
Additional comments not posted (4)
astro.config.mjs (4)

6-6: Import statement for Tailwind.

The import statement for tailwind from @astrojs/tailwind is correctly added.


14-14: Integration of Tailwind.

The tailwind integration is correctly added to the integrations array.


21-23: Markdown configuration reformatting.

The markdown configuration block has been reformatted for better readability.


16-16: Vite plugins configuration.

The plugins array in the vite configuration is now empty, indicating the removal of vanillaExtractPlugin.

However, verify if the removal of vanillaExtractPlugin affects any other part of the codebase.

Verification successful

Vite plugins configuration.

The plugins array in the vite configuration is now empty, indicating the removal of vanillaExtractPlugin. The search results confirm that there are no other occurrences of vanillaExtractPlugin in the codebase, indicating that its removal does not affect any other part of the codebase.

  • No further action required.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the removal of `vanillaExtractPlugin` affects any other part of the codebase.

# Test: Search for the usage of `vanillaExtractPlugin`. Expect: No usage in the codebase.
rg --type js --type mjs $'vanillaExtractPlugin'

Length of output: 74



Script:

#!/bin/bash
# Description: Verify if the removal of `vanillaExtractPlugin` affects any other part of the codebase.

# Test: Search for the usage of `vanillaExtractPlugin`. Expect: No usage in the codebase.
rg 'vanillaExtractPlugin' --glob '*.js' --glob '*.mjs'

Length of output: 54

Copy link

cloudflare-workers-and-pages bot commented Sep 18, 2024

Deploying boxofrubberbands with  Cloudflare Pages  Cloudflare Pages

Latest commit: ca477a9
Status:🚫  Build failed.

View logs

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: 2

Outside diff range and nitpick comments (4)
tools/rehype-wrap-h2-with-section/package.json (2)

9-9: Add keywords to improve the package's discoverability.

The keywords field is currently empty. Please add relevant keywords to help users discover this package when searching for rehype plugins or HTML processing tools.


10-10: Add author information for attribution and maintainability.

The author field is currently empty. Please add your name and email address to provide attribution and facilitate maintainability of this package.

tools/remark-code-quote/package.json (2)

4-4: Consider adding a proper description and author information.

The "description" and "author" fields are currently empty. Filling in these details can provide valuable information about the module's purpose and maintainer.

Also applies to: 10-10


7-7: Implement actual tests for the module.

The current test script simply outputs an error message indicating no tests are specified. As the module's development progresses, replace this placeholder with actual tests to ensure the module's functionality and catch potential issues.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd68233 and 9ff0cde.

Files ignored due to path filters (3)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tools/rehype-wrap-h2-with-section/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tools/remark-code-quote/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (17)
  • .editorconfig (1 hunks)
  • astro.config.mjs (1 hunks)
  • package.json (1 hunks)
  • src/components/Footer.astro (0 hunks)
  • src/components/Header.astro (0 hunks)
  • src/config.ts (1 hunks)
  • src/content/config.ts (1 hunks)
  • src/env.d.ts (1 hunks)
  • src/layouts/BlogPost.astro (0 hunks)
  • src/pages/majime/blog/[...slug].astro (0 hunks)
  • src/pages/majime/blog/index.astro (0 hunks)
  • src/pages/majime/index.astro (0 hunks)
  • src/pages/rss.xml.ts (1 hunks)
  • tools/rehype-wrap-h2-with-section/index.js (1 hunks)
  • tools/rehype-wrap-h2-with-section/package.json (1 hunks)
  • tools/remark-code-quote/index.js (1 hunks)
  • tools/remark-code-quote/package.json (1 hunks)
Files not reviewed due to no reviewable changes (6)
  • src/components/Footer.astro
  • src/components/Header.astro
  • src/layouts/BlogPost.astro
  • src/pages/majime/blog/[...slug].astro
  • src/pages/majime/blog/index.astro
  • src/pages/majime/index.astro
Files skipped from review due to trivial changes (5)
  • .editorconfig
  • src/config.ts
  • src/content/config.ts
  • src/env.d.ts
  • src/pages/rss.xml.ts
Additional comments not posted (24)
tools/rehype-wrap-h2-with-section/package.json (1)

12-15: Dependencies are appropriate for the package's intended functionality.

The dependencies section lists rehype and unist-util-visit, which are suitable for a package that aims to process HTML using rehype and manipulate the AST using unist-util-visit.

tools/remark-code-quote/package.json (1)

1-18: The package.json file provides a solid foundation for the remark-code-quote module.

The file correctly defines the module's metadata and lists relevant dependencies, establishing a good starting point for the module's development.

astro.config.mjs (6)

5-5: LGTM!

The import statement for the custom codeBlockPlugin is syntactically correct. Ensure that the plugin is implemented correctly in the referenced file.


6-6: LGTM!

The import statement for the custom wrapH2WithSection plugin is syntactically correct. Ensure that the plugin is implemented correctly in the referenced file.


12-12: LGTM!

The addition of the tailwind() integration is syntactically correct and aligns with the AI-generated summary. This change integrates Tailwind CSS into the project.


14-14: LGTM!

The empty plugins array in the vite configuration is syntactically correct and aligns with the AI-generated summary. This change suggests a shift away from using Vanilla Extract for CSS-in-JS styling.


17-18: LGTM!

The addition of the custom codeBlockPlugin to the remarkPlugins array and the custom wrapH2WithSection plugin to the rehypePlugins array is syntactically correct and aligns with the AI-generated summary. These changes enhance the markdown processing capabilities of the project.


20-21: LGTM!

The configuration of the "github-light" theme for syntax highlighting in the shikiConfig is syntactically correct. This change sets a preference for a light-themed syntax highlighting style.

tools/rehype-wrap-h2-with-section/index.js (1)

1-30: LGTM!

The function correctly wraps <h2> elements with <section> tags and groups the following nodes into the same <section>. The logic is sound and the implementation is accurate.

tools/remark-code-quote/index.js (3)

3-17: LGTM!

The codeBlockPlugin function correctly implements a remark plugin for processing code blocks in a Markdown AST. It follows the expected pattern of traversing the AST using visit, modifying the code block nodes by extracting the title from the meta property, and replacing the original node with a new HTML structure.

The logic is sound and adheres to the plugin's intended behavior.


19-30: LGTM!

The createCodeBlockWithTitle function correctly generates the HTML structure for a code block with an optional title. It properly handles the presence or absence of a title by conditionally creating the title element.

The use of template literals to construct the HTML string is a clean and readable approach. The code is also safely escaped using the escapeHtml function to prevent HTML injection vulnerabilities.

The function produces the expected HTML output based on the provided language, title, and code.


32-39: LGTM!

The escapeHtml function correctly escapes special characters in a string to prevent HTML injection. It replaces the characters &, <, >, ", and ' with their corresponding HTML entities using the replace method and regular expressions.

The function is a simple and effective way to sanitize user input and ensure that it is safely rendered in HTML contexts.

The implementation is correct and achieves the desired escaping behavior.

package.json (12)

16-17: LGTM!

The new format and format:check scripts are more concise and descriptive. The --plugin-search-dir=. flag is a good practice to ensure that plugins are searched for in the current directory.


25-25: What is the purpose of the @astrojs/check package?

The @astrojs/check package has been added as a new dependency with version ^0.7.0. Can you please provide more information about the purpose of this package and how it will be used in the project?


27-28: LGTM!

The @astrojs/rss and @astrojs/sitemap packages have been updated to newer minor versions. These updates should not introduce any breaking changes.


29-29: LGTM!

The @markuplint/astro-parser package has been updated to a newer minor version. This update should not introduce any breaking changes.


30-30: LGTM!

The @vanilla-extract/css package has been updated to a newer minor version. This update should not introduce any breaking changes.


34-34: LGTM!

The husky package has been updated to a newer patch version. This update should not introduce any breaking changes.


35-35: LGTM!

The markuplint package has been updated to a newer minor version. This update should not introduce any breaking changes.


37-37: LGTM!

The prettier package has been updated to a newer minor version. This update should not introduce any breaking changes.


40-40: LGTM!

The tailwindcss package has been added as a new dependency with version ^3.4.3. This package provides a utility-first CSS framework for rapidly building custom user interfaces.


41-41: What is the impact of updating the typescript package to a major version?

The typescript package has been updated from version ^4.9.5 to ^5.4.5. This is a major version update, which means that it may introduce breaking changes. Can you please provide more information about the impact of this update on the project and confirm that all necessary changes have been made to accommodate this update?


39-39: LGTM!

The remark-breaks package has been added as a new dependency with version ^4.0.0. This package adds support for hard line breaks in Markdown.


Line range hint 1-43: What is the reason for removing textlint related dependencies?

The textlint related dependencies have been removed from the devDependencies section. Can you please provide more information about the reason for this removal and confirm that it is intentional?

{
"name": "rehype-wrap-h2-with-section",
"version": "1.0.0",
"description": "",
Copy link

Choose a reason for hiding this comment

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

Add a description to provide an overview of the package's functionality.

The description field is currently empty. Please add a brief description of what this package does and how it integrates with the rehype ecosystem.

Comment on lines +6 to +8
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Copy link

Choose a reason for hiding this comment

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

Replace the placeholder test script with actual tests.

The scripts section includes a placeholder test script that outputs an error message. Please replace this with actual test scripts to ensure the package's functionality is properly verified.

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: 7

🧹 Outside diff range and nitpick comments (16)
.prettierignore (1)

1-2: LGTM! Consider adding a Markdown-specific linter.

The addition of *.mdx and *.md to .prettierignore is a good practice. It prevents Prettier from potentially misformatting Markdown and MDX files, which often have specific formatting requirements.

To maintain consistency in your Markdown files without using Prettier, consider adding a Markdown-specific linter to your project. Tools like markdownlint can help enforce consistent styling in your documentation files.

.editorconfig (1)

1-11: Overall, good configuration with room for improvement.

This .editorconfig file provides a solid foundation for consistent code formatting across the project. However, consider the following improvements:

  1. Use LF instead of CRLF for line endings to ensure better cross-platform compatibility.
  2. Consider adding settings for other file types used in your project (e.g., .md, .yml, .astro).
  3. Verify that the global indentation settings (tabs with width of 2 spaces) align with your team's coding standards.

These changes will enhance the consistency and cross-platform compatibility of your codebase.

tools/remark-astro-last-modified-at/package.json (2)

1-6: Package metadata needs improvement

The package.json file has been created with basic metadata, which is a good start. However, there are some areas that could be improved:

  1. The description field is empty. This should be filled with a concise explanation of what the package does.
  2. The keywords array is empty. Adding relevant keywords will help others discover your package.
  3. The author field is empty. It's good practice to include author information.

Consider updating these fields to provide more information about your package. For example:

{
  "description": "A remark plugin for Astro to add last modified date to markdown files",
  "keywords": ["remark", "plugin", "astro", "markdown", "last-modified"],
  "author": "Your Name <[email protected]>"
}

Also applies to: 10-13


1-13: Consider adding more npm package configurations

While the current package.json file covers the basics, there are additional fields you might want to consider adding:

  1. repository: Link to your GitHub repository.
  2. bugs: URL where issues can be reported.
  3. homepage: URL to the project homepage or documentation.
  4. peerDependencies: If your plugin requires specific versions of remark or other packages.
  5. engines: Specify which versions of Node.js are supported.

Here's an example of how these might look:

{
  "repository": {
    "type": "git",
    "url": "https://github.com/yourusername/remark-astro-last-modified-at.git"
  },
  "bugs": {
    "url": "https://github.com/yourusername/remark-astro-last-modified-at/issues"
  },
  "homepage": "https://github.com/yourusername/remark-astro-last-modified-at#readme",
  "peerDependencies": {
    "remark": "^14.0.0"
  },
  "engines": {
    "node": ">=14.0.0"
  }
}

These additions will make your package more discoverable and provide important information to potential users.

tools/rehype-wrap-h2-with-section/package.json (1)

9-11: Enhance package metadata with keywords and author information.

To improve the discoverability and attribution of your package:

  1. Add relevant keywords to the keywords array. For example: ["rehype", "plugin", "markdown", "html", "section", "heading"].
  2. Fill in the author field with your name and optionally your email or website.

The license field is appropriately set to "ISC".

.prettierrc.json (1)

Line range hint 1-24: LGTM! Consider a minor improvement for clarity

The overall Prettier configuration is well-structured and follows best practices. It includes appropriate settings for common formatting preferences and uses the Astro plugin for Astro files.

As a minor suggestion for improved clarity, consider adding a comment explaining the purpose of the ".*" pattern in the files array of the first override. This pattern applies the override to all files, which might not be immediately obvious to all developers.

You could add a comment like this:

 "overrides": [
   {
-    "files": [".*", "*.json", "*.toml", "*.yml"],
+    "files": [
+      ".*", // Apply to all files
+      "*.json",
+      "*.toml",
+      "*.yml"
+    ],
     "options": {
       "useTabs": false
     }
   },

This change would make the configuration more self-documenting and easier for other developers to understand and maintain.

tools/remark-code-quote/package.json (1)

1-5: Enhance package metadata for better discoverability and understanding.

Consider making the following improvements to the package metadata:

  1. Add a concise description of the package's purpose and functionality (line 4).
  2. Include relevant keywords to improve discoverability (line 9).
  3. Specify the author information for attribution and contact purposes (line 10).
  4. Verify if the "ISC" license is the intended license for this package (line 11).

These changes will provide better context for potential users and contributors.

Also applies to: 9-11, 17-18

astro.config.mjs (1)

18-19: LGTM! Consider adding documentation for custom plugins.

The addition of new remark and rehype plugins enhances the markdown processing capabilities. This is a good improvement.

Consider adding comments or documentation explaining the purpose and functionality of these custom plugins (codeBlockPlugin, astroLastModifiedAt, and wrapH2WithSection) for better maintainability.

tools/rehype-wrap-h2-with-section/index.js (3)

1-5: LGTM! Consider adding JSDoc comments for better documentation.

The function declaration and initial setup look good. The higher-order function pattern is appropriate for this use case.

Consider adding JSDoc comments to describe the purpose of the function and its parameters. This would improve code documentation and maintainability. For example:

/**
 * Creates a rehype plugin that wraps <h2> elements and their subsequent content in <section> elements.
 * @returns {function} A rehype plugin function.
 */
export default function wrapH2WithSection() {
  /**
   * @param {object} tree - The syntax tree to process.
   * @returns {void}
   */
  return (tree) => {
    // ... rest of the code
  };
}

6-22: LGTM! Consider extracting the section creation logic for improved readability.

The main processing loop correctly implements the desired functionality of wrapping <h2> elements and their subsequent content in <section> elements.

To improve readability, consider extracting the section creation logic into a separate function. This would make the main loop more concise and easier to understand. Here's a suggested refactor:

function createSection(node) {
  return {
    type: 'element',
    tagName: 'section',
    properties: { className: ['section'] },
    children: [node]
  };
}

tree.children.forEach((node) => {
  if (node.type === 'element' && node.tagName === 'h2') {
    if (currentSection) {
      sections.push(currentSection);
    }
    currentSection = createSection(node);
  } else if (currentSection) {
    currentSection.children.push(node);
  } else {
    sections.push(node);
  }
});

This refactoring would make the main loop more focused on its primary task of organizing nodes into sections.


28-28: LGTM! Consider adding a safety check for tree.children.

The replacement of the original tree's children with the newly created sections is correct and achieves the desired outcome.

For added robustness, consider adding a safety check to ensure tree.children exists before assigning to it. This can prevent potential errors if the tree structure is unexpected:

if (tree.children) {
  tree.children = sections;
} else {
  console.warn('Unexpected tree structure: tree.children is undefined');
}

This addition would make the function more resilient to unexpected input structures.

package.json (1)

Line range hint 1-42: Overall package.json changes align with project renewal objectives.

The changes in this file reflect a significant update to the project's dependencies and scripts, aligning with the renewal project mentioned in the PR objectives. Key points:

  1. Script renaming improves clarity and follows common conventions.
  2. Dependency updates, especially for core packages like Astro, bring the project up-to-date but require careful testing for compatibility.
  3. The addition of GSAP and removal of previous dependencies represent a major shift in the project's structure.

Recommendations:

  1. Thoroughly test the project with the updated dependencies, especially the beta versions.
  2. Review the project's animation requirements and ensure GSAP is being used effectively.
  3. Verify that all necessary functionality is maintained after the removal of previous dependencies.
  4. Update project documentation to reflect these changes, particularly regarding any new animation capabilities or changes in build/development processes.

Consider creating a changelog entry for these significant updates to help track and communicate these changes to other developers or stakeholders.

tools/remark-code-quote/index.js (4)

3-17: Approve implementation with suggestions for improvement

The codeBlockPlugin function is well-structured and follows the expected pattern for a remark plugin. However, consider the following improvements for increased robustness:

  1. Enhance the title extraction regex to handle more cases, such as titles containing quotes or using different delimiters.
  2. Add a check for the existence of the meta property before attempting to match the title.
  3. Implement error handling to catch and log any issues during the transformation process.

Here's a suggested improvement:

 export default function codeBlockPlugin() {
   return (tree) => {
     visit(tree, "code", (node, index, parent) => {
-      if (node.meta) {
-        const titleMatch = node.meta.match(/title=["']([^"']*)["']/);
-        const title = titleMatch ? titleMatch[1] : "";
+      if (node.meta && typeof node.meta === 'string') {
+        const titleMatch = node.meta.match(/title=(?:["']([^"']*?)["']|(\S+))/);
+        const title = titleMatch ? (titleMatch[1] || titleMatch[2]) : "";
         const codeBlockWithTitle = {
           type: "html",
           value: createCodeBlockWithTitle(node.lang, title, node.value)
         };
-        parent.children.splice(index, 1, codeBlockWithTitle);
+        try {
+          parent.children.splice(index, 1, codeBlockWithTitle);
+        } catch (error) {
+          console.error("Error replacing code block:", error);
+        }
       }
     });
   };
 }

This modification improves title extraction, adds a type check for meta, and includes basic error handling.


19-30: Approve implementation with suggestions for security and edge cases

The createCodeBlockWithTitle function effectively generates the HTML structure for a code block with an optional title. However, consider the following improvements:

  1. Sanitize the lang parameter to prevent potential XSS vulnerabilities.
  2. Handle cases where lang is undefined or an empty string.
  3. Consider using a template literal with proper indentation for better readability and maintenance.

Here's a suggested improvement:

 function createCodeBlockWithTitle(lang, title, code) {
   const titleElement = title 
     ? `<div class="code-block-title">${escapeHtml(title)}</div>`
     : '';
   
+  const sanitizedLang = lang ? escapeHtml(lang.trim()) : 'plaintext';
+  
   return `
 <div class="code-block-with-title">
   ${titleElement}
-  <pre><code class="language-${lang}">${escapeHtml(code)}</code></pre>
+  <pre><code class="language-${sanitizedLang}">${escapeHtml(code)}</code></pre>
 </div>
 `;
 }

This modification sanitizes both the lang and title parameters, and provides a default language if none is specified.


32-39: Approve implementation with suggestions for robustness and efficiency

The escapeHtml function correctly escapes the most common HTML special characters. However, consider the following improvements:

  1. Handle potential null or undefined inputs to prevent runtime errors.
  2. For larger strings, consider using a single replace call with a callback function for better efficiency.
  3. Rename the function to escapeCommonHtmlChars to more accurately reflect its functionality.

Here's a suggested improvement:

-function escapeHtml(unsafe) {
+function escapeCommonHtmlChars(unsafe) {
+  if (unsafe == null) return '';
+  
   return unsafe
-    .replace(/&/g, "&amp;")
-    .replace(/</g, "&lt;")
-    .replace(/>/g, "&gt;")
-    .replace(/"/g, "&quot;")
-    .replace(/'/g, "&#039;");
+    .replace(/[&<>"']/g, (char) => {
+      switch (char) {
+        case '&': return '&amp;';
+        case '<': return '&lt;';
+        case '>': return '&gt;';
+        case '"': return '&quot;';
+        case "'": return '&#039;';
+        default: return char;
+      }
+    });
 }

This modification handles null/undefined inputs, uses a single replace call for better efficiency, and renames the function to more accurately describe its functionality.


1-39: Overall assessment: Well-implemented plugin with room for improvement

This remark plugin for processing code blocks with titles is well-structured and functional. The main areas for improvement are:

  1. Enhanced security measures (input sanitization)
  2. Better error handling and edge case management
  3. Improved efficiency for string operations
  4. More accurate function naming

Implementing the suggested changes will result in a more robust, secure, and maintainable plugin.

Consider adding unit tests to verify the plugin's behavior, especially after implementing the suggested improvements. This will help ensure the plugin continues to function correctly as it evolves.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9ff0cde and c19d982.

⛔ Files ignored due to path filters (3)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tools/rehype-wrap-h2-with-section/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tools/remark-code-quote/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (21)
  • .editorconfig (1 hunks)
  • .prettierignore (1 hunks)
  • .prettierrc.json (1 hunks)
  • astro.config.mjs (1 hunks)
  • package.json (1 hunks)
  • src/components/Footer.astro (0 hunks)
  • src/components/Header.astro (0 hunks)
  • src/config.ts (1 hunks)
  • src/content/config.ts (1 hunks)
  • src/env.d.ts (1 hunks)
  • src/layouts/BlogPost.astro (0 hunks)
  • src/pages/majime/blog/[...slug].astro (0 hunks)
  • src/pages/majime/blog/index.astro (0 hunks)
  • src/pages/majime/index.astro (0 hunks)
  • src/pages/rss.xml.ts (1 hunks)
  • tools/rehype-wrap-h2-with-section/index.js (1 hunks)
  • tools/rehype-wrap-h2-with-section/package.json (1 hunks)
  • tools/remark-astro-last-modified-at/index.js (1 hunks)
  • tools/remark-astro-last-modified-at/package.json (1 hunks)
  • tools/remark-code-quote/index.js (1 hunks)
  • tools/remark-code-quote/package.json (1 hunks)
💤 Files with no reviewable changes (6)
  • src/components/Footer.astro
  • src/components/Header.astro
  • src/layouts/BlogPost.astro
  • src/pages/majime/blog/[...slug].astro
  • src/pages/majime/blog/index.astro
  • src/pages/majime/index.astro
✅ Files skipped from review due to trivial changes (4)
  • src/config.ts
  • src/content/config.ts
  • src/env.d.ts
  • src/pages/rss.xml.ts
🔇 Additional comments (15)
.editorconfig (2)

1-1: LGTM: Root declaration is correct.

The root = true declaration is correctly set, ensuring that this .editorconfig file is treated as the top-most configuration file for the project.


3-5: LGTM: Global settings are well-defined.

The global settings use tab indentation with a width of 2 spaces, which is a valid choice. However, it's important to ensure this aligns with your team's coding standards.

Please confirm that these indentation settings (tabs with width of 2 spaces) align with your team's coding standards and preferences.

tools/remark-astro-last-modified-at/index.js (1)

1-1: LGTM: Import statement is correct.

The import of execSync from child_process is appropriate for the functionality implemented in this file.

tools/rehype-wrap-h2-with-section/package.json (4)

4-4: Add a description to provide an overview of the package's functionality.

The description field is still empty. As mentioned in a previous review, please add a brief description of what this package does and how it integrates with the rehype ecosystem. This will help users understand the purpose of your plugin.


6-8: Replace the placeholder test script with actual tests.

As noted in a previous review, the scripts section still includes a placeholder test script that outputs an error message. Please replace this with actual test scripts to ensure the package's functionality is properly verified. Consider using a testing framework like Jest or tape for Node.js packages.


12-15: Dependencies look good.

The dependencies section is well-structured:

  • "rehype" and "unist-util-visit" are appropriate choices for a rehype plugin.
  • The use of caret (^) version ranges allows for compatible updates.
  • The specified versions are recent, which is good for security and feature availability.

5-5: Verify the existence of the main entry point file.

The main field is correctly set to "index.js". However, please ensure that this file exists in the package root and contains the main logic for the rehype plugin.

✅ Verification successful

Main entry point file verified.

The index.js file exists in the tools/rehype-wrap-h2-with-section directory and correctly serves as the main entry point as specified in the package.json.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if index.js exists in the package directory

# Test: Check if index.js exists
if fd -t f -d 1 index.js tools/rehype-wrap-h2-with-section; then
    echo "index.js found in the package directory"
else
    echo "index.js not found in the package directory"
fi

Length of output: 189

.prettierrc.json (1)

11-11: Verify the removal of Markdown files from Prettier overrides

The Markdown file types (*.md, *.mdx) have been removed from the overrides section. This change means that Markdown files will now use the default Prettier configuration instead of the specific override.

Please confirm if this was intentional. If not, consider adding Markdown files back to the override to maintain consistent formatting across all file types.

astro.config.mjs (2)

15-15: LGTM! Unused plugins removed.

Removing unused plugins from the Vite configuration helps maintain a clean and efficient setup.


21-23: LGTM! Improved code formatting.

The indentation change in the shikiConfig object improves code readability while maintaining the same functionality.

tools/rehype-wrap-h2-with-section/index.js (2)

24-26: LGTM! Proper handling of the final section.

This code segment correctly handles the case where the last section is still open after processing all nodes. It ensures that no content is lost, which is crucial for the integrity of the output.


1-30: Overall, well-implemented functionality with room for minor enhancements.

The wrapH2WithSection function successfully implements the desired functionality of wrapping <h2> elements and their subsequent content in <section> elements. The code is logically structured and handles edge cases appropriately.

To further improve the code:

  1. Add JSDoc comments for better documentation.
  2. Consider extracting the section creation logic into a separate function for improved readability.
  3. Add a safety check when assigning to tree.children for increased robustness.

These suggestions will enhance the maintainability and resilience of the code without changing its core functionality.

package.json (3)

16-17: LGTM: Script renaming improves clarity.

The renaming of "prettier:fix" to "format" and "prettier:check" to "format:check" is a good change. It makes the scripts more generic and aligns with common naming conventions, improving overall clarity without altering functionality.


40-42: Verify the necessity and impact of dependency changes.

The addition of GSAP (GreenSock Animation Platform) as the only runtime dependency is a significant change:

  1. GSAP is a powerful animation library, which suggests new animation features in the project.
  2. The removal of all previous dependencies from this section (as mentioned in the AI summary) could have a substantial impact on existing functionality.

Please ensure:

  1. The addition of GSAP is intentional and necessary for the project's requirements.
  2. The removal of previous dependencies doesn't break any existing features or components.
  3. If GSAP is the only runtime dependency, verify that it's being used efficiently and that no unnecessary bloat is added to the project.

To verify these changes, please run the following script:

#!/bin/bash
# Description: Check for usage of GSAP and removed dependencies

# Test: Search for GSAP usage in the project
echo "Checking for GSAP usage:"
rg --type astro --type typescript --type javascript 'from "gsap"' ./src

# Test: List all import statements to verify no removed dependencies are still in use
echo "Listing all import statements:"
rg --type astro --type typescript --type javascript '^\s*import' ./src

25-38: Verify compatibility with updated dependencies.

The devDependencies have been significantly updated:

  1. New addition: "@astrojs/check" (v0.9.3) for improved type checking.
  2. Major version updates:
    • "@astrojs/mdx" to 4.0.0-beta.1
    • "astro" to 5.0.0-beta.2
  3. Minor version updates to several other dependencies.

These updates are generally positive for security and feature improvements. However, please ensure:

  1. The project is compatible with the beta versions of Astro and MDX.
  2. Any breaking changes in the major version updates are addressed.
  3. The removal of textlint-related dependencies (mentioned in the AI summary but not visible in this diff) doesn't negatively impact the project's linting capabilities.

To verify the impact of these changes, please run the following script:

.editorconfig Outdated
Comment on lines 7 to 11
[{src,scripts}/**.{ts,json,js,cjs}]
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Consider using LF instead of CRLF for better cross-platform compatibility.

The specific settings for .ts, .json, .js, and .cjs files in the src and scripts directories are generally good:

  • UTF-8 charset is a good standard choice.
  • Trimming trailing whitespace and inserting a final newline are good practices.

However, the use of CRLF line endings may cause issues on non-Windows systems. Consider using LF instead for better cross-platform compatibility.

Apply this change to use LF line endings:

[{src,scripts}/**.{ts,json,js,cjs}]
-end_of_line = crlf
+end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[{src,scripts}/**.{ts,json,js,cjs}]
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{src,scripts}/**.{ts,json,js,cjs}]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

Comment on lines +7 to +9
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement actual tests

The current test script is a placeholder that always fails. It's important to implement actual tests for your package.

Replace the placeholder test script with actual tests. If you're not sure how to start, consider using a testing framework like Jest or Mocha. Here's an example of how you might update the scripts section:

"scripts": {
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
}

Don't forget to add the necessary devDependencies and create test files.

Comment on lines +3 to +9
export function astroLastModifiedAt() {
return function (_, file) {
const filePath = file.history[0];
const result = execSync(`git log -1 --pretty="%cs" "${filePath}"`);
file.data.astro.frontmatter.updatedDate = new Date(result.toString().trim());
}
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Security Vulnerability Identified: Unsanitized filePath in execSync.

The astroLastModifiedAt function utilizes execSync with filePath directly interpolated into the command string without any sanitization. This practice can lead to command injection vulnerabilities if filePath contains malicious input.

  • File: tools/remark-astro-last-modified-at/index.js
  • Lines: 3-9
🔗 Analysis chain

Security and robustness improvements needed.

While the function achieves its purpose, there are several areas that need attention:

  1. Security: The use of execSync with user input (file path) is potentially dangerous. Consider using a safer alternative or ensure proper input sanitization.

  2. Error Handling: Add try-catch blocks to handle potential errors from execSync and file path retrieval.

  3. Performance: execSync is blocking. For large repositories, consider using an asynchronous alternative like exec from child_process/promises.

  4. Unused Parameter: The first parameter of the inner function is unused. Consider removing it or documenting its purpose if it's required by the API.

  5. Git Dependency: The function assumes git is installed and the file is in a git repository. Add checks for these conditions.

  6. Date Parsing: The date parsing assumes a specific format. Consider making this more robust.

Here's a suggested refactor addressing these points:

import { exec } from 'child_process/promises';
import { existsSync } from 'fs';

export function astroLastModifiedAt() {
  return async function (file) {
    try {
      const filePath = file.history[0];
      if (!filePath || !existsSync(filePath)) {
        throw new Error('Invalid file path');
      }

      const sanitizedPath = filePath.replace(/"/g, '\\"');
      const result = await exec(`git log -1 --pretty="%cs" "${sanitizedPath}"`);
      
      if (result.stderr) {
        throw new Error(result.stderr);
      }

      const dateStr = result.stdout.trim();
      const date = new Date(dateStr);
      
      if (isNaN(date.getTime())) {
        throw new Error('Invalid date format');
      }

      file.data.astro.frontmatter.updatedDate = date;
    } catch (error) {
      console.error(`Error processing file: ${error.message}`);
      // Set a fallback date or handle the error as appropriate for your use case
      file.data.astro.frontmatter.updatedDate = new Date();
    }
  }
}

This refactored version addresses the identified issues and improves the overall robustness of the function.

To verify the git installation and repository status, you can run:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if git is installed and if we're in a git repository
if ! command -v git &> /dev/null; then
    echo "Git is not installed"
    exit 1
fi

if ! git rev-parse --is-inside-work-tree &> /dev/null; then
    echo "Not in a git repository"
    exit 1
fi

echo "Git is installed and we're in a git repository"

Length of output: 160


Script:

#!/bin/bash
# Search for execSync usage and potential sanitization in tools/remark-astro-last-modified-at/index.js
rg 'execSync' tools/remark-astro-last-modified-at/index.js

Length of output: 170

Comment on lines +6 to +8
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement actual tests for the package.

The current test script is a placeholder that always fails. It's recommended to implement proper tests for your package to ensure its functionality and reliability. Consider using a testing framework like Jest or Mocha to write and run tests for your code.

Example of how you might update the scripts section:

"scripts": {
  "test": "jest",
  "lint": "eslint ."
}

Don't forget to install the necessary devDependencies for testing and linting.

Would you like assistance in setting up a basic testing structure for this package?

Comment on lines 12 to 16
"dependencies": {
"open-graph-scraper": "6.3.2",
"unist-builder": "4.0.0",
"unist-util-visit": "5.0.0"
},
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using flexible version ranges for dependencies.

Currently, exact version numbers are specified for all dependencies. It's generally recommended to use more flexible version ranges (e.g., using the caret ^ prefix) to allow for bug fixes and non-breaking updates. This approach helps in keeping the package up-to-date with the latest compatible versions of its dependencies.

Here's a suggested update:

"dependencies": {
  "open-graph-scraper": "^6.3.2",
  "unist-builder": "^4.0.0",
  "unist-util-visit": "^5.0.0"
}

Also, for clarity, here's a brief explanation of each dependency:

  • open-graph-scraper: Likely used for extracting metadata from URLs in code quotes.
  • unist-builder: Used for programmatically building Unist syntax trees.
  • unist-util-visit: A utility for visiting nodes in a Unist tree, useful for traversing and manipulating the AST.

astro.config.mjs Outdated

// https://astro.build/config
export default defineConfig({
// site: 'https://example.com',
site: "https://wagomu.me",
integrations: [mdx(), sitemap()],
integrations: [mdx(), sitemap(), tailwind()],
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add Tailwind import.

The addition of tailwind() to the integrations is good, but the tailwind function is not imported at the top of the file.

Add the following import at the top of the file:

+import tailwind from "@astrojs/tailwind";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
integrations: [mdx(), sitemap(), tailwind()],
import tailwind from "@astrojs/tailwind";
integrations: [mdx(), sitemap(), tailwind()],

Comment on lines +5 to +7
import codeBlockPlugin from "./tools/remark-code-quote";
import wrapH2WithSection from "./tools/rehype-wrap-h2-with-section";
import { astroLastModifiedAt } from "./tools/remark-astro-last-modified-at";
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Imported modules are missing in the tools directory.

The files remark-code-quote.js, rehype-wrap-h2-with-section.js, and remark-astro-last-modified-at.js referenced in astro.config.mjs do not exist. This will lead to import errors and potential runtime failures.

  • Ensure that these modules are added to the tools directory.
  • Verify that the file paths and names are correct in the import statements.
🔗 Analysis chain

LGTM! Verify the imported modules.

The new imports for custom plugins look good. They follow a consistent naming convention and are appropriately imported from local files.

To ensure the imported modules exist and are correctly implemented, run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and basic structure of the imported modules

# Test: Check if the files exist and contain expected content
for file in "tools/remark-code-quote.js" "tools/rehype-wrap-h2-with-section.js" "tools/remark-astro-last-modified-at.js"; do
  if [ -f "$file" ]; then
    echo "File $file exists."
    grep -q "export default" "$file" && echo "  - Contains default export." || echo "  - Warning: No default export found."
  else
    echo "Warning: File $file does not exist."
  fi
done

Length of output: 923

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

🧹 Outside diff range and nitpick comments (3)
src/components/BaseHead.astro (1)

30-30: LGTM! Consider performance impact.

The GoogleFontsOptimizer component is correctly implemented for the Michroma font.

Consider the performance impact of loading custom fonts. While the optimizer helps, custom fonts can still affect page load times and Core Web Vitals. Monitor performance metrics after this change and consider using font-display: swap for better perceived performance.

astro.config.mjs (1)

31-36: Approve markdown configuration updates

The updates to the markdown configuration look good. The addition of custom remark and rehype plugins (codeBlockPlugin, astroLastModifiedAt, wrapH2WithSection) aligns with the new imports and likely enhances your markdown processing capabilities.

Consider adding brief comments to explain the purpose of each custom plugin for better maintainability:

markdown: {
  remarkPlugins: [
    remarkBreaks,
    codeBlockPlugin, // Handles code block formatting
    astroLastModifiedAt, // Adds last modified date to pages
  ],
  rehypePlugins: [
    wrapH2WithSection, // Wraps h2 elements with section tags
  ],
  // ... rest of the configuration
}

This will help other developers (including your future self) understand the purpose of each plugin at a glance.

package.json (1)

40-44: Approve new dependencies and suggest documentation updates.

The addition of new dependencies (@playform/compress, @playform/inline, astro-google-fonts-optimizer, gsap) aligns with the renewal objectives, potentially introducing asset optimization, font loading improvements, and advanced animations.

To ensure proper integration and usage of these new features:

  1. Please update the project documentation to reflect the use of these new dependencies.
  2. Consider adding usage examples or guidelines for the team.

Would you like assistance in drafting documentation updates for these new features?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c19d982 and c55b2e8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .editorconfig (1 hunks)
  • astro.config.mjs (1 hunks)
  • package.json (1 hunks)
  • src/components/BaseHead.astro (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .editorconfig
🔇 Additional comments (10)
src/components/BaseHead.astro (3)

Line range hint 1-31: Summary: Font optimization implemented successfully

The changes to BaseHead.astro successfully implement Google Fonts optimization for Michroma and Playwrite AR fonts. This aligns with the renewal project objectives and should improve page load performance.

Key points:

  1. Google Fonts Optimizer package is correctly imported and used.
  2. Two custom fonts (Michroma and Playwrite AR) are now optimized.

Recommendations:

  1. Monitor performance metrics after these changes.
  2. Review the usage of different font weights for Playwrite AR to ensure optimal loading.
  3. Consider using font-display: swap for better perceived performance.

These changes contribute positively to the renewal project by enhancing the efficiency of font loading.


31-31: LGTM! Review font weight usage.

The GoogleFontsOptimizer component is correctly implemented for the Playwrite AR font.

Ensure that the specified font weight range (100-400) is actually used in the project:

Consider loading only the font weights that are actually used in the project to optimize performance further.


3-3: LGTM! Verify package installation.

The import statement for GoogleFontsOptimizer is correct and aligns with the intended changes.

Ensure that the astro-google-fonts-optimizer package is properly installed and listed in the package.json file:

✅ Verification successful

Package installation verified.
The astro-google-fonts-optimizer package is correctly listed in package.json and the import statement in BaseHead.astro is valid.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the installation of astro-google-fonts-optimizer package

# Test: Check if the package is listed in package.json
if grep -q '"astro-google-fonts-optimizer"' package.json; then
  echo "Package 'astro-google-fonts-optimizer' is listed in package.json"
else
  echo "Warning: Package 'astro-google-fonts-optimizer' is not listed in package.json"
fi

Length of output: 285


Script:

#!/bin/bash
# Description: Verify the installation of astro-google-fonts-optimizer package using jq

# Check if package.json exists
if [ ! -f package.json ]; then
  echo "Error: package.json not found in the current directory."
  exit 1
fi

# Use jq to check dependencies and devDependencies
if jq -e '.dependencies | has("astro-google-fonts-optimizer")' package.json > /dev/null; then
  echo "Package 'astro-google-fonts-optimizer' is listed under dependencies."
elif jq -e '.devDependencies | has("astro-google-fonts-optimizer")' package.json > /dev/null; then
  echo "Package 'astro-google-fonts-optimizer' is listed under devDependencies."
else
  echo "Warning: Package 'astro-google-fonts-optimizer' is not listed in dependencies or devDependencies."
fi

Length of output: 257

astro.config.mjs (5)

5-7: Verify the existence of imported modules

The new imports for custom plugins look good syntactically. However, we need to ensure that these modules exist in the tools directory to prevent potential runtime errors.

Run the following script to check for the existence of these files:

#!/bin/bash
# Description: Verify the existence and basic structure of the imported modules

for file in "tools/remark-code-quote.js" "tools/rehype-wrap-h2-with-section.js" "tools/remark-astro-last-modified-at.js"; do
  if [ -f "$file" ]; then
    echo "File $file exists."
    grep -q "export default" "$file" && echo "  - Contains default export." || echo "  - Warning: No default export found."
  else
    echo "Warning: File $file does not exist."
  fi
done

If any of these files are missing or don't contain a default export, please ensure they are created and implemented correctly.

This comment addresses the concern raised in a previous review about missing modules in the tools directory.


13-25: Approve integrations update and suggest documentation

The updated integrations array looks good. The addition of @playform/compress and @playform/inline plugins can potentially improve the performance of your site.

Consider adding a comment to briefly explain the purpose of these new plugins for better maintainability.

Example:

integrations: [
  mdx(),
  sitemap(),
  // Compress assets for improved performance
  (await import('@playform/compress')).default({
    // ... configuration ...
  }),
  // Inline critical assets
  (await import("@playform/inline")).default()
],

Regarding the past comment about adding a Tailwind import: Since tailwind() is not used in this configuration, there's no need to import it. If you plan to use Tailwind in the future, remember to both import and add it to the integrations array.


26-26: Approve trailingSlash configuration

The addition of trailingSlash: 'never' is a good configuration choice. This ensures that all URLs in your site will not have trailing slashes, which can help maintain consistent URL structures and potentially improve SEO.

This configuration will affect how Astro generates links and redirects, so make sure this aligns with your overall URL strategy.


28-28: Clarify removal of Vite plugins

The plugins array in the Vite configuration has been emptied. While this is a valid configuration, it's unclear why any previously configured Vite plugins were removed.

Could you please clarify the reasoning behind removing the Vite plugins? If this was intentional, consider adding a comment explaining why:

vite: {
  plugins: [] // Removed previous plugins because...
},

If this was unintentional, please review if any necessary Vite plugins need to be reinstated.


1-36: Overall configuration update looks good

The changes to astro.config.mjs significantly enhance the project's capabilities:

  1. New custom plugins have been added for improved markdown processing.
  2. Performance optimization plugins (@playform/compress and @playform/inline) have been integrated.
  3. URL structure has been standardized with the trailingSlash option.
  4. Markdown configuration has been expanded with new remark and rehype plugins.

These updates should improve the site's performance, SEO, and content processing capabilities. The suggestions for additional documentation will help maintain the config file's clarity as the project grows.

Remember to implement the custom plugins in the tools directory if they haven't been created yet, and consider the suggestions for adding clarifying comments throughout the configuration.

package.json (2)

25-38: Approve dependency updates and highlight significant changes.

The updates to devDependencies are generally good, keeping the project up-to-date. Notable changes include:

  1. Addition of @astrojs/check for improved type-checking.
  2. Significant update to Astro (5.0.0-beta.2), which may introduce breaking changes.
  3. Removal of textlint and related rules, indicating a change in linting strategy.

Please ensure thorough testing, especially with the Astro beta version. Consider running the following commands to check for any breaking changes or deprecation warnings:

#!/bin/bash
# Description: Install dependencies and run build process to check for warnings or errors

echo "Installing dependencies..."
npm install

echo "Running build process..."
npm run build

echo "Checking for deprecation warnings or errors in the build output..."
npm run build 2>&1 | grep -i "deprecat\|warning\|error"

16-17: Approve script renaming and suggest verification.

The renaming of "prettier:fix" to "format" and "prettier:check" to "format:check" improves clarity and consistency. This is a good change.

Please verify that any CI/CD pipelines, documentation, or other scripts that may have referenced the old script names ("prettier:fix" and "prettier:check") are updated accordingly. Run the following script to check for any remaining references:

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: 2

🧹 Outside diff range and nitpick comments (6)
src/components/Icon/OutowardIcon.astro (2)

5-6: LGTM: Well-structured SVG element with flexible customization

The SVG element is correctly defined with appropriate attributes. The use of "1em" for width and height ensures scalability, and spreading props allows for additional customization.

Consider adding an aria-hidden="true" attribute to the SVG element for better accessibility, as this appears to be a decorative icon. If the icon conveys meaning, add a descriptive aria-label instead.


6-7: LGTM: Well-defined SVG path with proper color inheritance

The SVG path is correctly defined, using "currentColor" for the fill, which allows for easy color customization. The path data accurately represents an outward arrow icon.

For improved maintainability, consider extracting the path data into a constant or variable at the top of the file. This would make it easier to update the icon's shape in the future if needed.

Example:

---
const props = Astro.props;
const pathData = "M6.4 18L5 16.6L14.6 7H6V5h12v12h-2V8.4z";
---

<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24" {...props}>
  <path fill="currentColor" d={pathData}></path>
</svg>
tools/remark-budoux/index.js (1)

4-14: LGTM: Well-structured remark plugin with room for improvement.

The remarkBudoux function is well-implemented and follows the standard remark plugin pattern. It correctly uses the Budoux library to process Japanese text and updates the AST accordingly.

However, consider adding a configuration option to allow users to specify which text should be processed. This would make the plugin more flexible and prevent unnecessary processing of non-Japanese text.

Here's a suggested improvement:

-export default function remarkBudoux() {
+export default function remarkBudoux(options = {}) {
+  const { shouldProcess = () => true } = options;
   const parser = budoux.loadDefaultJapaneseParser();
   return (tree) => {
     visit(tree, 'text', (node) => {
-      if (node.value.trim()) {
+      if (node.value.trim() && shouldProcess(node.value)) {
         node.value = parser.translateHTMLString(node.value);
         node.type = 'html';
       }
     });
   };
 }

This change allows users to provide a shouldProcess function in the options to determine which text nodes should be processed.

astro.config.mjs (3)

14-26: LGTM! Consider documenting the new plugins.

The addition of @playform/compress and @playform/inline plugins is a good step towards optimizing the site's performance. The configuration for the compress plugin looks comprehensive, covering CSS, HTML, JavaScript, and SVG.

Consider adding a brief comment explaining the purpose and benefits of these new plugins for future reference and maintainability.


31-37: LGTM! Consider documenting the new markdown plugins.

The addition of new remark and rehype plugins enhances the markdown processing capabilities. The remarkBudoux plugin is likely for improved Japanese text processing, while wrapH2WithSection suggests better HTML structure for headings.

Consider adding brief comments explaining the purpose of each new plugin, especially remarkBudoux and wrapH2WithSection, to improve maintainability and understanding for future developers.


1-37: Overall, good improvements to the Astro configuration.

The changes to astro.config.mjs focus on performance optimization and enhanced markdown processing. The addition of compression and inlining plugins, along with new markdown processors, should improve the site's performance and content handling.

However, there are a few points to address:

  1. Ensure all new imported modules in the tools directory exist and are correctly implemented.
  2. Consider adding documentation for the new plugins and integrations to improve maintainability.
  3. Clarify the reasoning behind removing all Vite plugins, as this could have significant implications on the build process.

These changes have the potential to greatly enhance the project, but careful testing should be done to ensure everything works as expected, especially with the new plugins and changed Vite configuration.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c55b2e8 and b721584.

⛔ Files ignored due to path filters (1)
  • tools/remark-budoux/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • astro.config.mjs (1 hunks)
  • src/components/BaseHead.astro (2 hunks)
  • src/components/Header.astro (2 hunks)
  • src/components/Icon/OutowardIcon.astro (1 hunks)
  • tools/remark-budoux/index.js (1 hunks)
  • tools/remark-budoux/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tools/remark-budoux/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/BaseHead.astro
  • src/components/Header.astro
🔇 Additional comments (4)
src/components/Icon/OutowardIcon.astro (1)

1-3: LGTM: Proper use of Astro.props

The frontmatter correctly uses Astro.props to accept properties, allowing for flexible customization of the icon component.

tools/remark-budoux/index.js (1)

1-2: LGTM: Appropriate imports for the plugin functionality.

The import statements are correct and necessary for the plugin's functionality. The unist-util-visit library is commonly used in remark plugins for AST traversal, and the budoux library is essential for Japanese text processing.

astro.config.mjs (2)

27-27: LGTM! Good URL configuration.

Setting trailingSlash to 'never' is a good practice. It ensures URL consistency across the site, which can be beneficial for SEO and user experience.


28-30: Clarify the removal of Vite plugins.

The vite.plugins array is now empty. Can you provide more context on why the previous plugins were removed? Are their functionalities now handled by other parts of the configuration or are they no longer needed?

Let's check if there are any Vite-related imports or configurations elsewhere in the project:

This will help us understand if Vite configurations have been moved elsewhere in the project.

✅ Verification successful

Verify if Vite is still a project dependency.

To ensure that removing the Vite plugins doesn't impact the project, let's check if Vite is listed as a dependency in package.json:


Vite plugins removal is appropriate.

Since Vite is not listed in the project's dependencies or devDependencies and no Vite configurations or imports are found elsewhere in the project, removing the vite.plugins array in astro.config.mjs does not impact the build process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for Vite-related configurations in the project

# Test: Search for Vite-related imports or configurations
echo "Searching for Vite-related imports or configurations:"
rg --type js --type ts "import.*from 'vite'" || echo "No Vite imports found."
rg --type js --type ts "vite.*config" || echo "No Vite configurations found."

Length of output: 333


Script:

#!/bin/bash
# Description: Check if Vite is listed in dependencies or devDependencies in package.json

echo "Checking for Vite in dependencies:"
grep -E '"vite":' package.json || echo "Vite not found in dependencies."

echo "Checking for Vite in devDependencies:"
grep -E '"vite":' package.json || echo "Vite not found in devDependencies."

Length of output: 381

Comment on lines +7 to +11
visit(tree, 'text', (node) => {
if (node.value.trim()) {
node.value = parser.translateHTMLString(node.value);
node.type = 'html';
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider adding a check for Japanese text.

The current implementation processes all non-empty text nodes, which might include non-Japanese text. This could lead to unnecessary processing and potential issues with other languages.

Consider adding a check to ensure only Japanese text is processed. You could use a regular expression or a more sophisticated method to detect Japanese characters. Here's a simple example using a regular expression:

 visit(tree, 'text', (node) => {
-  if (node.value.trim()) {
+  if (node.value.trim() && /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]/.test(node.value)) {
     node.value = parser.translateHTMLString(node.value);
     node.type = 'html';
   }
 });

This regex checks for the presence of Japanese characters in the text before processing it.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
visit(tree, 'text', (node) => {
if (node.value.trim()) {
node.value = parser.translateHTMLString(node.value);
node.type = 'html';
}
visit(tree, 'text', (node) => {
if (node.value.trim() && /[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]/.test(node.value)) {
node.value = parser.translateHTMLString(node.value);
node.type = 'html';
}

Comment on lines +5 to +8
import codeBlockPlugin from "./tools/remark-code-quote";
import wrapH2WithSection from "./tools/rehype-wrap-h2-with-section";
import { astroLastModifiedAt } from "./tools/remark-astro-last-modified-at";
import remarkBudoux from "./tools/remark-budoux";
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Imported modules are missing from the tools directory.

The imports in astro.config.mjs (lines 5-8) reference modules that do not exist:

  • ./tools/remark-code-quote.js
  • ./tools/rehype-wrap-h2-with-section.js
  • ./tools/remark-astro-last-modified-at.js
  • ./tools/remark-budoux.js

Please ensure these modules are present in the tools directory and correctly implemented to avoid runtime errors.

🔗 Analysis chain

Verify the existence and implementation of imported modules.

The new imports for custom plugins look good and follow a consistent naming convention. However, we need to ensure that these modules exist and are correctly implemented.

Let's run a script to check for the existence and basic structure of these files:

Please ensure that all these files exist in the tools directory and contain the necessary exports.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and basic structure of the imported modules

# Test: Check if the files exist and contain expected content
for file in "tools/remark-code-quote.js" "tools/rehype-wrap-h2-with-section.js" "tools/remark-astro-last-modified-at.js" "tools/remark-budoux.js"; do
  if [ -f "$file" ]; then
    echo "File $file exists."
    grep -q "export default" "$file" && echo "  - Contains default export." || echo "  - Warning: No default export found."
  else
    echo "Warning: File $file does not exist."
  fi
done

Length of output: 1297

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

🧹 Outside diff range and nitpick comments (1)
package.json (1)

40-44: Approve new dependencies and suggest documentation updates.

The addition of new dependencies (@playform/compress, @playform/inline, astro-google-fonts-optimizer, and unist-util-visit) indicates the introduction of asset optimization, font performance improvements, and potentially enhanced markdown processing capabilities to the project. These are positive additions that should improve the overall performance and functionality of the application.

To ensure smooth integration of these new features:

  1. Update the project documentation to reflect the new capabilities these dependencies provide.
  2. Consider adding usage examples or configuration guidelines for these new packages in the README or relevant documentation files.

Would you like assistance in drafting documentation updates for these new dependencies?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 42e15d0 and 1e4041b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • tools/rehype-wrap-h2-with-section/package.json (1 hunks)
  • tools/remark-budoux/package.json (1 hunks)
  • tools/remark-code-quote/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • tools/rehype-wrap-h2-with-section/package.json
  • tools/remark-budoux/package.json
  • tools/remark-code-quote/package.json
🔇 Additional comments (3)
package.json (3)

Line range hint 1-44: Overall package.json updates look great!

The changes to package.json reflect a significant update to the project's dependencies and development workflow. The script renaming, dependency updates, and new additions all contribute to improved maintainability, performance, and potentially new features. These changes align well with modern development practices and should positively impact the project.

Key points:

  1. Script names have been standardized for better clarity.
  2. DevDependencies have been updated, including major version bumps for some packages.
  3. New dependencies have been added for asset optimization and font performance.

These updates set a good foundation for future development and optimization efforts.


25-39: Approve dependency updates and suggest changelog review.

The updates to the devDependencies are beneficial for security and feature improvements. The addition of "@astrojs/check" is a positive step towards better type checking in the project.

Please review the changelogs of the updated packages, especially for major version bumps like "@astrojs/mdx" (2.3.1 to 4.0.0-beta.1) and "astro" (4.7.0 to 5.0.0-beta.2), to ensure there are no breaking changes that might affect your project. Run the following script to fetch the latest versions and changelogs:


16-17: Approve script renaming and suggest verification.

The renaming of "prettier:fix" to "format" and "prettier:check" to "format:check" is a good practice for standardizing script names. This change improves clarity and aligns with common conventions.

Please ensure that any CI/CD pipelines, documentation, or other scripts that may have referenced the old script names are updated accordingly. Run the following script to check for any remaining references to the old script names:

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: 2

🧹 Outside diff range and nitpick comments (3)
src/styles/global.css (2)

10-12: Consider removing redundant word-wrap property

The word-wrap property is an alias for overflow-wrap and is now considered obsolete. Since you've specified overflow-wrap: break-word;, you can safely remove word-wrap: break-word; to clean up the code.

Suggested change:

  background-color: var(--bg-light);
- word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.8;

96-97: Remove commented out code

The commented-out background-color properties can be removed to keep the stylesheet clean and maintainable.

Suggested change:

.code-block-title::after {
-  /* background-color: red; */
-  /* background-color: var(--bg-light); */
   position: absolute;
src/pages/blog/index.astro (1)

45-50: Simplify date formatting for improved readability

Currently, the date formatting uses toLocaleDateString followed by .split("/").join("-"). This approach can be simplified for better readability and maintainability.

Consider using Intl.DateTimeFormat for more control over the date format:

{new Intl.DateTimeFormat("ja-JP", {
  month: "2-digit",
  day: "2-digit",
}).format(post.data.pubDate).replace(/\//g, "-")}

Alternatively, manually format the date:

{`${String(post.data.pubDate.getMonth() + 1).padStart(2, '0')}-${String(post.data.pubDate.getDate()).padStart(2, '0')}`}

This avoids the need to manipulate the string after formatting.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1e4041b and a5c38da.

📒 Files selected for processing (3)
  • src/pages/blog/[...slug].astro (1 hunks)
  • src/pages/blog/index.astro (1 hunks)
  • src/styles/global.css (3 hunks)
🔇 Additional comments (4)
src/pages/blog/[...slug].astro (1)

7-11: 🛠️ Refactor suggestion

Ensure robust post retrieval, but consider performance implications.

The change in the props assignment improves the reliability of fetching the correct post data. However, there are a few points to consider:

  1. This approach introduces a slight performance overhead by searching the posts array for each post.
  2. There's a potential edge case where find might return undefined if no matching post is found.

To address these concerns, consider the following improvement:

 export async function getStaticPaths() {
   const posts = await getCollection("blog");
+  const postMap = new Map(posts.map(post => [post.slug, post]));
   return posts.map((post) => ({
     params: { slug: post.slug },
-    props: posts.find((x) => x.slug === post.slug),
+    props: postMap.get(post.slug) || post,
   }));
 }

This approach:

  1. Creates a Map for O(1) lookup, improving performance.
  2. Falls back to the original post if not found in the Map, preventing undefined props.
  3. Maintains the intent of ensuring the correct post is used.

To ensure this change doesn't introduce any regressions, please verify:

  1. All blog posts are still accessible.
  2. The correct content is displayed for each blog post.
src/styles/global.css (1)

126-136: ⚠️ Potential issue

Correct invalid CSS syntax: Replace & with the appropriate selector

The & symbol is used in CSS preprocessors like SASS or LESS but is not valid in standard CSS. Since this is a .css file, you should replace &::before with section.section::before to ensure valid CSS syntax.

Suggested change:

-      &::before {
+      section.section::before {
         content: "";
         z-index: -1;
         position: absolute;
         top: 4.5rem;
         right: 0;
         bottom: 0;
         left: 0;
         border-radius: 20px;
         background: var(--b);
       }

Likely invalid or redundant comment.

src/pages/blog/index.astro (2)

71-71: Verify browser compatibility of color-mix CSS function

The color-mix CSS function is part of the CSS Color Module Level 5 specification and may not be fully supported in all browsers. Using it without fallbacks could lead to inconsistent styling across different browsers.

Consider checking browser support and providing a fallback or using a more widely supported method for background color blending.


69-79: Ensure CSS nesting is properly supported or preprocessed

The CSS code uses nested selectors with the & combinator (e.g., &:hover and & .timeline), which is part of the CSS Nesting Module Level 3 draft and is not widely supported in browsers yet.

Make sure that your build process includes a CSS preprocessor (like PostCSS with a nesting plugin) to compile nested CSS into standard CSS, or refactor the styles to avoid nesting:

.bloglink:hover .timeline {
  /* styles */
}

This ensures compatibility across all browsers without relying on experimental features.

Comment on lines +143 to +145
& > article > *:not(.section, .title, hr) {
padding: 0rem 2rem;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct invalid CSS syntax: Replace & with the appropriate selector

Similar to the previous issue, the & symbol should be replaced with main.blog or the appropriate parent selector in standard CSS.

Suggested change:

-    & > article > *:not(.section, .title, hr) {
+    main.blog > article > *:not(.section, .title, hr) {
       padding: 0rem 2rem;
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
& > article > *:not(.section, .title, hr) {
padding: 0rem 2rem;
}
main.blog > article > *:not(.section, .title, hr) {
padding: 0rem 2rem;
}

Comment on lines +33 to +37
{
posts.filter(
(p) => p.data.pubDate.getFullYear() === post.data.pubDate.getFullYear()
).length
}{" "}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize post count calculation for better performance

The current code filters the entire posts array inside the map function to count the number of posts for each year. This can lead to performance issues with a large number of posts, as it performs redundant operations on each iteration.

Consider precomputing the number of posts per year before the map function.

Here's how you might implement it:

// Precompute the number of posts per year
const postsByYear = posts.reduce((acc, post) => {
  const year = post.data.pubDate.getFullYear();
  acc[year] = (acc[year] || 0) + 1;
  return acc;
}, {});

Then, in your JSX, you can use postsByYear to get the count without filtering:

- {
-   posts.filter(
-     (p) => p.data.pubDate.getFullYear() === post.data.pubDate.getFullYear()
-   ).length
- }{" "}
+ {postsByYear[post.data.pubDate.getFullYear()]}{" "}

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