Skip to content

Commit 3e1de7e

Browse files
committed
Add sample app link to homepage
1 parent 770ff56 commit 3e1de7e

File tree

4 files changed

+58
-23
lines changed

4 files changed

+58
-23
lines changed

i18n/de/code.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"custom.documentation-button": {
66
"message": "Dokumentation"
77
},
8+
"custom.sample-app-button": {
9+
"message": "Beispiel-App"
10+
},
811
"custom.subtitle": {
912
"message": "Die barrierefreie Web Component Bibliothek"
1013
},
@@ -342,4 +345,4 @@
342345
"custom.components-short-description": {
343346
"message": "Heute umfasst die Komponentenvielfalt mehr als 40 Komponenten mit einem hohen Funktionsumfang zur Umsetzung verschiedenster Fachanwendungen und Darstellung von webbasierten Inhalten."
344347
}
345-
}
348+
}

i18n/en/code.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"custom.documentation-button": {
66
"message": "Documentation"
77
},
8+
"custom.sample-app-button": {
9+
"message": "Sample-App"
10+
},
811
"custom.subtitle": {
912
"message": "The accessible Web Component library"
1013
},

src/pages/index.tsx

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import Layout from '@theme/Layout';
77
import type { FunctionComponent } from 'react';
88
import React from 'react';
99
import { KoliBriAbbr } from '../components/KoliBriAbbr';
10+
import { useDocsPreferredVersion } from '@docusaurus/theme-common';
11+
import { Version } from '../../shares/version';
1012

1113
const HomepageHeader: FunctionComponent = () => (
1214
<header className="p-8 grid justify-center">
@@ -22,6 +24,43 @@ const HomepageHeader: FunctionComponent = () => (
2224
</p>
2325
</header>
2426
);
27+
const HomepageButtons: FunctionComponent = () => {
28+
const docVersion = useDocsPreferredVersion();
29+
const version =
30+
typeof docVersion?.preferredVersion?.name && parseFloat(docVersion?.preferredVersion?.name as Version) < 2
31+
? 'v1'
32+
: 'v2';
33+
34+
return (
35+
<div className="grid sm:flex gap-4 justify-center mt-4">
36+
<KolLinkButton
37+
className="w-72"
38+
_icons={{
39+
right: 'codicon codicon-dashboard',
40+
}}
41+
_href="docs/get-started/first-steps"
42+
_label={translate({
43+
id: 'custom.get-started-button',
44+
})}
45+
_variant="primary"
46+
></KolLinkButton>
47+
<KolLinkButton
48+
className="w-72"
49+
_href="docs"
50+
_label={translate({
51+
id: 'custom.documentation-button',
52+
})}
53+
></KolLinkButton>
54+
<KolLinkButton
55+
className="w-72"
56+
_href={`/${version}/sample-react/#/handout/basic`}
57+
_label={translate({
58+
id: 'custom.sample-app-button',
59+
})}
60+
></KolLinkButton>
61+
</div>
62+
);
63+
};
2564

2665
export default function Homepage(): JSX.Element {
2766
return (
@@ -41,27 +80,9 @@ export default function Homepage(): JSX.Element {
4180
)}
4281
>
4382
<HomepageHeader />
83+
<HomepageButtons />
84+
4485
<main>
45-
<div className="grid sm:flex gap-4 justify-center mt-4">
46-
<KolLinkButton
47-
className="w-72"
48-
_icons={{
49-
right: 'codicon codicon-dashboard',
50-
}}
51-
_href="docs/get-started/first-steps"
52-
_label={translate({
53-
id: 'custom.get-started-button',
54-
})}
55-
_variant="primary"
56-
></KolLinkButton>
57-
<KolLinkButton
58-
className="w-72"
59-
_href="docs"
60-
_label={translate({
61-
id: 'custom.documentation-button',
62-
})}
63-
></KolLinkButton>
64-
</div>
6586
<div className="grid gap-2 md:w-6/12 m-auto mt-4 p-4">
6687
<div className="flex gap-4 justify-center">
6788
<KolLogo

src/theme/Navbar/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { LanguageSwitch } from '@site/src/components/LanguageSwitch';
99
import Navbar from '@theme-original/Navbar';
1010
import ThemeSelect from './ThemeSelect';
1111
import { useDocsPreferredVersion } from '@docusaurus/theme-common';
12+
import { Version } from '../../shares/version';
13+
import { translate } from '@docusaurus/Translate';
1214

1315
export const NavbarWrapper: FunctionComponent<PropsWithChildren> = (props) => {
1416
// const [dark, setDark] = useState(false);
@@ -26,7 +28,11 @@ export const NavbarWrapper: FunctionComponent<PropsWithChildren> = (props) => {
2628
// },
2729
// };
2830
const docVersion = useDocsPreferredVersion();
29-
const version = (docVersion?.preferredVersion?.name as number) > 2 ? 'v2' : 'v1';
31+
const version =
32+
typeof docVersion?.preferredVersion?.name && parseFloat(docVersion?.preferredVersion?.name as Version) < 2
33+
? 'v1'
34+
: 'v2';
35+
3036
return (
3137
<div className="kolibri-navbar-wrapper sticky top-0 z-50 bg-white">
3238
<div className="kolibri-navbar max-w-screen-md lg:max-w-4xl 2xl:max-w-[95rem] mx-auto grid grid-cols-[1fr,auto] gap-y-2 items-center 2xl:grid-cols-[1fr,auto,auto,auto] p-4 lg:px-8">
@@ -88,7 +94,9 @@ export const NavbarWrapper: FunctionComponent<PropsWithChildren> = (props) => {
8894
_href={`/${version}/sample-react/#/handout/basic`}
8995
_icons={'codicon codicon-preview'}
9096
_hideLabel
91-
_label="Präsentation anschauen"
97+
_label={translate({
98+
id: 'custom.sample-app-button',
99+
})}
92100
_tooltipAlign="left"
93101
// _target="presentation"
94102
_variant="ghost"

0 commit comments

Comments
 (0)