introducing search params for creating new pages and/or new frontmatter

stuff
This commit is contained in:
Marcell Mars 2021-08-12 01:11:00 +02:00
parent 530290224c
commit 0d2d4bf11e
1 changed files with 36 additions and 7 deletions

View File

@ -42,7 +42,7 @@
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
}
function loadHugoPageMetadata() {
function loadHugoPageMetadata(editHash) {
var el = document.createElement("script");
el.onload = () => {
v = repo.content;
@ -109,7 +109,7 @@
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
title = repo.frontmatter[tkey];
};
el.src = `../js/repo/${location.hash.substring(1)}.js`;
el.src = `../js/repo/${editHash}.js`;
document.body.appendChild(el);
}
@ -152,13 +152,37 @@
}
}
onMount(() => {
loadHugoPageMetadata();
console.dir(frontmatter);
});
function newFrontmatter() {
return Object.entries(frontmatter).filter(val => val[1].length == 0).map(key => key[0])
}
function newTriad() {
let t = {}
t["detail"] = ["triad", 0, "authors", "editors"]
newHasTiers(t)
}
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(() => {
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 +218,11 @@
{/if}
{/each}
{/each}
{#each newFrontmatter() as nf}
{#if nf == "triad"}
<div on:click="{newTriad}">NEW TRIAD TIER</div>
{/if}
{/each}
</span>
<div class="formgrid">
<label for="pagecontent">Content:</label>