fix(description): make sure to we join space correctly (#970)
Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
		@@ -39,29 +39,29 @@ export const Description: QuartzTransformerPlugin<Partial<Options> | undefined>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            const desc = frontMatterDescription ?? text
 | 
					            const desc = frontMatterDescription ?? text
 | 
				
			||||||
            const sentences = desc.replace(/\s+/g, " ").split(/\.\s/)
 | 
					            const sentences = desc.replace(/\s+/g, " ").split(/\.\s/)
 | 
				
			||||||
            let finalDesc = ""
 | 
					            const finalDesc: string[] = []
 | 
				
			||||||
            let sentenceIdx = 0
 | 
					 | 
				
			||||||
            const len = opts.descriptionLength
 | 
					            const len = opts.descriptionLength
 | 
				
			||||||
 | 
					            let sentenceIdx = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (sentences[0] !== undefined && sentences[0].length >= len) {
 | 
					            if (sentences[0] !== undefined && sentences[0].length >= len) {
 | 
				
			||||||
              const firstSentence = sentences[0].split(" ")
 | 
					              const firstSentence = sentences[0].split(" ")
 | 
				
			||||||
              while (finalDesc.length < len) {
 | 
					              while (finalDesc.length < len) {
 | 
				
			||||||
                const sentence = firstSentence[sentenceIdx]
 | 
					                const sentence = firstSentence[sentenceIdx]
 | 
				
			||||||
                if (!sentence) break
 | 
					                if (!sentence) break
 | 
				
			||||||
                finalDesc += sentence + " "
 | 
					                finalDesc.push(sentence)
 | 
				
			||||||
                sentenceIdx++
 | 
					                sentenceIdx++
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
              finalDesc = finalDesc.trimEnd() + "..."
 | 
					              finalDesc.push("...")
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              while (finalDesc.length < len) {
 | 
					              while (finalDesc.length < len) {
 | 
				
			||||||
                const sentence = sentences[sentenceIdx]
 | 
					                const sentence = sentences[sentenceIdx]
 | 
				
			||||||
                if (!sentence) break
 | 
					                if (!sentence) break
 | 
				
			||||||
                finalDesc += sentence.endsWith(".") ? sentence : sentence + "."
 | 
					                finalDesc.push(sentence.endsWith(".") ? sentence : sentence + ".")
 | 
				
			||||||
                sentenceIdx++
 | 
					                sentenceIdx++
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            file.data.description = finalDesc
 | 
					            file.data.description = finalDesc.join(" ")
 | 
				
			||||||
            file.data.text = text
 | 
					            file.data.text = text
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user