Fix up links to other wiki-doc pages, and reduce the following depth to improve load times.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4631 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-11-14 17:38:48 +00:00
parent 305f5232e7
commit a0043ec49f
3 changed files with 17 additions and 2 deletions

View File

@ -5,6 +5,7 @@ class TfWikiDocElement extends LitElement {
static get properties() {
return {
whoami: {type: String},
wiki: {type: String},
value: {type: Object},
blob: {type: String},
blob_original: {type: String},
@ -21,6 +22,19 @@ class TfWikiDocElement extends LitElement {
var reader = new commonmark.Parser({safe: true});
var writer = new commonmark.HtmlRenderer();
var parsed = reader.parse(md || '');
let walker = parsed.walker();
let event;
while ((event = walker.next())) {
let node = event.node;
if (event.entering) {
if (node.type === 'link') {
if (node.destination.indexOf(':') == -1 &&
node.destination.indexOf('/') == -1) {
node.destination = `#${this.wiki?.name}/${node.destination}`;
}
}
}
}
return writer.render(parsed);
}