Dev Helpers
← Back

Identify untagged entries

Identify untagged entries. Build the result in an App Router server page and send the rendered entries to the client.

Open this example in the interactive library

Source code

// app/identify-untagged-entries/page.tsx
export const metadata = { title: "Identify untagged entries" };
export default function Page() {
  const rows = [
    { title: "Tide", tags: ["sea", "blue"] },
    { title: "Dune", tags: ["sand", "gold"] },
    { title: "Reef", tags: ["sea", "gold"] },
    { title: "Blank", tags: [] },
  ];
  const result = rows.filter((r) => r.tags.length === 0).map((r) => r.title);
  const entries = Object.entries(
    typeof result === "object" && result !== null ? result : { value: result },
  );
  return (
    <section>
      <h2>{"Identify untagged entries"}</h2>
      {entries.length ? (
        <dl>
          {entries.map(([key, value]) => (
            <div key={key}>
              <dt>{key}</dt>
              <dd>
                {typeof value === "string" ? value : JSON.stringify(value)}
              </dd>
            </div>
          ))}
        </dl>
      ) : (
        <p>No matching entries.</p>
      )}
    </section>
  );
}