Skip to content
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

Refactor/app router refs #28095

Merged
merged 35 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift click to select a range
677a50c
wip: convert js ref to app router
charislam Jul 4, 2024
b617397
wip create navigation menu
charislam Jul 4, 2024
ae1006b
wip
charislam Jul 5, 2024
db16b91
wip start adding sections to js ref
charislam Jul 5, 2024
5caa4b0
wip add more to the refs page display
charislam Jul 8, 2024
4daa7ee
feat: process type spec
charislam Jul 10, 2024
2467047
test: add snapshot
charislam Jul 11, 2024
b114791
feat: display params for ref functions
charislam Jul 19, 2024
43c1e79
feat: add return types
charislam Jul 19, 2024
22b99e9
feat: add code examples
charislam Jul 20, 2024
ecf8d94
feat: scroll behavior
charislam Jul 20, 2024
457957b
fix: vercel non-included files?
charislam Jul 20, 2024
381d5c3
fix: build
charislam Jul 20, 2024
3f0e573
fix: pregenerate root reference page for sdks
charislam Jul 20, 2024
a3e4627
fix: tiny ux fixes
charislam Jul 20, 2024
badc579
test: build time
charislam Jul 21, 2024
d3fcb26
feat: crawler pages
charislam Jul 21, 2024
67b0dc1
fix: typecheck
charislam Jul 22, 2024
2d9ad33
refactor: migrate all sdk libraries
charislam Jul 22, 2024
3719a69
fix: index paths for crawler pages
charislam Jul 22, 2024
89571fc
perf: get build times down
charislam Jul 23, 2024
635a6fd
perf: build timing issues
charislam Jul 23, 2024
35d9c0c
test: speed with more pre-calculated data
charislam Jul 23, 2024
73328d6
test: speed when caching actual component
charislam Jul 23, 2024
782c9a6
test: perf with simpler crawler pages
charislam Jul 23, 2024
7e40c8d
feat: crawler content served by api
charislam Jul 23, 2024
422aacf
test: outputFileTrackingIncludes
charislam Jul 23, 2024
1ce0576
test: try outputfiletracing again?
charislam Jul 23, 2024
c6feb8b
test: add smoke tests for docs crawler routes
charislam Jul 23, 2024
802406a
fix: restore other ref sections
charislam Jul 23, 2024
7eeb6d5
perf: shave bundle size
charislam Jul 23, 2024
416fc43
fix: jankiness
charislam Jul 23, 2024
7343f31
fix: og image and crawler tests
charislam Jul 23, 2024
6af1eff
fix: minor cleanup
charislam Jul 23, 2024
761d1d6
fix: minor cleanup and code review suggestions
charislam Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: perf with simpler crawler pages
  • Loading branch information
charislam committed Aug 12, 2024
commit 782c9a62cc3868681bd7fc0eef59698a08f635a5
4 changes: 0 additions & 4 deletions apps/docs/app/reference/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 34,7 @@ export default async function ReferencePage({
return (
<ClientSdkReferencePage
sdkId={sdkId}
libId={sdkData.meta[version].libId}
libPath={sdkData.libPath}
libVersion={maybeVersion ?? latestVersion}
specFile={sdkData.meta[version].specFile}
useTypeSpec={sdkData.typeSpec ?? false}
isCrawlerPage={!!maybeCrawlers}
requestedSection={path[0]}
/>
Expand Down
33 changes: 12 additions & 21 deletions apps/docs/features/docs/Reference.sdkPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 1,12 @@
import { MenuId } from '~/components/Navigation/NavigationMenu/NavigationMenu'
import * as NavItems from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'
import { REFERENCES } from '~/content/navigation.references'
import { getFlattenedSections } from '~/features/docs/Reference.generated.singleton'
import { ClientLibHeader } from '~/features/docs/Reference.header'
import { ClientLibIntroduction, OldVersionAlert } from '~/features/docs/Reference.introduction'
import { ClientSdkNavigation } from '~/features/docs/Reference.navigation'
import { ReferenceContentScrollHandler } from '~/features/docs/Reference.navigation.client'
import { ClientLibRefSections } from '~/features/docs/Reference.sections'
import { ClientLibRefSections, SectionSwitch } from '~/features/docs/Reference.sections'
charislam marked this conversation as resolved.
Show resolved Hide resolved
import { LayoutMainContent } from '~/layouts/DefaultLayout'
import { SidebarSkeleton } from '~/layouts/MainSkeleton'

Expand All @@ -17,15 18,7 @@ type ClientSdkReferenceProps = {
| { isCrawlerPage: true; requestedSection: string }
)

const _clientSdkComponentCache = new Map<string, any>()
export async function ClientSdkReferencePage(props) {
const key = JSON.stringify(props)
if (!_clientSdkComponentCache.has(key)) {
_clientSdkComponentCache.set(key, ClientSdkReferencePageUncached(props))
}
return _clientSdkComponentCache.get(key)
}
async function ClientSdkReferencePageUncached({
export async function ClientSdkReferencePage({
sdkId,
libVersion,
isCrawlerPage = false,
Expand All @@ -37,6 30,14 @@ async function ClientSdkReferencePageUncached({

const menuData = NavItems[libraryMeta.meta[libVersion].libId]

if (isCrawlerPage) {
const sections = await getFlattenedSections(sdkId, libVersion)
const section = sections.find((section) => section.slug === requestedSection)
if (!section) return null

return <SectionSwitch sdkId={sdkId} version={libVersion} section={section} isCrawlerPage />
}

return (
<ReferenceContentScrollHandler libPath={libraryMeta.libPath}>
<SidebarSkeleton
Expand Down Expand Up @@ -72,17 73,7 @@ async function ClientSdkReferencePageUncached({
/>
</>
)}
<ClientLibRefSections
sdkId={sdkId}
libPath={libraryMeta.libPath}
version={libVersion}
isLatestVersion={isLatestVersion}
specFile={libraryMeta.meta[libVersion].specFile}
useTypeSpec={libraryMeta.typeSpec}
{...(isCrawlerPage
? { isCrawlerPage: true, requestedSection }
: { isCrawlerPage: false })}
/>
<ClientLibRefSections sdkId={sdkId} version={libVersion} />
</article>
</LayoutMainContent>
</SidebarSkeleton>
Expand Down
83 changes: 17 additions & 66 deletions apps/docs/features/docs/Reference.sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@ import { Fragment } from 'react'

import { Tabs_Shadcn_, TabsContent_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_, cn } from 'ui'

import { REFERENCES } from '~/content/navigation.references'
import { getRefMarkdown, MDXRemoteRefs } from '~/features/docs/Reference.mdx'
import { MDXProviderReference } from '~/features/docs/Reference.mdx.client'
import type { MethodTypes } from '~/features/docs/Reference.typeSpec'
Expand All @@ -22,67 23,27 @@ import { normalizeMarkdown } from '~/features/docs/Reference.utils'

type ClientLibRefSectionsProps = {
sdkId: string
libPath: string
version: string
isLatestVersion: boolean
specFile: string
useTypeSpec: boolean
} & (
| { isCrawlerPage?: false; requestedSection?: undefined }
| { isCrawlerPage: true; requestedSection: string }
)

async function ClientLibRefSections({
sdkId,
libPath,
version,
isLatestVersion,
specFile,
useTypeSpec,
isCrawlerPage = false,
requestedSection,
}: ClientLibRefSectionsProps) {
async function ClientLibRefSections({ sdkId, version }: ClientLibRefSectionsProps) {
const flattenedSections = await getFlattenedSections(sdkId, version)

let requestedSectionMeta: AbbrevCommonClientLibSection
if (isCrawlerPage) {
requestedSectionMeta = flattenedSections.find((section) => section.slug === requestedSection)
} else {
trimIntro(flattenedSections)
}
trimIntro(flattenedSections)

return (
<MDXProviderReference>
<div className="flex flex-col my-16 gap-16">
{isCrawlerPage
? !!requestedSectionMeta && (
<SectionSwitch
sdkId={sdkId}
libPath={libPath}
version={version}
isLatestVersion={isLatestVersion}
section={requestedSectionMeta}
specFile={specFile}
useTypeSpec={useTypeSpec}
isCrawlerPage
/>
)
: flattenedSections
.filter((section) => section.type !== 'category')
.map((section, idx) => (
<Fragment key={`${section.id}-${idx}`}>
<SectionDivider />
<SectionSwitch
sdkId={sdkId}
libPath={libPath}
version={version}
isLatestVersion={isLatestVersion}
section={section}
specFile={specFile}
useTypeSpec={useTypeSpec}
/>
</Fragment>
))}
{flattenedSections
.filter((section) => section.type !== 'category')
.map((section, idx) => (
<Fragment key={`${section.id}-${idx}`}>
<SectionDivider />
<SectionSwitch sdkId={sdkId} version={version} section={section} />
</Fragment>
))}
</div>
</MDXProviderReference>
)
Expand All @@ -99,27 60,17 @@ function SectionDivider() {
return <hr />
}

interface SectionSwitchProps {
type SectionSwitchProps = {
sdkId: string
libPath: string
version: string
isLatestVersion: boolean
section: AbbrevCommonClientLibSection
specFile: string
useTypeSpec: boolean
isCrawlerPage?: boolean
}

function SectionSwitch({
sdkId,
libPath,
section,
version,
isLatestVersion,
specFile,
useTypeSpec,
isCrawlerPage,
}: SectionSwitchProps) {
export function SectionSwitch({ sdkId, version, section, isCrawlerPage }: SectionSwitchProps) {
const libPath = REFERENCES[sdkId].libPath
const isLatestVersion = version === REFERENCES[sdkId].versions[0]

const sectionLink = `/docs/reference/${libPath}/${isLatestVersion ? '' : `${version}/`}${section.slug}`

switch (section.type) {
Expand All @@ -141,7 92,7 @@ function SectionSwitch({
version={version}
link={sectionLink}
section={section}
useTypeSpec={useTypeSpec}
useTypeSpec={REFERENCES[sdkId].typeSpec}
isCrawlerPage={isCrawlerPage}
/>
)
Expand Down