Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 674abaa

Browse files
committed
fix build
1 parent 7eb7de3 commit 674abaa

File tree

4 files changed

+63
-31
lines changed

4 files changed

+63
-31
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use client'
2+
3+
import useLang, { LanguageId } from '@/hooks/useLang'
4+
import { cn } from '@/lib/utils'
5+
import React from 'react'
6+
import { Button } from '../ui/button'
7+
8+
export const LanguageSwitchClient = ({
9+
languages,
10+
}: {
11+
languages: { name: string; icon: React.ReactNode }[]
12+
}) => {
13+
const { currentLanguage, setCurrentLanguage } = useLang()
14+
15+
return (
16+
<ul className="flex gap-x-4">
17+
{languages.map(({ name, icon }) => (
18+
<li
19+
key={name}
20+
className={cn(
21+
'cursor-pointer transition-all',
22+
currentLanguage !== name ? 'grayscale hover:grayscale-0' : '',
23+
)}
24+
>
25+
<Button
26+
variant="unstyled"
27+
onClick={() => setCurrentLanguage(name as LanguageId)}
28+
>
29+
{icon}
30+
<span className="sr-only">set language to {name}</span>
31+
</Button>
32+
</li>
33+
))}
34+
</ul>
35+
)
36+
}
Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
'use client'
2-
3-
import useLang, { LanguageId } from '@/hooks/useLang'
4-
import { cn } from '@/lib/utils'
5-
import React from 'react'
6-
import { Button } from './ui/button'
1+
import React, { Suspense } from 'react'
72
import JavaScriptLogoColour from '@/components/icons/JavaScriptLogoColour'
83
import TypeScriptLogoColour from '@/components/icons/TypeScriptLogoColour'
94
import PythonColorLogo from '@/components/icons/PythonLogoColour'
105
import GoColorLogo from '@/components/icons/GoLogoColour'
116
import DartLogoNoTextColour from '@/components/icons/DartLogoNoTextColour'
7+
import { LanguageSwitchClient } from './LanguageSwitch.client'
8+
import { Button } from '../ui/button'
129

13-
const languages = [
10+
const languages: { name: string; icon: React.ReactNode }[] = [
1411
{
1512
name: 'javascript',
1613
icon: <JavaScriptLogoColour className={'size-8'} />,
@@ -34,27 +31,27 @@ const languages = [
3431
]
3532

3633
export const LanguageSwitch = () => {
37-
const { currentLanguage, setCurrentLanguage } = useLang()
38-
3934
return (
40-
<ul className="flex gap-x-4">
41-
{languages.map(({ name, icon }) => (
42-
<li
43-
key={name}
44-
className={cn(
45-
'cursor-pointer transition-all',
46-
currentLanguage !== name ? 'grayscale hover:grayscale-0' : '',
47-
)}
48-
>
49-
<Button
50-
variant="unstyled"
51-
onClick={() => setCurrentLanguage(name as LanguageId)}
52-
>
53-
{icon}
54-
<span className="sr-only">set language to {name}</span>
55-
</Button>
56-
</li>
57-
))}
58-
</ul>
35+
<Suspense
36+
fallback={
37+
<ul className="flex gap-x-4">
38+
{languages.map(({ name, icon }) => (
39+
<li
40+
key={name}
41+
className={
42+
'cursor-pointer grayscale transition-all hover:grayscale-0'
43+
}
44+
>
45+
<Button variant="unstyled">
46+
{icon}
47+
<span className="sr-only">set language to {name}</span>
48+
</Button>
49+
</li>
50+
))}
51+
</ul>
52+
}
53+
>
54+
<LanguageSwitchClient languages={languages} />
55+
</Suspense>
5956
)
6057
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { LanguageSwitch } from './LanguageSwitch'

src/components/guides/GuideFilters.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export const GuideFilters: React.FC<Props> = ({ allTags }) => {
1818
</li>
1919
))}
2020
</ul>
21-
<Suspense>
22-
<LanguageSwitch />
23-
</Suspense>
21+
<LanguageSwitch />
2422
</>
2523
)
2624
}

0 commit comments

Comments
 (0)