This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix: tested and verified the article data transformation #317
Merged
DanSnow
merged 2 commits into
main
from
SPMVP-6969-add-unit-test-for-karbon-to-test-data-transform
Jan 24, 2024
Merged
fix: tested and verified the article data transformation #317
DanSnow
merged 2 commits into
main
from
SPMVP-6969-add-unit-test-for-karbon-to-test-data-transform
Jan 24, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arielllin
suggested changes
Jan 12, 2024
Comment on lines
294
to
297
if (process.env.NODE_ENV === 'development') { | ||
ArticleSchema.parse(document) | ||
} | ||
const article = normalizeArticle(document as TypesenseArticleLike) |
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.
Comment on lines
322
to
324
if (process.env.NODE_ENV === 'development') { | ||
QueryArticleSchema.parse(data.article) | ||
} |
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.
如果驗證失敗的話會導致沒有 return article 直接顯示 500 error
Comment on lines
21
to
38
export const ArticleSchema = z.object({ | ||
authors: z.array(AuthorSchema), | ||
blurb: z.string(), | ||
cover: z.string(), | ||
desk: DeskSchema, | ||
featured: z.boolean(), | ||
id: z.string(), | ||
order: z.number(), | ||
pathnames: z.array(z.string()), | ||
plan: z.string(), | ||
published_at: z.number(), | ||
seo: z.string(), | ||
slug: z.string(), | ||
tags: z.array(DeskSchema), | ||
title: z.string(), | ||
updated_at: z.number(), | ||
}) | ||
export type Article = z.infer<typeof ArticleSchema> |
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.
cover
、seo
有可能會是 null
Comment on lines
10
to
18
export const AuthorSchema = z.object({ | ||
avatar: z.string(), | ||
bio: z.string(), | ||
full_name: z.string(), | ||
id: z.number(), | ||
location: z.string(), | ||
slug: z.string(), | ||
socials: z.string(), | ||
}) |
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.
bio
、location
、socials
有可能會是 null
arielllin
approved these changes
Jan 24, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added schema validation in dev, and when validation fails, access to the article page is denied.