feat: support full formatting of summary

This commit is contained in:
jinhojang6 2024-05-23 02:21:59 +09:00
parent 775d74ed34
commit 5683afcfe9
5 changed files with 24 additions and 9 deletions

View File

@ -1,3 +1,4 @@
import { removeDynamicSection } from '@/utils/html.utils'
import { lsdUtils } from '@/utils/lsd.utils'
import { Typography } from '@acid-info/lsd-react'
import styled from '@emotion/styled'
@ -7,14 +8,20 @@ type Props = {
className?: string
showLabel?: boolean
}
const ArticleSummary = ({ summary, className, showLabel }: Props) => (
<ArticleSummaryContainer className={className}>
{showLabel && <Typography variant="body3">summary</Typography>}
<SummaryParagraph variant="h6" component={'p'}>
{summary}
</SummaryParagraph>
</ArticleSummaryContainer>
)
const ArticleSummary = ({ summary, className, showLabel }: Props) => {
return (
<ArticleSummaryContainer className={className}>
{showLabel && <Typography variant="body3">summary</Typography>}
<SummaryParagraph
variant="h6"
component={'div'}
dangerouslySetInnerHTML={{
__html: removeDynamicSection(summary),
}}
></SummaryParagraph>
</ArticleSummaryContainer>
)
}
const ArticleSummaryContainer = styled('div')`
display: block;
@ -30,6 +37,7 @@ const ArticleSummaryContainer = styled('div')`
const SummaryParagraph = styled(Typography)`
display: block;
padding: 24px 0;
white-space: pre-wrap;
${(props) => lsdUtils.breakpoint(props.theme, 'sm', 'down')} {
${lsdUtils.typography('subtitle1')}

View File

@ -18,6 +18,7 @@ export type EpisodeHeaderProps = LPE.Podcast.Document & {
const EpisodeHeader = ({
channel,
summary,
title,
description,
publishedAt,
@ -59,7 +60,7 @@ const EpisodeHeader = ({
<TagsAndSocial tags={tags.map((tag) => tag.name)} />
{channels && <EpisodeChannels channels={channels} />}
{description && (
<ArticleSummary summary={description} showLabel={false} />
<ArticleSummary summary={summary ?? description} showLabel={false} />
)}
</EpisodeHeaderContainer>
)

View File

@ -111,6 +111,7 @@ export const postTransformer: Transformer<
authors,
content,
episodeNumber: attributes.episode_number,
summary: attributes.summary,
showId: attributes.podcast_show.data?.id || null,
modifiedAt: publishedAt,
// will be filled in later

View File

@ -239,6 +239,7 @@ export namespace LPE {
isDraft?: boolean
coverImage?: Image.Document
show?: Show
summary?: string
type: typeof LPE.PostTypes.Podcast
}

View File

@ -80,3 +80,7 @@ export function extractContentFromHTML(htmlString: string) {
return null
}
}
export function removeDynamicSection(input: string) {
return input.replace(/<section[^>]*>.*?<\/section>/gs, '')
}