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

Fix flash when switching top level sections #23

Merged

Conversation

dillondotzip
Copy link
Contributor

Import the main documentation template at the top level of the _app.tsx file instead of the getTemplate() function.

@flightcontrol-ops
Copy link

flightcontrol-ops bot commented Nov 1, 2022

🏖 This preview environment has been fully cleaned up. See you next time!

Copy link
Member

@flybayer flybayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this isn't done yet — let me know when ready for review (you can add WIP to PR title)

@dillondotzip dillondotzip changed the title Fix flash when switching top level sections WIP: Fix flash when switching top level sections Nov 1, 2022
@dillondotzip dillondotzip changed the title WIP: Fix flash when switching top level sections Fix flash when switching top level sections Nov 1, 2022
Copy link
Member

@flybayer flybayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok yes this makes sense. However I'm confused why dynamic is even being used at all. I realized that currently docs are not being SSRd ever. if you disable JS, it's a white page with is crap for SEO.

So we need to fix that, but we can do it in another pr

Comment on lines 8 to 30
const getBestGlobMatch = (globs, path) => {
const match = globs
.filter(p => minimatch(path, p))
.sort((m1, m2) => {
const d1 = fastLevenshtein.get(m1, path)
const d2 = fastLevenshtein.get(m2, path)
return d1 < d2 ? -1 : 1
})?.[0]

if (match === undefined && globs.includes('**/*')) {
return '**/*'
}
return match
}

const getTemplateId = (pathname) => {
const templateMappings = (motifConfig.templates) || {}
const path = pathname === '/' ? '' : pathname.replace(/^\//, '')
const matchingGlob = getBestGlobMatch(Object.keys(templateMappings), path)
if (matchingGlob !== undefined && matchingGlob in templateMappings) {
return templateMappings[matchingGlob]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should all be moved out of the component

}
const Template = dynamic<{children: React.ReactNode, meta: any, path: string, filename: string, files: {}}>(() =>
import('@templates/documentation.mdx').then(mod => (mod as any).Template),
{ ssr: false },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

@flybayer flybayer merged commit cd06ff1 into main Nov 3, 2022
@flybayer flybayer deleted the dillon/eng-856-docs-bug-full-page-reloadflash-of-white branch November 3, 2022 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants