Created
January 16, 2021 17:51
-
-
Save Chester97/1964393487ebe43e21e30108ebc99cb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cyberpunk 2077 - plan aktualizacji, Źródło zdjęć: © CD Projekt Red | Jan Kowal // Pełny string, caption, source | author | |
// Cyberpunk 2077 - plan aktualizacji, Źródło zdjęć: © CD Projekt Red | |
// Źródło zdjęć: © CD Projekt Red | Jan Kowal | |
// Cyberpunk 2077 - plan aktualizacji | |
// source - 'Źródło zdjęć: © SOURCE' | |
// caption - Jeśli jest source to: 'CAPTION, ' | jeśli nie, to: 'CAPTION' | |
// author - Jeśli source to 'SOURCE | AUTHOR' | |
type imageDetailsType = { | |
source?: string, | |
caption?: string, | |
author?: string, | |
isAmp?: boolean | |
} | |
type imgDetailsGeneratorType = (value: imageDetailsType) => String; | |
const foo: imgDetailsGeneratorType = (value) => { | |
const { author, caption, isAmp, source } = value; | |
const captionValue = (caption && isAmp) && `${caption}${!source ? '' : ', '}`; | |
const sourceValue = source && `Źródło zdjęć: © ${source}${(author && !captionValue) ? ' ' : ''}`; | |
const authorValue = author && `${captionValue ? ` | ${author}` : author}`; | |
return [captionValue,sourceValue,authorValue].filter(Boolean).join('').trim(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment