diff --git a/src/App.svelte b/src/App.svelte index 9dfee3c..4bd8e4b 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -14,6 +14,7 @@ let hases = []; let hasesCandidates = []; let frontmatter = {}; + let formaction = "edit"; frontmatter["triad"] = []; frontmatter["ascription"] = []; frontmatter["journal"] = []; @@ -65,6 +66,12 @@ toggleNewTiersButtons(); } + function swapTier(arrg) { + const [fmKeyType, fmKey, oldFmKey] = arrg.detail; + removeTier(fmKeyType, oldFmKey); + newTier(fmKeyType, fmKey, null); + } + function newTier(fmKeyType, fmKey, fmValue) { let tiers = []; let candidates = []; @@ -88,6 +95,7 @@ tiers = []; candidates = METASP[fmKey].tiers; } + frontmatter[fmKeyType].push({ fmKey: fmKey, tiers: tiers, @@ -95,6 +103,7 @@ }); frontmatter = { ...frontmatter }; } + hasesCandidates = [...new Set(reckonHasesCandidates())]; toggleNewTiersButtons(); } @@ -109,7 +118,6 @@ relpath = repo.path; relpermalink = repo.relpermalink; - protocol = document.location.protocol.substring(0, 4); const 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]) => { @@ -198,7 +206,6 @@ function toggleNewTiersButtons() { hasesCandidates = [...new Set(reckonHasesCandidates())]; - if (hasesCandidates.length == 0) { document.querySelectorAll(".newtiers").forEach((button) => { button.style.display = "none"; @@ -216,13 +223,19 @@ } function dispatchHash() { + protocol = document.location.protocol.substring(0, 4); const searchParams = new URLSearchParams(location.search); const editHash = searchParams.get("edit"); if (editHash) { loadHugoPageMetadata(editHash); } else { let newPage = searchParams.get("new"); - console.log({ newPage }); + formaction = "new"; + v = "waiting for your input here..."; + title = "Please, change this title..."; + relpath = `${newPage}/newfile.md`; + hases = Object.keys(METASP).filter((k) => k != newPage); + toggleNewTiersButtons(); } } @@ -239,7 +252,7 @@
- +
Frontmatter
@@ -257,12 +270,11 @@
- +