Skip to content

Commit

Permalink
Merge pull request #951 from Sitecore/feature/changelog-pdf-support
Browse files Browse the repository at this point in the history
Add support for pdf attachments
  • Loading branch information
markvanaalst authored Jan 29, 2025
2 parents 21fc162 + 210c28d commit efd7eb0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/pages/changelog/[product]/[...entry].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
GridItem,
Heading,
HStack,
Icon,
Image,
Modal,
ModalBody,
Expand All @@ -35,6 +36,7 @@ import {
import { Changelog } from '@lib/changelog';
import { ChangelogEntry, Product } from '@lib/changelog/types';
import { getChangelogEntryUrl, getQueryArray, getSlug, slugify } from '@lib/utils';
import { mdiDownload } from '@mdi/js';
import { Prose } from '@nikolovlazar/chakra-ui-prose';
import ChangelogByMonth from '@src/components/changelog/ChangelogByMonth';
import { ChangelogItemMeta } from '@src/components/changelog/ChangelogItemMeta';
Expand Down Expand Up @@ -133,7 +135,7 @@ const ChangelogProduct = ({ currentProduct, changelogEntry }: ChangelogProps) =>
)}
</CardHeader>
<CardBody py={0}>
{changelogEntry.image.length > 0 && (
{changelogEntry.image.length > 0 && changelogEntry.image[0].fileType.includes('image') && (
<>
<Image src={`${changelogEntry.image[0].fileUrl}`} alt={changelogEntry.title || ''} borderRadius={'lg'} onClick={onOpen} cursor={'zoom-in'} mb={4} maxW={'full'} />

Expand All @@ -158,6 +160,28 @@ const ChangelogProduct = ({ currentProduct, changelogEntry }: ChangelogProps) =>
</>
)}
<Prose margin={0} padding={0} dangerouslySetInnerHTML={{ __html: changelogEntry.description }} />

{changelogEntry.image.filter((img) => img.fileType.includes('pdf')).length > 0 &&
changelogEntry.image
.filter((img) => img.fileType.includes('pdf'))
.map((pdf, index) => {
return (
<LinkButton
key={index}
text="Download PDF"
variant={'outline'}
size={'sm'}
icon={
<Icon>
<path d={mdiDownload} />
</Icon>
}
href={pdf.fileUrl}
title={`Download the PDF ${pdf.name}`}
/>
);
})}

{changelogEntry.fullArticle != null && <Prose margin={0} padding={0} dangerouslySetInnerHTML={{ __html: changelogEntry.fullArticle }} />}
</CardBody>
<CardFooter justifyContent={changelogEntry.readMoreLink ? 'space-between' : 'flex-end'}>
Expand Down

0 comments on commit efd7eb0

Please sign in to comment.