Commit 3a096e1d authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

handle missing author

parent 2fe5d05e
Pipeline #1787 passed with stage
in 2 minutes
......@@ -29,7 +29,7 @@ export function List({ subtags, tag, content, metadata, file, config }) {
<div className="col">
<a className="breadcrumb">{tag.text}</a>
{subtags &&
subtags.map(subtag => (
subtags.map((subtag) => (
<React.Fragment key={subtag.url}>
{' '}
<a href={`/${subtag.url}`} className="chip">
......@@ -48,7 +48,7 @@ export function List({ subtags, tag, content, metadata, file, config }) {
justifyContent: 'space-between',
}}
>
{content.map(page => (
{content.map((page) => (
<Card
key={page.file}
file={page.file}
......@@ -63,13 +63,7 @@ export function List({ subtags, tag, content, metadata, file, config }) {
? truncate(striptags(page.content))
: null
}
caption={
<>
{dateFilter(page.metadata.published, 'D. M. YYYY')} napsal
{page.metadata.author.gender === 'F' ? 'a' : ''}{' '}
{page.metadata.author.name}
</>
}
caption={<Caption metadata={page.metadata} />}
/>
))}
</div>
......@@ -144,6 +138,20 @@ export function List({ subtags, tag, content, metadata, file, config }) {
)
}
function Caption({ metadata }: { metadata: { [key: string]: any } }) {
return (
<>
{dateFilter(metadata.published, 'D. M. YYYY')}{' '}
{metadata.author ? (
<>
napsal
{metadata.author.gender === 'F' ? 'a' : ''} {metadata.author.name}
</>
) : null}
</>
)
}
function Card({ file, image, title, text, caption }) {
return (
<div
......
......@@ -106,10 +106,16 @@ function Article({ metadata, content, config, file }) {
<span style={{ color: '#626262' }}>
{dateFilter(metadata.published, 'D. M. YYYY')}
</span>
{metadata.author.gender === 'F' ? ' napsala ' : ' napsal '}
<span style={{ color: '#626262' }}>
{metadata.author.name}
</span>
{metadata.author ? (
<>
{metadata.author.gender === 'F'
? ' napsala '
: ' napsal '}
<span style={{ color: '#626262' }}>
{metadata.author.name}
</span>{' '}
</>
) : null}
</>
) : (
<>Článek nebyl publikován</>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment