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:
@ -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,7 +64,9 @@ class TfWikiDocElement extends LitElement {
|
||||
if (!line.startsWith('#') && line.trim().length) {
|
||||
have_content = true;
|
||||
}
|
||||
result.push(line);
|
||||
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))}
|
||||
|
Reference in New Issue
Block a user