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 SpCandidates from "./SpCandidates.svelte";
import SpJournal from "./SpJournal.svelte";
import SpNotsand from "./SpNotsand.svelte";
import { onMount } from "svelte";
let v = "loading...";
let relpath = "";
@ -15,6 +16,7 @@
let frontmatter = {};
frontmatter["triad"] = [];
frontmatter["ascription"] = [];
frontmatter["journal"] = [];
frontmatter["notsand"] = [];
function keyUp(e) {
@ -42,6 +44,27 @@
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) {
let tiers = [];
let candidates = [];
@ -108,18 +131,10 @@
if (Array.isArray(fmValue)) {
newTier(fmKeyType, fmKey, fmValue);
}
} else if (fmKeyType == "journal") {
frontmatter["journal"] || (frontmatter["journal"] = []);
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 });
}
} else if (!["draft", "iscjklanguage", "title"].includes(fmKey)) {
newFmItem(fmKeyType, fmKey, fmValue);
}
});
hasesCandidates = reckonHasesCandidates();
const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
title = repo.frontmatter[tkey];
@ -188,7 +203,7 @@
document.querySelectorAll(".newtiers").forEach((button) => {
button.style.display = "none";
});
let newtierstitle = document.getElementById("newtierstitle")
let newtierstitle = document.getElementById("newtierstitle");
if (newtierstitle) {
newtierstitle.style.display = "none";
}
@ -196,7 +211,7 @@
document.querySelectorAll(".newtiers").forEach((button) => {
button.style.display = "block";
});
let newtierstitle = document.getElementById("newtierstitle")
let newtierstitle = document.getElementById("newtierstitle");
if (newtierstitle) {
newtierstitle.style.display = "block";
}
@ -285,6 +300,20 @@
<SpJournal {fmItem} />
</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}
{/each}
{/each}
@ -300,6 +329,13 @@
>
ASCRIPTION
</div>
<div
id="newfmitem"
class="newtiers newtierbutton"
on:click={() => newFmItem("notsand", "_new", null)}
>
MISC
</div>
</div>
</span>
<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" />