bajo-template 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -3
- package/package.json +1 -1
- package/wiki/CHANGES.md +4 -0
package/index.js
CHANGED
|
@@ -332,12 +332,16 @@ async function factory (pkgName) {
|
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
// based on: https://medium.com/@paulohfev/problem-solving-how-to-create-an-excerpt-fdb048687928
|
|
335
|
-
getExcerpt = (content, maxWords = 50, trailChars = '...') => {
|
|
335
|
+
getExcerpt = (content = '', maxWords = 50, trailChars = '...') => {
|
|
336
336
|
const listOfWords = content.trim().split(' ')
|
|
337
337
|
const truncatedContent = listOfWords.slice(0, maxWords).join(' ')
|
|
338
338
|
const excerpt = truncatedContent + trailChars
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
return listOfWords.length > maxWords ? excerpt : content
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
getTruncated = (content = '', maxChars = 50, trailChars = '...') => {
|
|
343
|
+
const truncated = content.slice(0, maxChars)
|
|
344
|
+
return truncated.length !== content.length ? (truncated + trailChars) : content
|
|
341
345
|
}
|
|
342
346
|
}
|
|
343
347
|
|
package/package.json
CHANGED