Skip to content

Commit 44ba07f

Browse files
committed
feat: implement contributors and last edit date with layouts
1 parent 2efd969 commit 44ba07f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/layouts/Docs.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ import { getEditPath } from "@/lib/utils/editPath"
5151
// Utils
5252
import { DEFAULT_LOCALE } from "@/lib/constants"
5353

54-
import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"
55-
5654
const Page = (props: ChildOnlyProp & Pick<FlexProps, "dir">) => (
5755
<Flex
5856
direction="column"
@@ -206,6 +204,7 @@ type DocsLayoutProps = Pick<
206204
| "lastUpdatedDate"
207205
| "crowdinContributors"
208206
| "contentNotTranslated"
207+
| "contributors"
209208
> &
210209
Required<Pick<MdPageContent, "lastUpdatedDate">> &
211210
ChildOnlyProp & {
@@ -220,14 +219,15 @@ export const DocsLayout = ({
220219
lastUpdatedDate,
221220
crowdinContributors,
222221
contentNotTranslated,
222+
contributors,
223223
}: DocsLayoutProps) => {
224224
const isPageIncomplete = !!frontmatter.incomplete
225225
const { asPath: relativePath } = useRouter()
226226
const absoluteEditPath = getEditPath(relativePath)
227227

228-
const gitHubLastEdit = useClientSideGitHubLastEdit(relativePath)
229-
const intlLastEdit =
230-
"data" in gitHubLastEdit ? gitHubLastEdit.data : lastUpdatedDate
228+
const gitHubLastEdit = contributors[0]?.date
229+
const intlLastEdit = gitHubLastEdit || lastUpdatedDate
230+
231231
const useGitHubContributors =
232232
frontmatter.lang === DEFAULT_LOCALE || crowdinContributors.length === 0
233233

@@ -245,8 +245,8 @@ export const DocsLayout = ({
245245
<H1 id="top">{frontmatter.title}</H1>
246246
{useGitHubContributors ? (
247247
<GitHubContributors
248-
relativePath={relativePath}
249248
lastUpdatedDate={lastUpdatedDate}
249+
contributors={contributors}
250250
/>
251251
) : (
252252
<CrowdinContributors

src/layouts/Tutorial.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import { getEditPath } from "@/lib/utils/editPath"
4343

4444
import { DEFAULT_LOCALE } from "@/lib/constants"
4545

46-
import { useClientSideGitHubLastEdit } from "@/hooks/useClientSideGitHubLastEdit"
47-
4846
type ContentContainerProps = Pick<BoxProps, "children" | "dir">
4947

5048
const ContentContainer = (props: ContentContainerProps) => {
@@ -161,7 +159,7 @@ export const tutorialsComponents = {
161159
type TutorialLayoutProps = ChildOnlyProp &
162160
Pick<
163161
MdPageContent,
164-
"tocItems" | "crowdinContributors" | "contentNotTranslated"
162+
"tocItems" | "crowdinContributors" | "contentNotTranslated" | "contributors"
165163
> &
166164
Required<Pick<MdPageContent, "lastUpdatedDate">> & {
167165
frontmatter: TutorialFrontmatter
@@ -176,14 +174,15 @@ export const TutorialLayout = ({
176174
lastUpdatedDate,
177175
crowdinContributors,
178176
contentNotTranslated,
177+
contributors,
179178
}: TutorialLayoutProps) => {
180179
const { asPath: relativePath } = useRouter()
181180
const absoluteEditPath = getEditPath(relativePath)
182181

183182
const borderColor = useToken("colors", "border")
184-
const gitHubLastEdit = useClientSideGitHubLastEdit(relativePath)
185-
const intlLastEdit =
186-
"data" in gitHubLastEdit ? gitHubLastEdit.data! : lastUpdatedDate
183+
const gitHubLastEdit = contributors[0]?.date
184+
const intlLastEdit = gitHubLastEdit || lastUpdatedDate
185+
187186
const useGitHubContributors =
188187
frontmatter.lang === DEFAULT_LOCALE || crowdinContributors.length === 0
189188

@@ -209,7 +208,7 @@ export const TutorialLayout = ({
209208
{children}
210209
{useGitHubContributors ? (
211210
<GitHubContributors
212-
relativePath={relativePath}
211+
contributors={contributors}
213212
lastUpdatedDate={lastUpdatedDate}
214213
/>
215214
) : (

0 commit comments

Comments
 (0)