1
Fork 0
mirror of https://github.com/glassflame/glassflame.github.io.git synced 2024-11-23 00:24:25 +00:00

Failed wikilink support attempt

This commit is contained in:
Steffo 2023-10-27 10:28:55 +02:00
parent ef70257b53
commit ce594624dc
2 changed files with 17 additions and 2 deletions

View file

@ -1,4 +1,4 @@
import {fileDetails} from "../utils/file.mjs"; import {fileDetails, filePath} from "../utils/file.mjs";
/** /**
* The body element for the pages viewer, handling most low-level things. * The body element for the pages viewer, handling most low-level things.
@ -34,6 +34,21 @@ export class BrowseElement extends HTMLBodyElement {
return url return url
} }
urlName(name) {
if(name.startsWith(".")) {
const path = filePath(name).join("/")
return this.urlFor({path})
}
else if(!name.includes("/")) {
const path = `${fileDetails(this.parameters.path).directory}/${name}.md`
return this.urlFor({path})
}
else {
const path = filePath(name).join("/")
return this.urlFor({path})
}
}
// TODO: Add a landing page // TODO: Add a landing page
/** /**

View file

@ -69,7 +69,7 @@ export class WikilinkElement extends CustomElement {
} }
resetAnchorElementProperties() { resetAnchorElementProperties() {
this.anchorElement.href = this.browseElement.urlFor({path: this.target}) this.anchorElement.href = this.browseElement.urlName(this.target)
this.anchorElement.innerText = this.text this.anchorElement.innerText = this.text
} }