Skip to content

Commit 36688c2

Browse files
committed
add default lang for blog.post queries
1 parent ceec7ae commit 36688c2

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/lib/i18n.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Language } from '@sanity/document-internationalization'
33
export const supportedLanguages = [
44
{ id: 'en', title: 'English' },
55
// { id: 'fr', title: 'Français' },
6-
// { id: 'ja', title: '日本語' },
6+
{ id: 'ja', title: '日本語' },
77
] as const as Language[]
88

99
export const languages = supportedLanguages.map((lang) => lang?.id)

src/ui/modules/blog/BlogFrontpage/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { cookies } from 'next/headers'
2+
import { DEFAULT_LANG } from '@/lib/i18n'
13
import { fetchSanityLive } from '@/sanity/lib/fetch'
24
import { groq } from 'next-sanity'
3-
import { cookies } from 'next/headers'
45
import { stegaClean } from 'next-sanity'
56
import sortFeaturedPosts from './sortFeaturedPosts'
67
import { Suspense } from 'react'
@@ -18,7 +19,7 @@ export default async function BlogFrontpage({
1819
showFeaturedPostsFirst: boolean
1920
itemsPerPage: number
2021
}>) {
21-
const lang = (await cookies()).get('lang')?.value
22+
const lang = (await cookies()).get('lang')?.value ?? DEFAULT_LANG
2223

2324
const posts = await fetchSanityLive<Sanity.BlogPost[]>({
2425
query: groq`

src/ui/modules/blog/BlogList/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { cookies } from 'next/headers'
2+
import { DEFAULT_LANG } from '@/lib/i18n'
13
import { fetchSanityLive } from '@/sanity/lib/fetch'
24
import { groq } from 'next-sanity'
3-
import { cookies } from 'next/headers'
45
import Pretitle from '@/ui/Pretitle'
56
import { PortableText, stegaClean } from 'next-sanity'
67
import FilterList from '@/ui/modules/blog/BlogList/FilterList'
@@ -26,7 +27,7 @@ export default async function BlogList({
2627
displayFilters: boolean
2728
filteredCategory: Sanity.BlogCategory
2829
}>) {
29-
const lang = (await cookies()).get('lang')?.value
30+
const lang = (await cookies()).get('lang')?.value ?? DEFAULT_LANG
3031

3132
const posts = await fetchSanityLive<Sanity.BlogPost[]>({
3233
query: groq`

0 commit comments

Comments
 (0)