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>
|
||||
|
||||
<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>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
let hases = [];
|
||||
let hasesCandidates = [];
|
||||
let frontmatter = {};
|
||||
let frontmatterLoaded = false;
|
||||
frontmatter["triad"] = [];
|
||||
frontmatter["ascriptions"] = [];
|
||||
frontmatter["notsand"] = [];
|
||||
|
@ -38,11 +39,11 @@
|
|||
tiers: [],
|
||||
candidates: METASP[newFmKey].tiers,
|
||||
};
|
||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
||||
}
|
||||
|
||||
function loadHugoPageMetadata() {
|
||||
function loadHugoPageMetadata(editHash) {
|
||||
var el = document.createElement("script");
|
||||
el.onload = () => {
|
||||
v = repo.content;
|
||||
|
@ -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_")) {
|
||||
|
@ -108,8 +110,9 @@
|
|||
|
||||
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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(() => {
|
||||
loadHugoPageMetadata();
|
||||
dispatchHash();
|
||||
// loadHugoPageMetadata();
|
||||
console.dir(frontmatter);
|
||||
});
|
||||
|
||||
$: hashChanged = ()=> dispatchHash();
|
||||
</script>
|
||||
|
||||
<svelte:window on:keyup={keyUp} />
|
||||
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
||||
<main id="sandpoints">
|
||||
<form>
|
||||
<div class="formgrid">
|
||||
|
@ -194,6 +224,9 @@
|
|||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
{#if frontmatterLoaded && checkTriad()}
|
||||
<div on:click="{newTriad}">NEW TRIAD TIER</div>
|
||||
{/if}
|
||||
</span>
|
||||
<div class="formgrid">
|
||||
<label for="pagecontent">Content:</label>
|
||||
|
|
Loading…
Add table
Reference in a new issue