fixed pageList loading taking too long
This commit is contained in:
parent
ae37fb930d
commit
9f27b34e9e
2 changed files with 6 additions and 5 deletions
|
@ -107,6 +107,11 @@ function recursiveParser(fileOrFolderPath: string) {
|
|||
|
||||
result.posts[urlPath] = parsedMarkdown.data
|
||||
|
||||
// preview
|
||||
// might cut mid html tag
|
||||
result.posts[urlPath].preview =
|
||||
parsedMarkdown.content.split(" ").slice(0, 20).join(" ") + " ..."
|
||||
|
||||
// date
|
||||
if (!result.posts[urlPath].date) {
|
||||
throw Error(`Date does not exist in file: ${urlPath}`)
|
||||
|
|
|
@ -87,7 +87,6 @@ export default class PostList extends React.Component<
|
|||
|
||||
for (const postPath in posts.posts) {
|
||||
if (this.state.isLimited && howMany <= 0) continue
|
||||
const data = await import(`../data/posts${postPath}.json`)
|
||||
|
||||
const post = posts.posts[postPath]
|
||||
|
||||
|
@ -105,10 +104,7 @@ export default class PostList extends React.Component<
|
|||
<div
|
||||
className="link-color"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: marked(
|
||||
data.content.split(" ").slice(0, 20).join(" ") +
|
||||
"..."
|
||||
),
|
||||
__html: marked(post.preview),
|
||||
}}
|
||||
></div>
|
||||
<small>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue