-
-
Notifications
You must be signed in to change notification settings - Fork 499
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: Reduce tearing issues #1113
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
<jumbotron> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
--- | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
layout: home | ||
title: Preact | ||
toc: false | ||
description: 'React 的 3kb 轻量级替代方案,拥有相同的现代 API。' | ||
--- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { useRoute, useLocation } from 'preact-iso'; | ||
import { useRoute } from 'preact-iso'; | ||
import { useContent } from '../../lib/use-resource'; | ||
import { useTitle, useDescription } from './utils'; | ||
import config from '../../config.json'; | ||
import { NotFound } from './not-found'; | ||
import cx from '../../lib/cx'; | ||
import { LATEST_MAJOR, isDocPage } from '../../lib/docs'; | ||
import { useLanguage } from '../../lib/i18n'; | ||
import { MarkdownRegion } from './markdown-region'; | ||
import Sidebar from '../sidebar'; | ||
import Footer from '../footer/index'; | ||
import { docRoutes } from '../../lib/route-utils'; | ||
import { LATEST_MAJOR } from '../doc-version'; | ||
import style from './style.module.css'; | ||
|
||
export function DocPage() { | ||
|
@@ -20,29 +20,27 @@ export function DocPage() { | |
return <NotFound />; | ||
} | ||
|
||
return <DocLayout />; | ||
return <DocLayout isGuide />; | ||
} | ||
|
||
export function DocLayout() { | ||
const { path } = useLocation(); | ||
export function DocLayout({ isGuide = false }) { | ||
const { path } = useRoute(); | ||
const [lang] = useLanguage(); | ||
|
||
const { html, meta } = useContent([lang, path === '/' ? 'index' : path]); | ||
useTitle(meta.title); | ||
useDescription(meta.description); | ||
|
||
const hasSidebar = meta.toc !== false && isDocPage(path); | ||
|
||
return ( | ||
<div class={cx(style.page, hasSidebar && style.withSidebar)}> | ||
<div class={cx(style.page, isGuide && style.withSidebar)}> | ||
<div class={style.outer}> | ||
{hasSidebar && ( | ||
{isGuide && ( | ||
<div class={style.sidebarWrap}> | ||
<Sidebar /> | ||
</div> | ||
)} | ||
<div class={style.inner}> | ||
<OldDocsWarning /> | ||
{isGuide && <OldDocsWarning />} | ||
<MarkdownRegion html={html} meta={meta} /> | ||
<Footer /> | ||
</div> | ||
|
@@ -53,9 +51,8 @@ export function DocLayout() { | |
|
||
function OldDocsWarning() { | ||
const { name, version } = useRoute().params; | ||
const { path } = useLocation(); | ||
|
||
if (!isDocPage(path) || version === LATEST_MAJOR) { | ||
if (version === LATEST_MAJOR) { | ||
Comment on lines
53
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was a bit of a problem as We could correct that here, but it's better to conditionally render the entire component. |
||
return null; | ||
} | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,12 +53,3 @@ export function useResource(fn, deps) { | |
else if (state.status === 'error') throw state.result; | ||
throw state.promise; | ||
} | ||
|
||
export function FakeSuspense(props) { | ||
this.__c = childDidSuspend; | ||
return this.state && this.state.suspended ? props.fallback : props.children; | ||
} | ||
|
||
function childDidSuspend(err) { | ||
err.then(() => this.forceUpdate()); | ||
} | ||
Comment on lines
-56
to
-64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessarily a tearing issue, but something that needed to be fixed. Tbh, I rather mindlessly copied this from #793 and didn't look too closely at it. Swapping it out for standard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant; the home page is the only one with
meta.toc == false
, and the sidebar only appears on/guide/*
pages. Better to switch it toisGuide
as that's essentially what we're checking.