File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2121 :key =" entry.id"
2222 class =" flex border-bottom-bg p-medium" >
2323 <div class =" col-sm-3 pr-xsmall" >
24- <img v-if =" entry.image" :src =" `${entry.image.file.url}${imgUrlParams}`" class =" main block" />
24+ <picture v-if =" entry.image?.file?.url" class =" main block" >
25+ <source :srcset =" `${entry.image?.file?.url}${imgUrlParams}`" media =" (prefers-color-scheme: light)" />
26+ <source v-if =" entry.imageDark" :srcset =" `${entry.imageDark.file?.url}${imgUrlParams}`" media =" (prefers-color-scheme: dark)" />
27+ <!-- fallback -->
28+ <img :src =" `${entry.image?.file?.url}${imgUrlParams}`" />
29+ </picture >
30+ <robot-icon v-else size =" 1.75rem" style =" float : right " />
2531 </div >
2632 <div class =" col-sm-9 pl-xsmall" >
2733 <a v-if =" entry.link" :href =" entry.link" target =" blank" class =" mb-none line-height-1" >
4248<script >
4349import { getNews } from ' ../js/contentfulClient'
4450import { documentToHtmlString } from ' @contentful/rich-text-html-renderer'
51+ import { RobotIcon } from ' ./icons'
4552export default {
53+ components: {
54+ RobotIcon
55+ },
4656 data : () => ({
4757 expanded: false ,
4858 news: [],
@@ -103,10 +113,10 @@ export default {
103113 }
104114 @media (prefers - color - scheme : dark ) {
105115 .inner - news- container: not (.expanded ):: after {
106- background: linear- gradient (transparent 80 % , #1a1a1a 100 % );
116+ background: linear- gradient (transparent 80 % , #1a1a1a 100 % );
107117 }
108118 }
109- img .main {
119+ picture .main , picture img {
110120 width: 100 % ;
111121 border- radius: 0 .25rem ;
112122 }
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ export const getNews = async() => {
2727 } )
2828 . then ( ( { items } ) => items . map ( ( { fields } ) => ( {
2929 ...fields ,
30- image : fields . image ?. fields
30+ image : fields . image ?. fields ,
31+ imageDark : fields . imageDark ?. fields // optional, for darkmode, eg white text variant
3132 } ) ) )
3233 return items
3334}
You can’t perform that action at this time.
0 commit comments