Skip to content

Commit 9a98ebd

Browse files
committed
refactor: Walk back making v11 already the default
1 parent f91a011 commit 9a98ebd

File tree

6 files changed

+40
-29
lines changed

6 files changed

+40
-29
lines changed

src/assets/_redirects

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
/guide/getting-started /guide/v11/getting-started
2-
/guide/differences-to-react /guide/v11/differences-to-react
3-
/guide/switching-to-preact /guide/v11/switching-to-preact
4-
/guide/types-of-components /guide/v11/components
5-
/guide/api-reference /guide/v11/api-reference
6-
/guide/forms /guide/v11/forms
7-
/guide/linked-state /guide/v8/linked-state
8-
/guide/external-dom-mutations /guide/v11/external-dom-mutations
1+
/guide/getting-started /guide/v10/getting-started
2+
/guide/differences-to-react /guide/v10/differences-to-react
3+
/guide/switching-to-preact /guide/v10/switching-to-preact
4+
/guide/types-of-components /guide/v10/components
5+
/guide/api-reference /guide/v10/api-reference
6+
/guide/forms /guide/v10/forms
7+
/guide/unit-testing-with-enzyme /guide/v10/unit-testing-with-enzyme
8+
/guide/external-dom-mutations /guide/v8/external-dom-mutations
99
/guide/extending-component /guide/v8/extending-component
10-
/guide/unit-testing-with-enzyme /guide/v11/unit-testing-with-enzyme
10+
/guide/linked-state /guide/v8/linked-state
1111
/guide/progressive-web-apps /guide/v8/progressive-web-apps
1212
/* /404/index.html 404

src/components/controllers/guide-page.jsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { MarkdownRegion } from './markdown-region';
99
import Sidebar from '../sidebar';
1010
import Footer from '../footer/index';
1111
import { docRoutes } from '../../lib/route-utils';
12-
import { LATEST_MAJOR } from '../doc-version';
12+
import { LATEST_MAJOR, PREVIEW_MAJOR } from '../doc-version';
1313
import style from './style.module.css';
1414

1515
export function GuidePage() {
@@ -56,13 +56,15 @@ function OldDocsWarning() {
5656
return null;
5757
}
5858

59+
const outdatedVersion = version !== PREVIEW_MAJOR;
5960
const latestExists = config.docs[LATEST_MAJOR].some(section =>
6061
section.routes.some(route => route.path === '/' + name)
6162
);
6263

6364
return (
6465
<div class={style.stickyWarning}>
65-
You are viewing the documentation for an older version of Preact.
66+
You are viewing the documentation for an{' '}
67+
{outdatedVersion ? 'older' : 'unreleased'} version of Preact.
6668
{latestExists ? (
6769
<>
6870
{' '}
@@ -93,7 +95,11 @@ function UnmaintainedTranslationWarning({ meta }) {
9395
const { name, version } = params;
9496
const [lang, setLang] = useLanguage();
9597

96-
if (version !== LATEST_MAJOR || MAINTAINED_LANGUAGES.includes(lang) || meta.isFallback) {
98+
if (
99+
version !== LATEST_MAJOR ||
100+
MAINTAINED_LANGUAGES.includes(lang) ||
101+
meta.isFallback
102+
) {
97103
return null;
98104
}
99105

@@ -103,10 +109,10 @@ function UnmaintainedTranslationWarning({ meta }) {
103109
<div class={style.stickyWarning}>
104110
<details>
105111
<summary>You are viewing an unmaintained translation</summary>
106-
107-
Whilst we try to offer these docs in as many languages as possible, we rely upon
108-
our community members to help us maintain them. This translation has seen little
109-
maintenance in recent months and may have fallen out of sync with the English version.
112+
Whilst we try to offer these docs in as many languages as possible, we
113+
rely upon our community members to help us maintain them. This
114+
translation has seen little maintenance in recent months and may have
115+
fallen out of sync with the English version.
110116
</details>
111117
<div class={style.unmaintaindTranslationLinks}>
112118
<a
@@ -115,11 +121,7 @@ function UnmaintainedTranslationWarning({ meta }) {
115121
>
116122
Switch to the English version
117123
</a>
118-
<a
119-
href={editUrl}
120-
target="_blank"
121-
rel="noopener noreferrer"
122-
>
124+
<a href={editUrl} target="_blank" rel="noopener noreferrer">
123125
Contribute to this translation
124126
</a>
125127
</div>

src/components/doc-version/index.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { useLocation, useRoute } from 'preact-iso';
33
import { docRoutes } from '../../lib/route-utils.js';
44
import style from './style.module.css';
55

6-
export const LATEST_MAJOR = 'v11';
6+
export const LATEST_MAJOR = 'v10';
7+
export const PREVIEW_MAJOR = 'v11';
78
export const AVAILABLE_DOCS = ['11', '10', '8'];
89

910
/**
@@ -30,7 +31,12 @@ export default function DocVersion() {
3031
Version:{' '}
3132
<select value={version} class={style.select} onChange={onChange}>
3233
{AVAILABLE_DOCS.map(v => {
33-
const suffix = LATEST_MAJOR.slice(1) == v ? ' (current)' : '';
34+
let suffix = '';
35+
if (LATEST_MAJOR.slice(1) == v) {
36+
suffix = ' (current)';
37+
} else if (PREVIEW_MAJOR.slice(1) == v) {
38+
suffix = ' (preview)';
39+
}
3440
return (
3541
<option key={v} value={`v${v}`}>
3642
{v}.x{suffix}

src/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
},
116116
"content": "guide",
117117
"path": "/guide/:version?/:page?",
118-
"href": "/guide/v11/getting-started"
118+
"href": "/guide/v10/getting-started"
119119
},
120120
{
121121
"name": {

src/lib/page-title.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ export function createTitle(title) {
77
// Titles for various content areas
88
let suffix = '';
99
switch (true) {
10-
case url.startsWith('/guide/v11'):
10+
case url.startsWith('/guide/v10'):
1111
suffix = 'Preact Guide';
1212
break;
13-
case url.startsWith('/guide/v10'):
14-
suffix = 'Preact Guide v10';
13+
// TODO v11: Switch when v11 is properly released
14+
case url.startsWith('/guide/v11'):
15+
suffix = 'Preact Guide v11';
1516
break;
1617
case url.startsWith('/guide/v8'):
1718
suffix = 'Preact Guide v8';

src/style/markdown.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,10 @@
375375
scroll-margin-top: var(--header-height);
376376
}
377377

378-
content-region[name*='v8'] &,
379-
content-region[name*='v10'] & {
378+
/* TODO v11: Switch when v11 is properly released */
379+
content-region[name*='v8'] & {
380+
/*content-region[name*='v8'] &,
381+
content-region[name*='v10'] & {*/
380382
scroll-margin-top: calc(var(--header-and-banner-height) + 3.25rem);
381383

382384
@media (max-height: 431px) {

0 commit comments

Comments
 (0)