Skip to content

Commit 47d9a90

Browse files
committed
build: require date prop, rm unwrap, use fallback
Make lastUpdatedDate prop for Docs and Tutorials layouts required, remove force unwrap with !, use lastUpdatedDate as fallback for intlLastEdit
1 parent 7f1fc36 commit 47d9a90

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

src/layouts/Docs.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,18 @@ export const docsComponents = {
206206
YouTube,
207207
}
208208

209-
interface DocsLayoutProps
210-
extends Pick<
211-
MdPageContent,
212-
| "slug"
213-
| "tocItems"
214-
| "lastUpdatedDate"
215-
| "crowdinContributors"
216-
| "contentNotTranslated"
217-
>,
218-
ChildOnlyProp {
219-
frontmatter: DocsFrontmatter
220-
}
209+
type DocsLayoutProps = Pick<
210+
MdPageContent,
211+
| "slug"
212+
| "tocItems"
213+
| "lastUpdatedDate"
214+
| "crowdinContributors"
215+
| "contentNotTranslated"
216+
> &
217+
Required<Pick<MdPageContent, "lastUpdatedDate">> &
218+
ChildOnlyProp & {
219+
frontmatter: DocsFrontmatter
220+
}
221221

222222
export const DocsLayout = ({
223223
children,
@@ -233,7 +233,8 @@ export const DocsLayout = ({
233233
const absoluteEditPath = getEditPath(relativePath)
234234

235235
const gitHubLastEdit = useClientSideGitHubLastEdit(relativePath)
236-
const intlLastEdit = "data" in gitHubLastEdit ? gitHubLastEdit.data! : ""
236+
const intlLastEdit =
237+
"data" in gitHubLastEdit ? gitHubLastEdit.data : lastUpdatedDate
237238
const useGitHubContributors =
238239
frontmatter.lang === DEFAULT_LOCALE || crowdinContributors.length === 0
239240

@@ -252,7 +253,7 @@ export const DocsLayout = ({
252253
{useGitHubContributors ? (
253254
<GitHubContributors
254255
relativePath={relativePath}
255-
lastUpdatedDate={lastUpdatedDate!}
256+
lastUpdatedDate={lastUpdatedDate}
256257
/>
257258
) : (
258259
<CrowdinContributors

src/layouts/Tutorial.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,15 @@ export const tutorialsComponents = {
165165
StyledDivider,
166166
YouTube,
167167
}
168-
interface TutorialLayoutProps
169-
extends ChildOnlyProp,
170-
Pick<
171-
MdPageContent,
172-
| "tocItems"
173-
| "lastUpdatedDate"
174-
| "crowdinContributors"
175-
| "contentNotTranslated"
176-
> {
177-
frontmatter: TutorialFrontmatter
178-
timeToRead: number
179-
}
168+
type TutorialLayoutProps = ChildOnlyProp &
169+
Pick<
170+
MdPageContent,
171+
"tocItems" | "crowdinContributors" | "contentNotTranslated"
172+
> &
173+
Required<Pick<MdPageContent, "lastUpdatedDate">> & {
174+
frontmatter: TutorialFrontmatter
175+
timeToRead: number
176+
}
180177

181178
export const TutorialLayout = ({
182179
children,
@@ -194,7 +191,8 @@ export const TutorialLayout = ({
194191
const postMergeBannerTranslationString =
195192
frontmatter.postMergeBannerTranslation as TranslationKey | null
196193
const gitHubLastEdit = useClientSideGitHubLastEdit(relativePath)
197-
const intlLastEdit = "data" in gitHubLastEdit ? gitHubLastEdit.data! : ""
194+
const intlLastEdit =
195+
"data" in gitHubLastEdit ? gitHubLastEdit.data! : lastUpdatedDate
198196
const useGitHubContributors =
199197
frontmatter.lang === DEFAULT_LOCALE || crowdinContributors.length === 0
200198

@@ -226,7 +224,7 @@ export const TutorialLayout = ({
226224
{useGitHubContributors ? (
227225
<GitHubContributors
228226
relativePath={relativePath}
229-
lastUpdatedDate={lastUpdatedDate!}
227+
lastUpdatedDate={lastUpdatedDate}
230228
/>
231229
) : (
232230
<CrowdinContributors

0 commit comments

Comments
 (0)