forked from cory/tildefriends
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:
parent
99998aac8a
commit
023731fc3f
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "📝",
|
"emoji": "📝",
|
||||||
"previous": "&4lapemQFDuH+5ZeI831O8Qk+nK+47xLdHvKU6x53j2A=.sha256"
|
"previous": "&mxGlepLtpWc3IOzgZAKI5gz52tGb+r20LA+aI1qZL1g=.sha256"
|
||||||
}
|
}
|
@ -43,6 +43,16 @@ class TfWikiDocElement extends LitElement {
|
|||||||
return writer.render(parsed);
|
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) {
|
summary(md) {
|
||||||
let lines = (md || '').split('\n');
|
let lines = (md || '').split('\n');
|
||||||
let result = [];
|
let result = [];
|
||||||
@ -54,7 +64,9 @@ class TfWikiDocElement extends LitElement {
|
|||||||
if (!line.startsWith('#') && line.trim().length) {
|
if (!line.startsWith('#') && line.trim().length) {
|
||||||
have_content = true;
|
have_content = true;
|
||||||
}
|
}
|
||||||
result.push(line);
|
if (!line.startsWith('#')) {
|
||||||
|
result.push(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result.join('\n');
|
return result.join('\n');
|
||||||
}
|
}
|
||||||
@ -124,6 +136,7 @@ class TfWikiDocElement extends LitElement {
|
|||||||
type: 'blog',
|
type: 'blog',
|
||||||
key: this.value.id,
|
key: this.value.id,
|
||||||
parent: this.value.parent,
|
parent: this.value.parent,
|
||||||
|
title: this.title(blob),
|
||||||
summary: this.summary(blob),
|
summary: this.summary(blob),
|
||||||
thumbnail: this.thumbnail(blob),
|
thumbnail: this.thumbnail(blob),
|
||||||
blog: id,
|
blog: id,
|
||||||
@ -231,6 +244,7 @@ class TfWikiDocElement extends LitElement {
|
|||||||
<div style="flex: 1 1">
|
<div style="flex: 1 1">
|
||||||
<div ?hidden=${!this.is_editing} style="border: 1px solid #fff; border-radius: 1em; padding: 0.5em">
|
<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">
|
<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)))}
|
${unsafeHTML(this.markdown(this.summary(this.blob)))}
|
||||||
</div>
|
</div>
|
||||||
${unsafeHTML(this.markdown(this.blob))}
|
${unsafeHTML(this.markdown(this.blob))}
|
||||||
|
Loading…
Reference in New Issue
Block a user