// 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) => ` ${esc(f.code)} ${esc(f.name)}${noahName(f.code) ? `Für Noah: ${esc(noahName(f.code))}` : ""} ${funnelZelle(f.code)}${esc(aufwandText(f.aufwand))}${esc(f.konto || "")} ${mitPlan ? `${imPlan(f.code, h)}` : `${esc(f.start || "")}`} `; main.innerHTML = `

Formate

Ein Format ist eine wiederholbare Bauform. Alle Formate tragen dasselbe Thema.
Thema: ${esc(S.plan.thema.name)}
Formatbibliothek lesen

Im Plan ${imPlanListe.length} Formate, zum Öffnen anklicken

${imPlanListe.map((f) => zeile(f, true)).join("")}
FormatFunnelAufwandKontoIm Plan
${rest.length} weitere Formate, noch nicht im Plan
${rest.map((f) => zeile(f, false)).join("")}
FormatFunnelAufwandKontoStart
${S.plan.ideen?.length ? `

Ideen-Pool zum Thema nicht fest im Plan, für Ausfälle und nach T5

${S.plan.ideen.map((i) => ``).join("")}
IdeeFunnelAufwandBaut 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(", "))}
` : ""}

LinkedIn-Postarten Text und Bild

${S.plan.linkedin.map((l) => `
${esc(l.kuerzel)}${esc(l.name)}
Was dahinter steckt${mdInline(l.text)}
${nutzung(l.kuerzel).length} Mal
`).join("")}

Blickwinkel auf das eine Thema

${S.plan.saeulen.map((s) => `
${esc(s.kuerzel)}${esc(s.name)}${esc(s.text || "")} ${S.slots.filter((x) => x.saeule === s.kuerzel).length} Slots
`).join("")}
${allgemein ? `
${esc(allgemein.titel)}
${md(allgemein.rumpf)}
` : ""}

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(`
Format

${esc(abschnitt ? abschnitt.titel : `${code} ${eintrag?.name || ""}`)}

${eintrag ? [`Aufwand ${esc(eintrag.aufwand)}`, eintrag.konto && esc(eintrag.konto), eintrag.laenge && esc(eintrag.laenge)].filter(Boolean).join(", ") + "." : ""}
Im Plan
${im.length ? im.map((s) => `${kurzDatum(s.datum)}, ${esc(ohneMd(s.format))}${s.status !== "geplant" ? ` ${pille(s.status)}` : ""}`).join("
") : `nicht im festen Plan`}
${planFormat(code)?.funnel ? `
Funnel
${funnelZelle(code)}
` : ""} ${planFormat(code)?.thema ? `
Im Thema
${esc(planFormat(code).thema)}
` : ""} ${noahName(code) ? `
Für Noah
${esc(noahName(code))}
` : ""}
${abschnitt ? md(abschnitt.rumpf) : `

In der Formatbibliothek gibt es dazu keinen eigenen Abschnitt.

`}
`, { zurueck: "#/formate", breit: true }); }