fixed pageList loading taking too long

This commit is contained in:
Kim, Jimin 2021-06-22 22:34:40 +09:00
parent ae37fb930d
commit 9f27b34e9e
2 changed files with 6 additions and 5 deletions

View file

@ -107,6 +107,11 @@ function recursiveParser(fileOrFolderPath: string) {
result.posts[urlPath] = parsedMarkdown.data result.posts[urlPath] = parsedMarkdown.data
// preview
// might cut mid html tag
result.posts[urlPath].preview =
parsedMarkdown.content.split(" ").slice(0, 20).join(" ") + " ..."
// date // date
if (!result.posts[urlPath].date) { if (!result.posts[urlPath].date) {
throw Error(`Date does not exist in file: ${urlPath}`) throw Error(`Date does not exist in file: ${urlPath}`)

View file

@ -87,7 +87,6 @@ export default class PostList extends React.Component<
for (const postPath in posts.posts) { for (const postPath in posts.posts) {
if (this.state.isLimited && howMany <= 0) continue if (this.state.isLimited && howMany <= 0) continue
const data = await import(`../data/posts${postPath}.json`)
const post = posts.posts[postPath] const post = posts.posts[postPath]
@ -105,10 +104,7 @@ export default class PostList extends React.Component<
<div <div
className="link-color" className="link-color"
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: marked( __html: marked(post.preview),
data.content.split(" ").slice(0, 20).join(" ") +
"..."
),
}} }}
></div> ></div>
<small> <small>