resolve conflict 3

This commit is contained in:
jinhojang6 2023-05-14 17:40:39 +09:00 committed by Jinho Jang
parent 50ed7c1d38
commit 68891f0135
5 changed files with 34 additions and 10 deletions

View File

@ -48,7 +48,7 @@ export const RenderArticleBlock = ({
component={block.tagName as any}
genericFontFamily="sans-serif"
className={extractClassFromFirstTag(block.html) || ''}
id={extractIdFromFirstTag(block.html) || ''}
id={extractIdFromFirstTag(block.html) || `p-${block.order}`}
dangerouslySetInnerHTML={{ __html: extractInnerHtml(block.html) }}
/>
)

View File

@ -7,6 +7,8 @@ import ArticleStats from '../Article.Stats'
import { Typography } from '@acid-info/lsd-react'
import styled from '@emotion/styled'
import ArticleSummary from './Article.Summary'
import { UnbodyGraphQl } from '../../../lib/unbody/unbody-content.types'
import { calcReadingTime } from '@/utils/string.utils'
import { Authors } from '@/components/Authors'
import { Tags } from '@/components/Tags'
@ -31,9 +33,24 @@ const ArticleHeader = ({
)
}, [blocks])
const readingTime = useMemo(() => {
return calcReadingTime(
blocks
.map((block) => {
if (
block.__typename === UnbodyGraphQl.UnbodyDocumentTypeNames.TextBlock
) {
return block.text
}
return ''
})
.join(' '),
)
}, [blocks])
return (
<header>
<ArticleStats dateStr={modifiedAt} readingLength={3} />
<ArticleStats dateStr={modifiedAt} readingLength={readingTime} />
<ArticleTitle
id={toc[0].href.substring(1)}
variant={'h1'}

View File

@ -12,7 +12,6 @@ import {
import { Authors } from '../Authors'
import { UnbodyGraphQl } from '@/lib/unbody/unbody-content.types'
import { Tags } from '@/components/Tags'
import { ResponsiveImage } from '../ResponsiveImage/ResponsiveImage'
import {
ResponsiveImage,
ResponsiveImageProps,

View File

@ -175,6 +175,7 @@ export default function Searchbar(props: SearchbarProps) {
</IconButton>
</div>
</SearchBox>
{!isArticlePage && (
<TagsWrapper className={active ? 'active' : ''}>
<FilterTags
tags={copyConfigs.search.filterTags}
@ -182,6 +183,7 @@ export default function Searchbar(props: SearchbarProps) {
selectedTags={filterTags}
/>
</TagsWrapper>
)}
{resultsNumber !== null && (
<ResultsStatus>
<Typography variant={'subtitle2'}>{resultsNumber} matches</Typography>

View File

@ -35,3 +35,9 @@ function editDistance(s1: string, s2: string) {
}
return costs[s2.length]
}
export const calcReadingTime = (text: string): number => {
const wordsPerMinute = 200
const numberOfWords = text.split(/\s/g).length
return Math.ceil(numberOfWords / wordsPerMinute)
}