mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-18 15:09:34 +00:00
feat(原生支持字数统计和阅读时长): 统一使用WordCount组件
(cherry picked from commit d8180e1a783ad50c501b741adc72f2747896bdc1)
This commit is contained in:
@@ -10,6 +10,7 @@ import { getPageContentText } from '@/pages/search/[keyword]'
|
||||
import { getAiSummary } from '@/lib/plugins/aiSummary'
|
||||
import BLOG from '@/blog.config'
|
||||
import { uploadDataToAlgolia } from '@/lib/plugins/algolia'
|
||||
import { countWords } from '@/lib/plugins/wordCount'
|
||||
|
||||
/**
|
||||
* 获取文章的关联推荐文章列表,目前根据标签关联性筛选
|
||||
@@ -115,7 +116,10 @@ export async function processPostData(props, from) {
|
||||
key => props.post.blockMap.block[key]?.value?.parent_id === props.post.id
|
||||
)
|
||||
props.post.toc = getPageTableOfContents(props.post, props.post.blockMap)
|
||||
|
||||
const pageContentText = getPageContentText(props.post, props.post.blockMap)
|
||||
const { wordCount, readTime } = countWords(pageContentText)
|
||||
props.post.wordCount = wordCount
|
||||
props.post.readTime = readTime
|
||||
const aiSummaryAPI = siteConfig('AI_SUMMARY_API')
|
||||
if (aiSummaryAPI) {
|
||||
const post = props.post
|
||||
@@ -131,7 +135,7 @@ export async function processPostData(props, from) {
|
||||
for (let heading of post.toc) {
|
||||
content += heading.text + ' '
|
||||
}
|
||||
content += getPageContentText(post, post.blockMap)
|
||||
content += pageContentText
|
||||
const combinedText = post.title + ' ' + content
|
||||
const truncatedText = combinedText.slice(0, wordLimit)
|
||||
aiSummary = await getAiSummary(
|
||||
|
||||
Reference in New Issue
Block a user