git ssb

7+

dinoworm 🐛 / patchcore



Commit 9b421343eb76d9c775a0f125bdc96770f966c4ea

message.async.name: handle blog titles

Matt McKegg committed on 4/10/2018, 9:16:21 AM
Parent: 4ce4ef5db3d9c2b861e196de6bbf9f82064c8064

Files changed

message/async/name.jschanged
message/async/name.jsView
@@ -27,8 +27,10 @@
2727 } else if (value && value.content.type === 'post' && typeof value.content.text === 'string') {
2828 if (value.content.text.trim()) {
2929 return cb(null, titleFromMarkdown(value.content.text, 40) || fallbackName)
3030 }
31 + } else if (value && typeof value.content.title === 'string') {
32 + return cb(null, truncate(value.content.title, 40))
3133 } else if (value && typeof value.content.text === 'string') {
3234 return cb(null, value.content.type + ': ' + titleFromMarkdown(value.content.text, 30))
3335 } else {
3436 return getAboutName(id, cb)
@@ -52,9 +54,14 @@
5254 text = text.trim().split('\n', 3).join('\n')
5355 text = text.replace(/_|`|\*|#|^\[@.*?]|\[|]|\(\S*?\)/g, '').trim()
5456 text = text.replace(/:$/, '')
5557 text = text.trim().split('\n', 1)[0].trim()
56- if (text.length > max) {
57- text = text.substring(0, max - 2) + '...'
58 + text = truncate(text, max)
59 + return text
60 +}
61 +
62 +function truncate (text, maxLength) {
63 + if (text.length > maxLength) {
64 + text = text.substring(0, maxLength - 2) + '...'
5865 }
5966 return text
6067 }

Built with git-ssb-web