diff --git a/apps/wiki.json b/apps/wiki.json index 727fcf03..738cc48b 100644 --- a/apps/wiki.json +++ b/apps/wiki.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "📝", - "previous": "&kjbXfJac0FNZnkr+TlnKjbJOQ/Ktw5C/TWjXu/i6IWs=.sha256" + "previous": "&S0BU5A5u3ltu0+QZn+wANrO/sx+nqi4vQLs2t5Rwm/I=.sha256" } \ No newline at end of file diff --git a/apps/wiki/tf-wiki-doc.js b/apps/wiki/tf-wiki-doc.js index a944b07b..9c43175d 100644 --- a/apps/wiki/tf-wiki-doc.js +++ b/apps/wiki/tf-wiki-doc.js @@ -43,6 +43,29 @@ class TfWikiDocElement extends LitElement { return writer.render(parsed); } + summary(md) { + let lines = (md || '').split('\n'); + let result = []; + let have_content = false; + for (let line of lines) { + if (have_content && !line.trim().length) { + return result.join('\n'); + } + if (!line.startsWith('#') && line.trim().length) { + have_content = true; + } + result.push(line); + } + return result.join('\n'); + } + + thumbnail(md) { + //let m = md ? md.match(/\!\[image:[^\]]+]\((\&.{44}\.sha256)\)/) : undefined; + let m = md ? md.match(/.*\((\&.{44}\.sha256)\).*/) : undefined; + console.log('thumb', m); + return m ? m[1] : undefined; + } + async load_blob() { let blob = await tfrpc.rpc.get_blob(this.value?.blob); if (blob.endsWith('.box')) { @@ -171,6 +194,7 @@ class TfWikiDocElement extends LitElement { this.load_blob(); } let self = this; + let thumbnail_ref = this.thumbnail(this.blob); return html`