Skip to content

Commit

Permalink
fix(web): NewsList - Filter out frontpage news tags (#18102)
Browse files Browse the repository at this point in the history
* Filter out frontpage news tags

* Rename variable
  • Loading branch information
RunarVestmann authored Feb 25, 2025
1 parent 13f9069 commit 95f6e47
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions apps/web/components/NewsItems/NewsItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Text,
} from '@island.is/island-ui/core'
import { GridItems } from '@island.is/web/components'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import { GetNewsQuery } from '@island.is/web/graphql/schema'
import { LinkType, useLinkResolver } from '@island.is/web/hooks/useLinkResolver'

Expand Down Expand Up @@ -125,7 +125,7 @@ export const NewsItems = ({
// @ts-ignore make web strict
image={image}
tags={genericTags
.filter((tag) => tag.slug !== FRONTPAGE_NEWS_TAG_ID)
.filter((tag) => tag.slug !== FRONTPAGE_NEWS_TAG_SLUG)
.map(({ slug, title, __typename: tn }) => {
return {
label: title,
Expand Down
4 changes: 2 additions & 2 deletions apps/web/components/NewsList/NewsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
NewsCard,
Webreader,
} from '@island.is/web/components'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import { GenericTag, GetNewsQuery } from '@island.is/web/graphql/schema'
import { LinkType, useLinkResolver, useNamespace } from '@island.is/web/hooks'

Expand Down Expand Up @@ -222,7 +222,7 @@ export const NewsList = ({
}
imageSrc={newsItem.image?.url ?? ''}
tags={newsItem.genericTags
.filter((tag) => tag.id !== FRONTPAGE_NEWS_TAG_ID)
.filter((tag) => tag.slug !== FRONTPAGE_NEWS_TAG_SLUG)
.map((tag) => tag.title)}
title={newsItem.title}
description={newsItem.intro}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Text,
} from '@island.is/island-ui/core'
import { DigitalIcelandNewsCard } from '@island.is/web/components'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import { LatestNewsSlice as LatestNewsSliceSchema } from '@island.is/web/graphql/schema'
import { useLinkResolver } from '@island.is/web/hooks'

Expand Down Expand Up @@ -75,7 +75,7 @@ export const DigitalIcelandLatestNewsSlice: React.FC<
description={news.intro}
imageSrc={news.image?.url ?? ''}
tags={news.genericTags
.filter((tag) => tag.slug !== FRONTPAGE_NEWS_TAG_ID)
.filter((tag) => tag.slug !== FRONTPAGE_NEWS_TAG_SLUG)
.map((tag) => tag.title)}
title={news.title}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const SLICE_SPACING: ResponsiveSpace = 7
export const PROJECT_STORIES_TAG_ID = '9yqOTwQYzgyej5kItFTtd'
export const ADGERDIR_INDIVIDUALS_TAG_ID = '4kLt3eRht5yJoakIHWsusb'
export const ADGERDIR_COMPANIES_TAG_ID = '4ZWcwoW2IiB2AhtzQpzdIW'
export const FRONTPAGE_NEWS_TAG_ID = 'forsidufrettir'
export const FRONTPAGE_NEWS_TAG_SLUG = 'forsidufrettir'
export const PLAUSIBLE_SCRIPT_SRC =
'https://plausible.io/js/script.outbound-links.js'
export const DIGITAL_ICELAND_PLAUSIBLE_TRACKING_DOMAIN =
Expand Down
4 changes: 2 additions & 2 deletions apps/web/pages/api/rss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { parseAsString, parseAsStringEnum } from 'next-usequerystate'

import { defaultLanguage } from '@island.is/shared/constants'
import type { Locale } from '@island.is/shared/types'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import initApollo from '@island.is/web/graphql/client'
import {
ContentLanguage,
Expand Down Expand Up @@ -50,7 +50,7 @@ const extractTagsFromQuery = (query: NextApiRequest['query']) => {
}

// If nothing is defined in query we'll show frontpage news
return [FRONTPAGE_NEWS_TAG_ID]
return [FRONTPAGE_NEWS_TAG_SLUG]
}

const generateItemString = (item: Item) => {
Expand Down
6 changes: 3 additions & 3 deletions apps/web/screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SearchSection,
WatsonChatPanel,
} from '@island.is/web/components'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import { GlobalContext } from '@island.is/web/context'
import {
ContentLanguage,
Expand Down Expand Up @@ -156,7 +156,7 @@ Home.getProps = async ({ apolloClient, locale }) => {
input: {
size: 3,
lang: locale as ContentLanguage,
tags: [FRONTPAGE_NEWS_TAG_ID],
tags: [FRONTPAGE_NEWS_TAG_SLUG],
},
},
}),
Expand All @@ -177,7 +177,7 @@ Home.getProps = async ({ apolloClient, locale }) => {
...item,
genericTags:
item?.genericTags?.filter(
(tag) => tag.slug !== FRONTPAGE_NEWS_TAG_ID,
(tag) => tag.slug !== FRONTPAGE_NEWS_TAG_SLUG,
) ?? [],
})) ?? [],
categories: getArticleCategories,
Expand Down
6 changes: 3 additions & 3 deletions apps/web/screens/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
NewsCard,
Webreader,
} from '@island.is/web/components'
import { FRONTPAGE_NEWS_TAG_ID } from '@island.is/web/constants'
import { FRONTPAGE_NEWS_TAG_SLUG } from '@island.is/web/constants'
import { useNamespace } from '@island.is/web/hooks'
import { useDateUtils } from '@island.is/web/i18n/useDateUtils'
import { withMainLayout } from '@island.is/web/layouts/main'
Expand Down Expand Up @@ -412,7 +412,7 @@ NewsListNew.getProps = async ({ apolloClient, locale, query }) => {
const year = getIntParam(query.y, { minValue: 1000, maxValue: 9999 })
const month = year && getIntParam(query.m, { minValue: 1, maxValue: 12 })
const selectedPage = getIntParam(query.page, { minValue: 1 }) ?? 1
const tag = (query.tag as string) ?? FRONTPAGE_NEWS_TAG_ID
const tag = (query.tag as string) ?? FRONTPAGE_NEWS_TAG_SLUG
const [
{
data: { getNewsDates: newsDatesList },
Expand Down Expand Up @@ -492,7 +492,7 @@ NewsListNew.getProps = async ({ apolloClient, locale, query }) => {
}

const filterOutFrontpageTag = (tag: GenericTag) =>
tag?.slug !== FRONTPAGE_NEWS_TAG_ID
tag?.slug !== FRONTPAGE_NEWS_TAG_SLUG

return {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down

0 comments on commit 95f6e47

Please sign in to comment.