Skip to content

Commit

Permalink
🎨 update
Browse files Browse the repository at this point in the history
  • Loading branch information
BorghildSelle committed Nov 7, 2024
1 parent 2df4b0e commit dedabbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions web/pages/api/news/next.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { getNameFromLocale } from '../../../lib/localization'
import { sanityClient } from '../../../lib/sanity.server'
import { getNewsArticlesByPage } from '../../../lib/queries/newsroom'

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const lang = req.query.lang === 'no' ? getNameFromLocale('no') : getNameFromLocale('en') // Defaults to 'en' if the lang parameter is not 'no'

console.log('get next on lang', req.query.lang)
console.log('get next from req.query.lastId', req.query.lastId)
console.log('get next from req.query.lastPublishedAt', req.query.lastPublishedAt)
try {
const news = await sanityClient.fetch(getNewsArticlesByPage(false, true), {
lang,
lang: req.query.lang,
lastId: req.query.lastId,
lastPublishedAt: req.query.lastPublishedAt,
})
Expand Down
8 changes: 4 additions & 4 deletions web/pages/api/news/prev.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { getNameFromLocale } from '../../../lib/localization'
import { sanityClient } from '../../../lib/sanity.server'
import { getNewsArticlesByPage } from '../../../lib/queries/newsroom'

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const lang = req.query.lang === 'no' ? getNameFromLocale('no') : getNameFromLocale('en') // Defaults to 'en' if the lang parameter is not 'no'

console.log('get prev on lang', req.query.lang)
console.log('get prev from req.query.lastId', req.query.lastId)
console.log('get prev from req.query.lastPublishedAt', req.query.lastPublishedAt)
try {
const news = await sanityClient.fetch(getNewsArticlesByPage(true, false), {
lang,
lang: req.query.lang,
lastId: req.query.lastId,
lastPublishedAt: req.query.lastPublishedAt,
})
Expand Down
1 change: 1 addition & 0 deletions web/templates/newsroom/sanity/NewsroomSanity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const NewsRoomTemplateSanity = forwardRef<HTMLElement, NewsRoomTemplateProps>(fu
newsArticles?.[newsArticles?.length - 1]?.publishDateTime ??
null,
)

const [newsList, setNewsList] = useState(newsArticles ?? [])

const setSearchStates = (filteredNews: any) => {
Expand Down

0 comments on commit dedabbb

Please sign in to comment.