Compare commits
4 commits
40eb55bb04
...
2753be8450
Author | SHA1 | Date | |
---|---|---|---|
2753be8450 | |||
0d2d4bf11e | |||
530290224c | |||
67a7c272dd |
3 changed files with 69 additions and 36 deletions
|
@ -7,7 +7,7 @@
|
||||||
<title>Sandpoints Edit Page</title>
|
<title>Sandpoints Edit Page</title>
|
||||||
|
|
||||||
<link rel='stylesheet' href='global.css'>
|
<link rel='stylesheet' href='global.css'>
|
||||||
<script defer src='metasp.js'></script>
|
<script defer src='../metadata/index.js'></script>
|
||||||
<script defer src='build/bundle.js'></script>
|
<script defer src='build/bundle.js'></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
let hases = [];
|
let hases = [];
|
||||||
let hasesCandidates = [];
|
let hasesCandidates = [];
|
||||||
let frontmatter = {};
|
let frontmatter = {};
|
||||||
|
let frontmatterLoaded = false;
|
||||||
frontmatter["triad"] = [];
|
frontmatter["triad"] = [];
|
||||||
frontmatter["ascriptions"] = [];
|
frontmatter["ascriptions"] = [];
|
||||||
frontmatter["notsand"] = [];
|
frontmatter["notsand"] = [];
|
||||||
|
@ -38,11 +39,11 @@
|
||||||
tiers: [],
|
tiers: [],
|
||||||
candidates: METASP[newFmKey].tiers,
|
candidates: METASP[newFmKey].tiers,
|
||||||
};
|
};
|
||||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
|
||||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
||||||
|
hasesCandidates = [...hasesCandidates, oldFmKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadHugoPageMetadata() {
|
function loadHugoPageMetadata(editHash) {
|
||||||
var el = document.createElement("script");
|
var el = document.createElement("script");
|
||||||
el.onload = () => {
|
el.onload = () => {
|
||||||
v = repo.content;
|
v = repo.content;
|
||||||
|
@ -53,7 +54,8 @@
|
||||||
relpath = repo.path;
|
relpath = repo.path;
|
||||||
relpermalink = repo.relpermalink;
|
relpermalink = repo.relpermalink;
|
||||||
protocol = document.location.protocol.substring(0, 4);
|
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]) => {
|
Object.entries(repo.frontmatter).forEach(([fmKey, fmValue]) => {
|
||||||
let fmKeyType = "";
|
let fmKeyType = "";
|
||||||
if (fmKey.toLowerCase().startsWith("has_")) {
|
if (fmKey.toLowerCase().startsWith("has_")) {
|
||||||
|
@ -108,8 +110,9 @@
|
||||||
|
|
||||||
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
||||||
title = repo.frontmatter[tkey];
|
title = repo.frontmatter[tkey];
|
||||||
|
frontmatterLoaded = true;
|
||||||
};
|
};
|
||||||
el.src = `../js/repo/${location.hash.substring(1)}.js`;
|
el.src = `../js/repo/${editHash}.js`;
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,13 +155,40 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function newFrontmatter() {
|
||||||
|
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() {
|
||||||
|
newHasTiers({"detail": ["triad", 0, "authors", "editors"]})
|
||||||
|
}
|
||||||
|
|
||||||
|
function dispatchHash() {
|
||||||
|
var searchParams = new URLSearchParams(location.search);
|
||||||
|
let editHash = searchParams.get('edit')
|
||||||
|
if (editHash) {
|
||||||
|
loadHugoPageMetadata(editHash)
|
||||||
|
} else {
|
||||||
|
let newPage = searchParams.get('new')
|
||||||
|
console.log(newPage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
loadHugoPageMetadata();
|
dispatchHash();
|
||||||
|
// loadHugoPageMetadata();
|
||||||
console.dir(frontmatter);
|
console.dir(frontmatter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$: hashChanged = ()=> dispatchHash();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keyup={keyUp} />
|
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
||||||
<main id="sandpoints">
|
<main id="sandpoints">
|
||||||
<form>
|
<form>
|
||||||
<div class="formgrid">
|
<div class="formgrid">
|
||||||
|
@ -194,6 +224,9 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
|
{#if frontmatterLoaded && checkTriad()}
|
||||||
|
<div on:click="{newTriad}">NEW TRIAD TIER</div>
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
<div class="formgrid">
|
<div class="formgrid">
|
||||||
<label for="pagecontent">Content:</label>
|
<label for="pagecontent">Content:</label>
|
||||||
|
|
Loading…
Add table
Reference in a new issue