Update wordsCount in page

This commit is contained in:
Hongbo Wu 2022-09-06 11:46:08 +08:00
parent 16524a8b59
commit 97e560c443

View file

@ -94,6 +94,7 @@ import {
updatePage,
} from '../../elastic/pages'
import { searchHighlights } from '../../elastic/highlights'
import wordsCounter from 'word-counting'
export type PartialArticle = Omit<
Article,
@ -257,6 +258,9 @@ export const createArticleResolver = authorized<
const saveTime = new Date()
const slug = generateSlug(parsedContent?.title || croppedPathname)
const wordsCount = wordsCounter(parsedContent?.content || '', {
isHtml: true,
}).wordsCount
const articleToSave: Page = {
id: pageId || '',
userId: uid,
@ -289,6 +293,7 @@ export const createArticleResolver = authorized<
readingProgressAnchorIndex: 0,
state: ArticleSavingRequestStatus.Succeeded,
language: parsedContent?.language,
wordsCount,
}
let archive = false