OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 28 LINES
 
[ HISTORY ]  [ UP ]
 

// Static index consumed by the masthead fuzzy search. `note` doubles
// as the register marker shown next to results.
import type { APIRoute } from "astro";
import { getCollection } from "astro:content";
import { published, topSegment } from "../lib/notes";
import { readManifests, registerOf, registerLabel } from "../lib/registers";

const dirsOf = (id: string) => id.split("/").slice(0, -1).join("/").toUpperCase();

export const GET: APIRoute = async () => {
  const entries = await getCollection("kb", published);
  const manifests = readManifests();
  const data = entries.map((e) => {
    const info = registerOf(e.id, manifests);
    return {
      note: registerLabel(info.register),
      title: e.data.title,
      category: (info.title ?? topSegment(e.id)).toLowerCase(),
      tags: e.data.tags,
      filed: `/KB/${dirsOf(e.id)}`,
      url: `/kb/${e.id}/`,
    };
  });
  return new Response(JSON.stringify(data), {
    headers: { "Content-Type": "application/json" },
  });
};

// Static index consumed by the masthead fuz
zy search. `note` doubles
// as the register marker shown next to resu
lts.
import type { APIRoute } from "astro";
import { getCollection } from "astro:content
";
import { published, topSegment } from "../li
b/notes";
import { readManifests, registerOf, register
Label } from "../lib/registers";

const dirsOf = (id: string) => id.split("/")
.slice(0, -1).join("/").toUpperCase();

export const GET: APIRoute = async () => {
  const entries = await getCollection("kb", 
published);
  const manifests = readManifests();
  const data = entries.map((e) => {
    const info = registerOf(e.id, manifests)
;
    return {
      note: registerLabel(info.register),
      title: e.data.title,
      category: (info.title ?? topSegment(e.
id)).toLowerCase(),
      tags: e.data.tags,
      filed: `/KB/${dirsOf(e.id)}`,
      url: `/kb/${e.id}/`,
    };
  });
  return new Response(JSON.stringify(data), 
{
    headers: { "Content-Type": "application/
json" },
  });
};
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET