aboutsummaryrefslogtreecommitdiffstats
path: root/app/directory.ts
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2021-12-21 22:40:00 +0000
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2021-12-21 22:40:00 +0000
commit26df7ae8845ed3c2fe47456a7eff76ecb6d89e5e (patch)
treee211995557d901fcc7b7b7647448030ae29f393d /app/directory.ts
parent9250be8a1b0b5a6478130a0fd6a832754ac863b0 (diff)
Fix transclusion for templates
Diffstat (limited to 'app/directory.ts')
-rw-r--r--app/directory.ts28
1 files changed, 21 insertions, 7 deletions
diff --git a/app/directory.ts b/app/directory.ts
index a38b5a0..c5c42e7 100644
--- a/app/directory.ts
+++ b/app/directory.ts
@@ -34,13 +34,27 @@ export class PageDirectory {
pages.forEach(page => {
page = page.replace('.wiki', '').replace('/', ':').replace(/[^a-z0-9:]/gi, '_').toLowerCase();
- this.pages[page] = this.buildPage(page);
+ this.pages[page] = {
+ standardName: page,
+ buildTime: 0,
+ metadata: {}
+ }
+ });
+
+ // Build templates first
+ Object.keys(this.pages).forEach(name => {
+ if (name.includes('Template:')) {
+ this.pages[name] = this.buildPage(name);
+ }
});
const primaryPages = [];
- Object.entries(this.pages).forEach(([_, page]) => {
- if (page.metadata.includeInNavbar) {
- primaryPages.push(page);
+ Object.keys(this.pages).forEach(name => {
+ if (!name.includes('Template:')) {
+ this.pages[name] = this.buildPage(name);
+ }
+ if (this.pages[name].metadata.includeInNavbar) {
+ primaryPages.push(this.pages[name]);
}
});
@@ -148,7 +162,7 @@ export class PageDirectory {
} catch {
return undefined;
}
- const result = parse(data);
+ const result = parse(this, data);
const title = result.metadata.displayTitle ?? name
const content = `${result.metadata.notitle ? '' : `<h1>${title}</h1>`}${result.html}`;
@@ -193,8 +207,8 @@ export class PageDirectory {
}
export type Page = {
- html: string;
- raw: string;
+ html?: string;
+ raw?: string;
standardName: string,
buildTime: number;
metadata: PageMetadata;