Skip to content

Commit

Permalink
Fix thumbail url for archived items in news (#2639)
Browse files Browse the repository at this point in the history
* πŸ› Fix archive url #2631

* Simplify

* βœ… pass test

* Pass test

* πŸ› Fix thumbnail #2631
  • Loading branch information
padms authored Nov 5, 2024
1 parent b6fc9ff commit cdb9c7d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
4 changes: 1 addition & 3 deletions search/IndexArchivedNews/mapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ describe('fileStorage', () => {
expect(res.topicTags).toEqual(['tag1', 'tag2', 'General news'])
expect(res.countryTags).toEqual(['Norway'])
expect(res.text).toEqual('A lot of \n content')
expect(res.thumbnailUrl).toEqual(
'https://envisstoragedev.blob.core.windows.net/equinor-archive-content/link/to/url/of/image.png',
)
expect(res.thumbnailUrl).toEqual('/link/to/url/of/image.png')
})
})

Expand Down
2 changes: 1 addition & 1 deletion search/IndexArchivedNews/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export const mapData: MapDataType = (article) => {
],
countryTags: [country.trim()].filter(identity),
year,
thumbnailUrl: thumbnailURL ? `https://envisstoragedev.blob.core.windows.net/equinor-archive-content${thumbnailURL}` : null,
thumbnailUrl: thumbnailURL ? thumbnailURL : null,
} as NewsIndex
}
19 changes: 8 additions & 11 deletions web/templates/newsroom/NewsSections/NewsHeadliner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FormattedDate } from '@components/FormattedDateTime'
import { forwardRef, HTMLAttributes } from 'react'
import Img from 'next/image'
import { BaseLink } from '@core/Link'
import { Typography } from '@core/Typography'
import Image, { Ratios } from '../../../pageComponents/shared/SanityImage'
Expand All @@ -26,16 +25,14 @@ const NewsHeadliner = forwardRef<HTMLLIElement, NewsHeadlinerProps>(function New
{(heroImage?.image?.asset || fallbackImage || thumbnailUrl) && (
<div className="aspect-video relative max-h-[324px] mb-2">
{thumbnailUrl ? (
<div className="relative rounded-xs">
<Img
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
fill
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
</div>
<img
className="relative rounded-xs"
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
) : (
(heroImage?.image?.asset || fallbackImage) && (
<Image
Expand Down
19 changes: 8 additions & 11 deletions web/templates/newsroom/NewsSections/NewsItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { FormattedDate } from '@components/FormattedDateTime'
import { forwardRef, HTMLAttributes } from 'react'
import Img from 'next/image'
import { BaseLink } from '@core/Link'
import { Typography } from '@core/Typography'
import Image, { Ratios } from '../../../pageComponents/shared/SanityImage'
Expand Down Expand Up @@ -37,16 +36,14 @@ const NewsItem = forwardRef<HTMLLIElement, NewsListItemProps>(function NewsItem(
{(heroImage?.image?.asset || fallbackImage || thumbnailUrl) && (
<>
{thumbnailUrl ? (
<div className="relative rounded-xs">
<Img
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
fill
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
</div>
<img
className="relative rounded-xs"
src={thumbnailUrl}
alt=""
style={{ objectFit: 'cover' }}
sizes="(max-width: 800px) 100vw, 800px"
role={'presentation'}
/>
) : (
(heroImage?.image?.asset || fallbackImage) && (
<Image
Expand Down

0 comments on commit cdb9c7d

Please sign in to comment.