// Formate: Übersicht aus der Formatbibliothek, mit Nutzung im Redaktionsplan. import { S, schublade } from "../app.js"; import { heute, kurzDatum, esc, md, mdInline, ohneMd, codes, dokLink, pille, FUNNEL_NAME } from "../hilfen.js"; const QUELLE = "Ressourcen/Formatbibliothek.md"; let cache = { zeit: null, daten: null }; // Liest die Formatbibliothek: die Übersichtstabelle und die Abschnitte je Format. export async function formatbibliothek() { const zeit = S.stand?.dokumente; if (cache.daten && cache.zeit === zeit) return cache.daten; const text = await fetch("/" + QUELLE.split("/").map(encodeURIComponent).join("/"), { cache: "no-store" }).then((r) => r.text()); const abschnitte = {}; const teile = text.split(/^## /m); const vorspann = teile.shift(); for (const t of teile) { const kopf = t.slice(0, t.indexOf("\n")); const rumpf = t.slice(t.indexOf("\n") + 1); const m = kopf.match(/^(F\d{1,2}b?)\s/); abschnitte[m ? m[1] : kopf.trim()] = { titel: kopf.trim(), rumpf }; } const uebersicht = []; const tabelle = (abschnitte["Übersicht"]?.rumpf || "").split("\n").filter((z) => /^\|\s*F\d/.test(z)); for (const z of tabelle) { const [code, name, herkunft, aufwand, konto, laenge, start] = z.split("|").slice(1, -1).map((x) => x.trim()); uebersicht.push({ code, name, herkunft, aufwand, konto, laenge, start }); } cache = { zeit, daten: { vorspann, abschnitte, uebersicht } }; return cache.daten; } function nutzung(code) { return S.slots.filter((s) => codes(s.format).includes(code) && s.status !== "ausgefallen"); } // Wie das Format für Noah heißt, welche Funnel-Stufe es hat und wie das Thema darin vorkommt. const planFormat = (code) => S.plan.formate.find((f) => f.kuerzel === code) || S.plan.linkedin.find((l) => l.kuerzel === code); const noahName = (code) => planFormat(code)?.noah_name || ""; const funnelZelle = (code) => (planFormat(code)?.funnel ? `${FUNNEL_NAME[planFormat(code).funnel]}` : ""); function imPlan(code, h) { const im = nutzung(code); const naechst = im.find((s) => s.datum >= h); if (!im.length) return `nicht im Plan`; return `${im.length} Mal${naechst ? `ab ${kurzDatum(naechst.datum)}` : ""}`; } export async function zeichnen(main, r) { const h = heute(); const fb = await formatbibliothek(); const liste = [...fb.uebersicht]; // CH steht nur im Redaktionsplan, nicht in der Formatbibliothek. for (const f of S.plan.formate) { if (!liste.some((x) => x.code === f.kuerzel)) { liste.push({ code: f.kuerzel, name: f.name, aufwand: f.aufwand === "mittel" ? "2" : f.aufwand === "leicht" ? "1" : "3", konto: "HiveGrid", start: "laut Redaktionsplan" }); } } const allgemein = fb.abschnitte["Was für alle Reel-Formate gilt"]; const imPlanListe = liste.filter((f) => nutzung(f.code).length); const rest = liste.filter((f) => !nutzung(f.code).length); const aufwandText = (a) => ({ "1": "leicht", "2": "mittel", "3": "hoch", "1 bis 2": "leicht bis mittel" }[String(a)] || String(a)); const zeile = (f, mitPlan) => `
| Format | Funnel | Aufwand | Konto | Im Plan |
|---|
| Format | Funnel | Aufwand | Konto | Start |
|---|
| Idee | Funnel | Aufwand | Baut auf |
|---|---|---|---|
| ${esc(i.name)}${esc(i.text)} | ${FUNNEL_NAME[i.funnel] || ""} | ${esc(i.aufwand)} | ${esc([i.aus === "neu" ? "neu" : i.aus, i.vorbild].filter(Boolean).join(", "))} |
Woher die Formate kommen: Analyse der Inspo-Reels.
`; main.querySelectorAll("[data-format]").forEach((tr) => { tr.onclick = () => { location.hash = `#/formate/${encodeURIComponent(tr.dataset.format)}`; }; }); const code = r.rest[0]; if (!code) return; const abschnitt = fb.abschnitte[code]; const eintrag = liste.find((f) => f.code === code); const im = nutzung(code); schublade(`In der Formatbibliothek gibt es dazu keinen eigenen Abschnitt.
`}