diff --git a/src/App.svelte b/src/App.svelte index c6505ea..3931250 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -10,10 +10,11 @@ let relpermalink = ""; let protocol = ""; let title = "Foo bar"; - let hases = []; - let hasesCandidates = []; - let frontmatter = {}; - frontmatter["triad"] = []; + let hases = []; + let hasesCandidates = []; + let frontmatter = {}; + let frontmatterLoaded = false; + frontmatter["triad"] = []; frontmatter["ascriptions"] = []; frontmatter["notsand"] = []; @@ -38,8 +39,8 @@ tiers: [], candidates: METASP[newFmKey].tiers, }; - hasesCandidates = [...hasesCandidates, oldFmKey]; hasesCandidates = hasesCandidates.filter((h) => h != newFmKey); + hasesCandidates = [...hasesCandidates, oldFmKey]; } function loadHugoPageMetadata(editHash) { @@ -53,7 +54,8 @@ relpath = repo.path; relpermalink = repo.relpermalink; protocol = document.location.protocol.substring(0, 4); - hases = Object.keys(METASP); + let notSelf = Object.entries(METASP).filter(n => n[1].singular == relpath.split("/")[0])[0][0] + hases = Object.keys(METASP).filter(k => k != notSelf); Object.entries(repo.frontmatter).forEach(([fmKey, fmValue]) => { let fmKeyType = ""; if (fmKey.toLowerCase().startsWith("has_")) { @@ -77,7 +79,7 @@ if (fmValue.includes(t.file)) { tiers.push(t); } else { - candidates.push(t); + candidates.push(t); } }); frontmatter[fmKeyType].push({ @@ -108,6 +110,7 @@ let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0]; title = repo.frontmatter[tkey]; + frontmatterLoaded = true; }; el.src = `../js/repo/${editHash}.js`; document.body.appendChild(el); @@ -156,10 +159,13 @@ return Object.entries(frontmatter).filter(val => val[1].length == 0).map(key => key[0]) } + function checkTriad() { + let ct = Object.entries(frontmatter).filter(i => i[1].length == 0 && i[0] == "triad") + return ct.length == 0 ? false : true + } + function newTriad() { - let t = {} - t["detail"] = ["triad", 0, "authors", "editors"] - newHasTiers(t) + newHasTiers({"detail": ["triad", 0, "authors", "editors"]}) } function dispatchHash() { @@ -218,11 +224,9 @@ {/if} {/each} {/each} - {#each newFrontmatter() as nf} - {#if nf == "triad"} -
NEW TRIAD TIER
- {/if} - {/each} + {#if frontmatterLoaded && checkTriad()} +
NEW TRIAD TIER
+ {/if}