1
0
mirror of synced 2026-02-03 09:01:57 -05:00

Merge pull request #10225 from github/repo-sync

repo sync
This commit is contained in:
Octomerger Bot
2021-09-22 02:20:07 -04:00
committed by GitHub
2 changed files with 25 additions and 2 deletions

View File

@@ -2,6 +2,12 @@ import pick from 'lodash/pick'
import { createContext, useContext } from 'react'
import { FeaturedLink, getFeaturedLinksFromReq } from './ProductLandingContext'
export type LearningTrack = {
trackName?: string
prevGuide?: { href: string; title: string }
nextGuide?: { href: string; title: string }
}
export type TocItem = {
fullPath: string
title: string
@@ -16,6 +22,7 @@ export type TocLandingContextT = {
variant?: 'compact' | 'expanded'
featuredLinks: Record<string, Array<FeaturedLink>>
renderedPage: string
currentLearningTrack?: LearningTrack
}
export const TocLandingContext = createContext<TocLandingContextT | null>(null)
@@ -43,5 +50,6 @@ export const getTocLandingContextFromRequest = (req: any): TocLandingContextT =>
featuredLinks: getFeaturedLinksFromReq(req),
renderedPage: isEarlyAccess ? req.context.renderedPage : '',
currentLearningTrack: req.context.currentLearningTrack,
}
}

View File

@@ -9,10 +9,19 @@ import { useTranslation } from 'components/hooks/useTranslation'
import { ArticleGridLayout } from 'components/article/ArticleGridLayout'
import { Callout } from 'components/ui/Callout'
import { Lead } from 'components/ui/Lead'
import { LearningTrackNav } from '../article/LearningTrackNav'
export const TocLanding = () => {
const { title, introPlainText, tocItems, productCallout, variant, featuredLinks, renderedPage } =
useTocLandingContext()
const {
title,
introPlainText,
tocItems,
productCallout,
variant,
featuredLinks,
renderedPage,
currentLearningTrack,
} = useTocLandingContext()
const { t } = useTranslation('toc')
return (
@@ -58,6 +67,12 @@ export const TocLanding = () => {
<TableOfContents items={tocItems} variant={variant} />
</div>
</ArticleGridLayout>
{currentLearningTrack?.trackName ? (
<div className="mt-4">
<LearningTrackNav track={currentLearningTrack} />
</div>
) : null}
</div>
</DefaultLayout>
)