initial notsandpoints frontmatter items...

This commit is contained in:
Marcell Mars 2021-08-24 00:49:33 +02:00
parent 8bf7613639
commit 40d853e9c4
2 changed files with 52 additions and 12 deletions

View file

@ -4,6 +4,7 @@
import SpKeys from "./SpKeys.svelte"; import SpKeys from "./SpKeys.svelte";
import SpCandidates from "./SpCandidates.svelte"; import SpCandidates from "./SpCandidates.svelte";
import SpJournal from "./SpJournal.svelte"; import SpJournal from "./SpJournal.svelte";
import SpNotsand from "./SpNotsand.svelte";
import { onMount } from "svelte"; import { onMount } from "svelte";
let v = "loading..."; let v = "loading...";
let relpath = ""; let relpath = "";
@ -15,6 +16,7 @@
let frontmatter = {}; let frontmatter = {};
frontmatter["triad"] = []; frontmatter["triad"] = [];
frontmatter["ascription"] = []; frontmatter["ascription"] = [];
frontmatter["journal"] = [];
frontmatter["notsand"] = []; frontmatter["notsand"] = [];
function keyUp(e) { function keyUp(e) {
@ -42,6 +44,27 @@
return Array.from(diff); return Array.from(diff);
} }
function newFmItem(fmKeyType, fmKey, fmValue) {
if (["abstract", "keywords"].includes(fmKey.toLowerCase())) {
fmKeyType = "journal";
}
if (fmKey == "_new") {
fmKey = `_new${Math.random()}`;
}
if (Array.isArray(fmValue)) {
let fmValueArray = [];
fmValue.forEach((v) => fmValueArray.push(v));
frontmatter[fmKeyType].push({ fmKey: fmKey, fmValue: fmValueArray });
} else {
frontmatter[fmKeyType].push({ fmKey: fmKey, fmValue: fmValue });
}
console.log("newFmItem", { frontmatter });
hasesCandidates = [...new Set(reckonHasesCandidates())];
toggleNewTiersButtons();
}
function newTier(fmKeyType, fmKey, fmValue) { function newTier(fmKeyType, fmKey, fmValue) {
let tiers = []; let tiers = [];
let candidates = []; let candidates = [];
@ -108,18 +131,10 @@
if (Array.isArray(fmValue)) { if (Array.isArray(fmValue)) {
newTier(fmKeyType, fmKey, fmValue); newTier(fmKeyType, fmKey, fmValue);
} }
} else if (fmKeyType == "journal") { } else if (!["draft", "iscjklanguage", "title"].includes(fmKey)) {
frontmatter["journal"] || (frontmatter["journal"] = []); newFmItem(fmKeyType, fmKey, fmValue);
if (Array.isArray(fmValue)) {
let fmValueArray = [];
fmValue.forEach((v) => fmValueArray.push(v));
frontmatter[fmKeyType].push({ fmKey: fmKey, fmValue: fmValueArray });
} else {
frontmatter[fmKeyType].push({ fmKey: fmKey, fmValue: fmValue });
}
} }
}); });
hasesCandidates = reckonHasesCandidates();
const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0]; const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
title = repo.frontmatter[tkey]; title = repo.frontmatter[tkey];
@ -188,7 +203,7 @@
document.querySelectorAll(".newtiers").forEach((button) => { document.querySelectorAll(".newtiers").forEach((button) => {
button.style.display = "none"; button.style.display = "none";
}); });
let newtierstitle = document.getElementById("newtierstitle") let newtierstitle = document.getElementById("newtierstitle");
if (newtierstitle) { if (newtierstitle) {
newtierstitle.style.display = "none"; newtierstitle.style.display = "none";
} }
@ -196,7 +211,7 @@
document.querySelectorAll(".newtiers").forEach((button) => { document.querySelectorAll(".newtiers").forEach((button) => {
button.style.display = "block"; button.style.display = "block";
}); });
let newtierstitle = document.getElementById("newtierstitle") let newtierstitle = document.getElementById("newtierstitle");
if (newtierstitle) { if (newtierstitle) {
newtierstitle.style.display = "block"; newtierstitle.style.display = "block";
} }
@ -285,6 +300,20 @@
<SpJournal {fmItem} /> <SpJournal {fmItem} />
</div> </div>
</div> </div>
{:else if fmItems[0] == "notsand"}
<div class="fmMeta">
<div class="fmMetaTitle">
{fmItems[0]}<button
type="button"
on:click={() => removeTier(fmItems[0], fmItem)}
on:mouseover={fmItemDottedBorder}
on:mouseout={fmItemNoBorder}>×</button
>
</div>
<div class="fmItem">
<SpNotsand />
</div>
</div>
{/if} {/if}
{/each} {/each}
{/each} {/each}
@ -300,6 +329,13 @@
> >
ASCRIPTION ASCRIPTION
</div> </div>
<div
id="newfmitem"
class="newtiers newtierbutton"
on:click={() => newFmItem("notsand", "_new", null)}
>
MISC
</div>
</div> </div>
</span> </span>
<div class="formgrid"> <div class="formgrid">

4
src/SpNotsand.svelte Normal file
View file

@ -0,0 +1,4 @@
<label for="notsandkey">Key:</label>
<input class="notsandkey" type="text" name="notsandkey" />
<label for="notsandvalue">Value:</label>
<input class="notsandvalue" type="text" name="notsandvalue" />