Make the wiki app produce the blog title.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4668 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-12-09 19:35:41 +00:00
parent 99998aac8a
commit 023731fc3f
2 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "📝",
"previous": "&4lapemQFDuH+5ZeI831O8Qk+nK+47xLdHvKU6x53j2A=.sha256"
"previous": "&mxGlepLtpWc3IOzgZAKI5gz52tGb+r20LA+aI1qZL1g=.sha256"
}

View File

@ -43,6 +43,16 @@ class TfWikiDocElement extends LitElement {
return writer.render(parsed);
}
title(md) {
let lines = (md || '').split('\n');
for (let line of lines) {
let m = line.match(/#+ (.*)/);
if (m) {
return m[1];
}
}
}
summary(md) {
let lines = (md || '').split('\n');
let result = [];
@ -54,8 +64,10 @@ class TfWikiDocElement extends LitElement {
if (!line.startsWith('#') && line.trim().length) {
have_content = true;
}
if (!line.startsWith('#')) {
result.push(line);
}
}
return result.join('\n');
}
@ -124,6 +136,7 @@ class TfWikiDocElement extends LitElement {
type: 'blog',
key: this.value.id,
parent: this.value.parent,
title: this.title(blob),
summary: this.summary(blob),
thumbnail: this.thumbnail(blob),
blog: id,
@ -231,6 +244,7 @@ class TfWikiDocElement extends LitElement {
<div style="flex: 1 1">
<div ?hidden=${!this.is_editing} style="border: 1px solid #fff; border-radius: 1em; padding: 0.5em">
<img ?hidden=${!thumbnail_ref} style="max-width: 128px; max-height: 128px; float: right" src="/${thumbnail_ref}/view">
<h1 ?hidden=${!this.title(this.blob)}>${unsafeHTML(this.markdown(this.title(this.blob)))}</h1>
${unsafeHTML(this.markdown(this.summary(this.blob)))}
</div>
${unsafeHTML(this.markdown(this.blob))}