Skip to content

Commit

Permalink
fix: 'Outdated docs' banner flash & simplify guide check
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Apr 8, 2024
1 parent 2b7a344 commit 5ea15ce
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 44 deletions.
1 change: 0 additions & 1 deletion content/de/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---


Expand Down
1 change: 0 additions & 1 deletion content/en/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
description: 'Fast 3kB alternative to React with the same modern API.'
---

Expand Down
1 change: 0 additions & 1 deletion content/es/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---


Expand Down
1 change: 0 additions & 1 deletion content/fr/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---

<jumbotron>
Expand Down
1 change: 0 additions & 1 deletion content/it/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---


Expand Down
1 change: 0 additions & 1 deletion content/ja/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
description: 'Preact is a fast 3kB alternative to React with the same modern API'
---

Expand Down
1 change: 0 additions & 1 deletion content/kr/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
description: 'Fast 3kB alternative to React with the same modern API.'
---

Expand Down
1 change: 0 additions & 1 deletion content/pt-br/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---


Expand Down
1 change: 0 additions & 1 deletion content/ru/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
description: 'Быстрая 3КБ-альтернатива React с тем же современным API.'
---

Expand Down
1 change: 0 additions & 1 deletion content/tr/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
---


Expand Down
1 change: 0 additions & 1 deletion content/zh/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: home
title: Preact
toc: false
description: 'React 的 3kb 轻量级替代方案,拥有相同的现代 API。'
---

Expand Down
17 changes: 7 additions & 10 deletions src/components/controllers/doc-page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ 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() {
Expand All @@ -20,29 +20,27 @@ export function DocPage() {
return <NotFound />;
}

return <DocLayout />;
return <DocLayout isGuide />;
}

export function DocLayout() {
export function DocLayout({ isGuide = false }) {
const { path } = useLocation();
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>
Expand All @@ -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) {
return null;
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/doc-version/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useLocation, useRoute } from 'preact-iso';
import config from '../../config.json';
import style from './style.module.css';

export const AVAILABLE_DOCS = [10, 8];
export const LATEST_MAJOR = 'v10';
export const AVAILABLE_DOCS = ['10', '8'];

/**
* Select box to switch the currently displayed docs version
Expand All @@ -28,7 +29,7 @@ export default function DocVersion() {
Version:{' '}
<select value={version} class={style.select} onChange={onChange}>
{AVAILABLE_DOCS.map(v => {
const suffix = v === 10 ? ' (current)' : '';
const suffix = LATEST_MAJOR.slice(1) == v ? ' (current)' : '';
return (
<option key={v} value={`v${v}`}>
{v}.x{suffix}
Expand Down
21 changes: 0 additions & 21 deletions src/lib/docs.js

This file was deleted.

0 comments on commit 5ea15ce

Please sign in to comment.