-
Notifications
You must be signed in to change notification settings - Fork 259
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
Add sanity blog #224
Add sanity blog #224
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce enhanced blog functionality with integration to a Sanity backend, allowing for dynamic data fetching and improved content management. New type definitions for posts and authors are established, along with utility functions for image handling and API interaction. Additionally, configurations for Sanity Studio are implemented, facilitating a streamlined authoring environment within the Next.js application. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant BlogPage
participant SanityAPI
participant Posts
participant PostCard
User->>BlogPage: Request blog page
BlogPage->>SanityAPI: Fetch posts
SanityAPI-->>BlogPage: Return posts
BlogPage->>Posts: Pass fetched posts
Posts->>PostCard: Render each post
PostCard-->>Posts: Display post content
Posts-->>BlogPage: Return rendered posts
BlogPage-->>User: Display blog page
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Outside diff range, codebase verification and nitpick comments (7)
apps/web/sanity/lib/fetch.ts (1)
12-42
: Refactor thesanityFetch
function to improve performance and readability.Consider applying the following improvements:
- Move the
DEFAULT_PARAMS
andDEFAULT_TAGS
constants outside the function to avoid creating them on every function call.- Move the
isDevelopment
constant outside the function to avoid creating it on every function call.- Move the
token
constant outside the function to avoid creating it on every function call.- Move the
isDraftMode
constant outside the function to avoid creating it on every function call.- Improve the error message to provide more context.
Here's the refactored code:
import "server-only"; import type { QueryParams } from "@sanity/client"; import { draftMode } from "next/headers"; import { client } from "./client"; +const DEFAULT_PARAMS = {} as QueryParams; +const DEFAULT_TAGS = [] as string[]; + +const token = process.env.SANITY_API_READ_TOKEN; +const isDevelopment = process.env.NODE_ENV === "development"; +const isDraftMode = draftMode().isEnabled; export async function sanityFetch<QueryResponse>({ query, params = DEFAULT_PARAMS, tags = DEFAULT_TAGS, }: { query: string; params?: QueryParams; tags?: string[]; }): Promise<QueryResponse> { - const isDraftMode = draftMode().isEnabled; if (isDraftMode && !token) { throw new Error( - "The `SANITY_API_READ_TOKEN` environment variable is required.", + "The `SANITY_API_READ_TOKEN` environment variable is required to fetch data in draft mode.", ); } - const isDevelopment = process.env.NODE_ENV === "development"; return client .withConfig({ useCdn: true }) .fetch<QueryResponse>(query, params, { cache: isDevelopment || isDraftMode ? undefined : "force-cache", ...(isDraftMode && { token: token, perspective: "previewDrafts", }), next: { ...(isDraftMode && { revalidate: 30 }), tags, }, }); }apps/web/sanity/schemaTypes/postType.ts (1)
4-65
: LGTM!The code changes are approved. The schema type is well-defined and covers the essential fields for a blog post.
Consider adding a field for SEO metadata (title, description, keywords) to optimize the blog post for search engines. You can define a new object type for SEO metadata and reference it in the post type. For example:
const seoMetadata = defineType({ name: 'seoMetadata', type: 'object', fields: [ defineField({ name: 'title', type: 'string', }), defineField({ name: 'description', type: 'text', }), defineField({ name: 'keywords', type: 'array', of: [{ type: 'string' }], }), ], }); // In the post type defineField({ name: 'seo', type: 'seoMetadata', }),apps/web/package.json (5)
49-49
: Use a version constraint that allows patch and minor updates.Consider using a version constraint like
^1.0.0
instead of1
for the@sanity/image-url
dependency. This allows patch and minor updates while ensuring the major version remains the same, reducing the risk of breakage due to major version changes.- "@sanity/image-url": "1", + "@sanity/image-url": "^1.0.0",
50-50
: Use a version constraint that allows patch and minor updates.Consider using a version constraint like
^3.0.0
instead of3
for the@sanity/vision
dependency. This allows patch and minor updates while ensuring the major version remains the same, reducing the risk of breakage due to major version changes.- "@sanity/vision": "3", + "@sanity/vision": "^3.0.0",
88-88
: Use a version constraint that allows patch and minor updates.Consider using a version constraint like
^9.0.0
instead of9
for thenext-sanity
dependency. This allows patch and minor updates while ensuring the major version remains the same, reducing the risk of breakage due to major version changes.- "next-sanity": "9", + "next-sanity": "^9.0.0",
105-105
: Use a version constraint that allows patch and minor updates.Consider using a version constraint like
^3.0.0
instead of3
for thesanity
dependency. This allows patch and minor updates while ensuring the major version remains the same, reducing the risk of breakage due to major version changes.- "sanity": "3", + "sanity": "^3.0.0",
108-108
: Use a version constraint that allows patch and minor updates.Consider using a version constraint like
^6.0.0
instead of6
for thestyled-components
dependency. This allows patch and minor updates while ensuring the major version remains the same, reducing the risk of breakage due to major version changes.- "styled-components": "6", + "styled-components": "^6.0.0",
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (17)
- apps/web/app/blog/page.tsx (3 hunks)
- apps/web/app/studio/[[...tool]]/page.tsx (1 hunks)
- apps/web/package.json (3 hunks)
- apps/web/sanity.cli.ts (1 hunks)
- apps/web/sanity.config.ts (1 hunks)
- apps/web/sanity/env.ts (1 hunks)
- apps/web/sanity/lib/client.ts (1 hunks)
- apps/web/sanity/lib/fetch.ts (1 hunks)
- apps/web/sanity/lib/image.ts (1 hunks)
- apps/web/sanity/lib/queries.ts (1 hunks)
- apps/web/sanity/schemaTypes/authorType.ts (1 hunks)
- apps/web/sanity/schemaTypes/blockContentType.ts (1 hunks)
- apps/web/sanity/schemaTypes/categoryType.ts (1 hunks)
- apps/web/sanity/schemaTypes/index.ts (1 hunks)
- apps/web/sanity/schemaTypes/postType.ts (1 hunks)
- apps/web/sanity/structure.ts (1 hunks)
- apps/web/tsconfig.json (1 hunks)
Files skipped from review due to trivial changes (1)
- apps/web/sanity.cli.ts
Additional context used
Biome
apps/web/sanity/schemaTypes/index.ts
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
apps/web/sanity/lib/image.ts
[error] 1-2: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
apps/web/sanity/structure.ts
[error] 15-15: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
Additional comments not posted (30)
apps/web/sanity/lib/client.ts (1)
1-10
: LGTM!The code changes are approved for the following reasons:
- The file is correctly creating and exporting a Sanity client using the
createClient
function from thenext-sanity
library.- The client is configured using the
projectId
,dataset
, andapiVersion
variables imported from../env
, which is a good practice to keep the configuration separate from the code.- The
useCdn
option is set totrue
, which is appropriate for most use cases. The comment provides clear guidance on when to set it tofalse
.- The file is small and focused, following the Single Responsibility Principle.
apps/web/sanity/schemaTypes/index.ts (1)
8-10
: LGTM!The schema object is correctly defined and exported.
apps/web/sanity/lib/image.ts (1)
1-11
: LGTM!The code changes are approved.
Tools
Biome
[error] 1-2: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
apps/web/tsconfig.json (1)
10-10
: LGTM!The code change is approved.
apps/web/sanity/schemaTypes/categoryType.ts (4)
1-2
: LGTM!The import statements are correct and necessary for defining the schema type.
4-8
: LGTM!The
categoryType
constant is correctly defined using thedefineType
function from Sanity. The name, title, type, and icon are appropriately set for a category schema type.
10-20
: LGTM!The
title
andslug
fields are correctly defined using thedefineField
function from Sanity. Theslug
field is appropriately configured to generate the slug from thetitle
field.
21-24
: LGTM!The
description
field is correctly defined using thedefineField
function from Sanity.apps/web/sanity/env.ts (3)
1-2
: Verify the default value forapiVersion
.The default value for
apiVersion
is set to"2024-09-03"
, which seems to be a future date. Please ensure that this is the intended default value.
4-7
: LGTM!The code changes are approved.
9-20
: LGTM!The code changes are approved.
apps/web/sanity/lib/queries.ts (3)
4-11
: LGTM!The
postsQuery
looks good and is fetching relevant fields for displaying a list of posts. The computed fieldsimageURL
andauthorName
are correctly fetching fields from the referenced documents.
14-16
: LGTM!The
postQuery
looks good and is fetching relevant fields for displaying a single post. The[0]
at the end of the query is correctly ensuring that only the first matching document is returned.
19-21
: LGTM!The
postPathsQuery
looks good and is correctly fetching theslug.current
field for generating dynamic paths for post pages. Thedefined()
function is ensuring that only documents with a definedslug.current
field are returned.apps/web/sanity/structure.ts (1)
1-17
: LGTM!The file is well-structured and follows the Sanity Studio structure builder cheat sheet. The code changes are approved with the minor change to remove the non-null assertion operator.
Tools
Biome
[error] 15-15: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
apps/web/app/studio/[[...tool]]/page.tsx (1)
1-19
: LGTM!The code changes are approved. The file is well-structured, follows best practices, and has no apparent issues. The code is clean, easy to understand, and the comments provide a clear explanation of the file's purpose and functionality. The imports and exports are used correctly, and the
NextStudio
component is used with the correct configuration.apps/web/sanity.config.ts (2)
7-14
: LGTM!The imports are correctly used in the file to configure Sanity Studio.
16-28
: LGTM!The configuration object for Sanity Studio is correctly defined with the following properties:
basePath
: The base path for the Sanity Studio.projectId
: The project ID for the Sanity project.dataset
: The dataset to use for the Sanity project.schema
: The schema definition for the Sanity project.plugins
: An array of plugins to use in the Sanity Studio.The configuration object is using good practices such as:
- Keeping the configuration separate from the code by importing the
projectId
anddataset
from./sanity/env
.- Keeping the schema definition separate from the configuration by importing the
schema
from./sanity/schemaTypes
.- Using the
structureTool
plugin to configure the structure of the Sanity Studio.- Using the
visionTool
plugin to query the data using GROQ from inside the Sanity Studio.apps/web/sanity/schemaTypes/authorType.ts (1)
4-46
: LGTM!The schema definition for the author type is well-structured and follows the Sanity schema definition conventions. The field types are appropriately chosen for their respective purposes, and the preview configuration provides a meaningful preview of the author document in the Sanity Studio.
apps/web/sanity/schemaTypes/postType.ts (1)
1-3
: LGTM!The code changes are approved.
apps/web/sanity/schemaTypes/blockContentType.ts (3)
1-2
: LGTM!The code changes are approved.
4-13
: LGTM!The code changes are approved.
15-76
: LGTM!The code changes are approved.
apps/web/package.json (2)
47-47
: LGTM!The
@sanity/client
dependency is required for interacting with the Sanity APIs. The version constraint looks good.
48-48
: LGTM!The
@sanity/icons
dependency is useful for integrating Sanity's icons into the project. The version constraint looks good.apps/web/app/blog/page.tsx (5)
3-8
: LGTM!The code changes are approved.
10-17
: LGTM!The code changes are approved.
191-195
: LGTM!The code changes are approved.
Line range hint
200-230
: LGTM!The code changes are approved.
239-287
: LGTM!The code changes are approved.
import { type SchemaTypeDefinition } from "sanity"; | ||
|
||
import { blockContentType } from "./blockContentType"; | ||
import { categoryType } from "./categoryType"; | ||
import { postType } from "./postType"; | ||
import { authorType } from "./authorType"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use import type
for type-only imports.
The imports are only used as types. Using import type
ensures that the imports are removed by the transpilers and avoids loading unnecessary modules.
Apply this diff to use import type
:
-import { type SchemaTypeDefinition } from "sanity";
+import type { SchemaTypeDefinition } from "sanity";
-import { blockContentType } from "./blockContentType";
-import { categoryType } from "./categoryType";
-import { postType } from "./postType";
-import { authorType } from "./authorType";
+import type { blockContentType } from "./blockContentType";
+import type { categoryType } from "./categoryType";
+import type { postType } from "./postType";
+import type { authorType } from "./authorType";
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.
import { type SchemaTypeDefinition } from "sanity"; | |
import { blockContentType } from "./blockContentType"; | |
import { categoryType } from "./categoryType"; | |
import { postType } from "./postType"; | |
import { authorType } from "./authorType"; | |
import type { SchemaTypeDefinition } from "sanity"; | |
import type { blockContentType } from "./blockContentType"; | |
import type { categoryType } from "./categoryType"; | |
import type { postType } from "./postType"; | |
import type { authorType } from "./authorType"; |
Tools
Biome
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
import createImageUrlBuilder from "@sanity/image-url"; | ||
import { SanityImageSource } from "@sanity/image-url/lib/types/types"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use import type
for the imports that are only used as types.
The imports createImageUrlBuilder
and SanityImageSource
are only used as types in this file.
Apply this diff to use import type
for these imports:
-import createImageUrlBuilder from "@sanity/image-url";
-import { SanityImageSource } from "@sanity/image-url/lib/types/types";
+import type { SanityImageSource } from "@sanity/image-url/lib/types/types";
+import type createImageUrlBuilder from "@sanity/image-url";
Using import type
ensures that the imports are removed by the transpilers and avoids loading unnecessary modules.
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.
import createImageUrlBuilder from "@sanity/image-url"; | |
import { SanityImageSource } from "@sanity/image-url/lib/types/types"; | |
import type { SanityImageSource } from "@sanity/image-url/lib/types/types"; | |
import type createImageUrlBuilder from "@sanity/image-url"; |
Tools
Biome
[error] 1-2: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
...S.documentTypeListItems().filter( | ||
(item) => | ||
item.getId() && | ||
!["post", "category", "author"].includes(item.getId()!), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the non-null assertion operator.
The non-null assertion operator (!
) is unnecessary and can be removed.
Apply this diff to remove the non-null assertion operator:
- !["post", "category", "author"].includes(item.getId()!),
+ !["post", "category", "author"].includes(item.getId()),
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.
!["post", "category", "author"].includes(item.getId()!), | |
!["post", "category", "author"].includes(item.getId()), |
Tools
Biome
[error] 15-15: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
@@ -0,0 +1,28 @@ | |||
"use client"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the "use client" directive.
The "use client" directive is used in Next.js 13 to mark a file as a Client Component. However, this file is a configuration file for Sanity Studio and not a React component. Therefore, the directive is not needed and should be removed.
-"use client";
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.
"use client"; |
There was a problem hiding this 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, codebase verification and nitpick comments (1)
apps/web/app/blog/page.tsx (1)
4-6
: Useimport type
for type-only imports.The static analysis tool suggests using
import type
for the following imports:-import { sanityFetch } from "@/sanity/lib/fetch"; -import { postsQuery } from "@/sanity/lib/queries"; -import { Post as PostType } from "@/app/blog/types"; +import type { Post as PostType } from "@/app/blog/types"; +import { sanityFetch } from "@/sanity/lib/fetch"; +import { postsQuery } from "@/sanity/lib/queries";Using
import type
ensures that the types are removed by the transpilers and avoids loading unnecessary modules.Tools
Biome
[error] 5-6: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (9)
- apps/web/app/blog/components/Prose.tsx (1 hunks)
- apps/web/app/blog/page.tsx (3 hunks)
- apps/web/app/blog/post/[slug]/Post.tsx (1 hunks)
- apps/web/app/blog/post/[slug]/page.tsx (1 hunks)
- apps/web/app/blog/types.ts (1 hunks)
- apps/web/next.config.mjs (1 hunks)
- apps/web/package.json (4 hunks)
- apps/web/sanity/lib/queries.ts (1 hunks)
- apps/web/sanity/schemaTypes/postType.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- apps/web/app/blog/components/Prose.tsx
Files skipped from review as they are similar to previous changes (3)
- apps/web/package.json
- apps/web/sanity/lib/queries.ts
- apps/web/sanity/schemaTypes/postType.ts
Additional context used
Biome
apps/web/app/blog/types.ts
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
apps/web/app/blog/post/[slug]/page.tsx
[error] 16-16: Unexpected any. Specify a different type.
any disables many type checking rules. Its use should be avoided.
(lint/suspicious/noExplicitAny)
apps/web/app/blog/page.tsx
[error] 5-6: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
Additional comments not posted (14)
apps/web/app/blog/types.ts (1)
3-15
: LGTM!The
Post
type definition clearly defines the structure of a blog post with appropriate types for each property. The optional properties are correctly marked with| null
.apps/web/app/blog/post/[slug]/page.tsx (3)
1-5
: LGTM!The code changes are approved.
7-7
: LGTM!The code changes are approved.
9-12
: LGTM!The code changes are approved.
apps/web/app/blog/post/[slug]/Post.tsx (5)
1-10
: LGTM!The imports and type definitions are good:
- The "use client" directive is used correctly for a client component.
- The necessary dependencies are imported, including Next.js Image component, Sanity client, and custom components.
- The custom
Post
type improves type safety.
11-11
: LGTM!The
builder
constant is correctly set up using theimageUrlBuilder
function from the Sanity library. It will be used later in the component to generate image URLs.
13-35
: LGTM!The
Post
component is well-structured and properly renders the blog post:
- It takes a
post
prop of typePostType
to receive the post data.- It uses the
BasicLayout
component for consistent layout.- The post title, description, and body are rendered within the
Prose
component.
21-28
: LGTM!The image rendering logic is implemented correctly:
- It conditionally renders the image only if
post.mainImage
exists.- The
builder
is used to generate the image URL with the specified width and height.- The
alt
text is set usingpost.mainImage.alt
for accessibility.
29-29
: LGTM!The portable text rendering is implemented correctly:
- It conditionally renders the
post.body
only if it exists.- The
PortableText
component from the@portabletext/react
library is used to render the rich text content from Sanity.apps/web/next.config.mjs (1)
38-41
: LGTM!The code changes are approved.
Adding the "cdn.sanity.io" domain to the
images.domains
array allows images to be served from Sanity, a headless CMS. This change aligns with the PR objective of adding a Sanity blog and enables the application to fetch and display images stored in Sanity.By specifying the protocol as "https", the configuration ensures that images are securely loaded over HTTPS, which is a best practice for web applications.
Overall, this is a necessary configuration change to support the integration with Sanity for the blog functionality.
apps/web/app/blog/page.tsx (4)
8-15
: LGTM!The
Post
type definition looks good. It provides a clear structure for the blog post data with fields for title, file, description, date, datetime, and author.
195-199
: LGTM!The changes in the
BlogPage
component look good:
- Making it an async function allows for data fetching from Sanity.
- The
sanityFetch
function andpostsQuery
are used correctly to fetch the posts.- Passing the fetched posts to the
Posts
component ensures dynamic rendering of the blog posts.
204-220
: LGTM!The changes in the
Posts
component look good:
- Accepting the
posts
prop allows the component to handle both fetched and static posts.- Combining the fetched posts and static posts into
allPosts
ensures all posts are rendered.- Mapping
allPosts
toPostCard
components provides a clean and reusable way to render each post.
243-291
: LGTM!The
PostCard
component looks good:
- Extracting the post rendering logic into a separate component improves code organization and reusability.
- The component correctly handles the
post
prop and renders the necessary post information.- The link to the full post is correctly generated using the
post.file
field.
@@ -0,0 +1,15 @@ | |||
import { PortableTextBlock } from "next-sanity"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use import type
for type-only imports.
The PortableTextBlock
import is only used as a type.
Use import type
to ensure that the import is removed by the transpilers and avoids loading unnecessary modules:
-import { PortableTextBlock } from "next-sanity";
+import type { PortableTextBlock } from "next-sanity";
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.
import { PortableTextBlock } from "next-sanity"; | |
import type { PortableTextBlock } from "next-sanity"; |
Tools
Biome
[error] 1-1: All these imports are only used as types.
Importing the types with import type ensures that they are removed by the transpilers and avoids loading unnecessary modules.
Safe fix: Use import type.(lint/style/useImportType)
export default async function Page({ params }: { params: any }) { | ||
const post = await sanityFetch<PostType>({ query: postQuery, params }); | ||
|
||
return <Post post={post} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the any
type for the params
prop.
The static analysis tool Biome has flagged an error for using any
type for the params
prop.
any
disables many type checking rules. Its use should be avoided.
You can fix this by specifying a more specific type for the params
prop.
For example, you can define a type for the params
prop like this:
type PageParams = {
slug: string;
};
Then, update the Page
component to use the PageParams
type:
-export default async function Page({ params }: { params: any }) {
+export default async function Page({ params }: { params: PageParams }) {
Tools
Biome
[error] 16-16: Unexpected any. Specify a different type.
any disables many type checking rules. Its use should be avoided.
(lint/suspicious/noExplicitAny)
There was a problem hiding this 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
Files selected for processing (1)
- apps/web/app/blog/post/[slug]/page.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- apps/web/app/blog/post/[slug]/page.tsx
There was a problem hiding this 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, codebase verification and nitpick comments (1)
apps/web/.env.example (1)
88-90
: LGTM!The code changes are approved. The commented-out environment variables are correctly defined and follow the naming convention for environment variables.
Consider adding a comment above the commented-out variables to provide more context about their intended purpose and usage. For example:
+# Environment variables for configuring Sanity Studio (uncomment and set values when needed) # SANITY_STUDIO_PROJECT_ID= # SANITY_STUDIO_DATASET=production # SANITY_STUDIO_HOST=
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (11)
- .gitignore (1 hunks)
- README.md (1 hunks)
- apps/web/.env.example (1 hunks)
- apps/web/package.json (4 hunks)
- apps/web/tsconfig.json (1 hunks)
- package.json (1 hunks)
- packages/eslint-config/package.json (1 hunks)
- packages/loops/package.json (1 hunks)
- packages/resend/package.json (1 hunks)
- packages/tinybird-ai-analytics/package.json (1 hunks)
- packages/tinybird/package.json (1 hunks)
Files skipped from review due to trivial changes (4)
- .gitignore
- packages/eslint-config/package.json
- packages/tinybird-ai-analytics/package.json
- packages/tinybird/package.json
Files skipped from review as they are similar to previous changes (1)
- apps/web/package.json
Additional context used
LanguageTool
README.md
[grammar] ~174-~174: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)?
Context: ...`` Set the following .env vars for the deploy to work: ```sh SANITY_STUDIO_PROJECT_I...(PREPOSITION_VERB)
Additional comments not posted (17)
packages/loops/package.json (2)
9-9
: LGTM!The update to the
@types/node
dependency looks good.
6-6
: Verify the impact of theloops
dependency version update.Ensure that the version update from
^3.1.1
to^3.2.0
is compatible with the existing codebase and does not introduce any breaking changes.Run the following script to verify the usage of the
loops
package:packages/resend/package.json (4)
9-9
: LGTM!The minor version update for
@react-email/components
dependency is approved.
17-17
: LGTM!The patch version update for
@types/node
dev dependency is approved.
18-18
: LGTM!The patch version update for
@types/react
dev dependency is approved.
13-13
: Verify the impact of the major version update.Ensure that the codebase is compatible with the breaking changes introduced in
react-email
version3.0.1
.Run the following script to verify the usage of
react-email
in the codebase:apps/web/tsconfig.json (2)
8-12
: LGTM!The code changes are approved.
13-13
: LGTM!The code changes are approved.
package.json (7)
16-16
: LGTM!The minor version update to
@biomejs/biome
is approved.
20-20
: LGTM!The major version update to
husky
is approved.
21-21
: LGTM!The patch version update to
lint-staged
is approved.
23-23
: LGTM!The minor version update to
turbo
is approved.
25-25
: LGTM!The minor version update to the package manager
pnpm
is approved.
17-17
: Verify the impact of the major version update to@turbo/gen
.Ensure that the update does not introduce any breaking changes that affect the application.
Run the following script to verify the dependency usage:
18-18
: Verify the impact of the major version update toeslint
and ensure linting compliance.
- Ensure that the update does not introduce any breaking changes that affect the application.
- Run the linter to ensure that the codebase complies with the updated linting rules.
Run the following script to verify the dependency usage and linting compliance:
apps/web/.env.example (1)
85-86
: LGTM!The code changes are approved. The new environment variables are correctly defined and follow the naming convention for public environment variables in Next.js.
README.md (1)
166-179
: LGTM!The new "Blog" section in the README provides clear instructions for deploying Sanity Studio and specifies the required environment variables. This is a valuable addition to the documentation.
Tools
LanguageTool
[grammar] ~174-~174: The word ‘deploy’ is a verb. Did you mean the noun “deployment” (= release, placement)?
Context: ...`` Set the following .env vars for the deploy to work: ```sh SANITY_STUDIO_PROJECT_I...(PREPOSITION_VERB)
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores