npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

post-meta-extractor

v0.2.0

Published

Framework-agnostic post metadata extractor with optional React, Solid, and Vue wrappers.

Readme

post-meta-extractor

Framework-agnostic post metadata extractor with optional React, Solid, and Vue wrappers.

What This Package Does

  • Extracts metadata from markdown content
  • Works in Node, browser, and SSR contexts
  • Provides deterministic extraction and optional AI-first extraction
  • Provides optional React/Solid/Vue wrapper APIs

What This Package Does Not Do

  • No built-in UI components
  • No database or storage integration
  • No markdown-to-HTML rendering pipeline

Install

npm install post-meta-extractor

Test and Coverage

npm test
npm run test:coverage

Coverage reports are written to ./coverage (HTML report: ./coverage/index.html).

Deep Docs

README is the canonical quickstart and top-level API summary. For deeper guides, use:

Examples

Runnable integration examples across frameworks:

Core Sync API

import { extractPostMeta } from "post-meta-extractor";

const meta = extractPostMeta({
  markdown: `---
title: My Post
aliases: [old-my-post]
tags: [TanStack, Solid]
---
# My Post

First paragraph`,
  sourceSlug: "2026-03-05-my-post",
});

Sync Output

type PostMeta = {
  title: string | null;
  description: string | null;
  date: string | null;
  dateValue: number;
  slug: string;
  aliases: string[];
  thumbnailUrl: string | null;
  tags: string[];
  published: boolean | null;
};

Core Async AI API

import { extractPostMetaWithAI } from "post-meta-extractor";

const result = await extractPostMetaWithAI(
  { markdown: "# AI Post" },
  {
    ai: {
      adapter: {
        name: "my-provider",
        generate: async ({ system, user, schema }) => {
          // call your provider here
          return {
            description: "AI summary",
            tags: ["ai", "metadata"],
          };
        },
      },
      maxRetries: 3,
    },
  },
);

AI Output Additions

type PostMetaAIResult = PostMeta & {
  ai: {
    status: "success" | "failed";
    attempts: number;
    warnings: string[];
    provider?: string;
  };
};

Notes:

  • AI API uses AI for description and tags.
  • AI retries default to 3.
  • After retries fail, description is null and tags is [].
  • AI diagnostics are always included in result.ai.
  • Deterministic fields (title, slug, aliases, thumbnailUrl, date fields) always come from parser logic.

TanStack Start AI Helper

import { createTanStackStartAIAdapter } from "post-meta-extractor/tanstack-start-ai";

const adapter = createTanStackStartAIAdapter(async (payload) => {
  // call TanStack Start AI
  return { description: "summary", tags: ["tanstack"] };
});

API Key Handling

This package does not read or store API keys. You must handle provider keys in your host app and inject an adapter.

Rules:

  • Keep keys in server-side environment variables.
  • Do not expose provider keys to browser/client bundles.
  • Build adapter calls in server/SSR code paths.

TanStack Start (server-side example)

import { extractPostMetaWithAI } from "post-meta-extractor";

const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) throw new Error("Missing OPENAI_API_KEY");

const result = await extractPostMetaWithAI(
  { markdown },
  {
    ai: {
      adapter: {
        name: "openai",
        generate: async ({ system, user, schema }) => {
          // call provider SDK with apiKey in server code
          return { description: "summary", tags: ["tanstack"] };
        },
      },
    },
  },
);

Nuxt (server route example)

// server/api/extract-meta.post.ts
import { extractPostMetaWithAI } from "post-meta-extractor";

export default defineEventHandler(async (event) => {
  const body = await readBody<{ markdown: string }>(event);
  const config = useRuntimeConfig(event);
  const apiKey = config.openaiApiKey; // server runtime config

  const result = await extractPostMetaWithAI(
    { markdown: body.markdown },
    {
      ai: {
        adapter: {
          name: "openai",
          generate: async ({ system, user, schema }) => {
            // call provider SDK with apiKey in server route only
            return { description: "summary", tags: ["nuxt"] };
          },
        },
      },
    },
  );

  return result;
});

React Wrapper

import { usePostMeta, usePostMetaWithAI } from "post-meta-extractor/react";

const syncMeta = usePostMeta({ markdown });
const aiMeta = usePostMetaWithAI({ markdown }, { ai: { adapter } });

usePostMetaWithAI returns:

  • data: PostMetaAIResult | null
  • isLoading: boolean
  • error: Error | null
  • refresh: () => Promise<void>

Solid Wrapper

import { createPostMeta, createPostMetaWithAI } from "post-meta-extractor/solid";

const syncMeta = createPostMeta(() => ({ markdown: props.markdown }));
const aiMeta = createPostMetaWithAI(() => ({ markdown: props.markdown }), { ai: { adapter } });

createPostMetaWithAI returns:

  • data: Accessor<PostMetaAIResult | null>
  • loading: Accessor<boolean>
  • error: Accessor<Error | null>
  • refetch: () => Promise<PostMetaAIResult | null>

Vue/Nuxt Wrapper

import { ref } from "vue";
import { usePostMeta, usePostMetaWithAI } from "post-meta-extractor/vue";

const input = ref({ markdown: "# Hello" });
const syncMeta = usePostMeta(input);
const aiMeta = usePostMetaWithAI(input, { ai: { adapter } });

usePostMetaWithAI returns:

  • data: Ref<PostMetaAIResult | null>
  • isLoading: Ref<boolean>
  • error: Ref<Error | null>
  • refresh: () => Promise<void>

Extraction Rules

  • Frontmatter keys supported: title, date, description, thumbnailUrl, aliases, tags, published
  • Title priority: frontmatter title -> first markdown heading -> fallbackTitle -> null
  • Date priority: frontmatter date -> slug prefix YYYY-MM-DD-* -> null
  • Slug priority: normalized sourceSlug -> normalized title -> "untitled"
  • Aliases source: frontmatter aliases, normalized and deduplicated
  • Thumbnail priority: frontmatter thumbnailUrl -> first markdown image -> null
  • Sync description fallback: first meaningful content line, truncated by maxDescriptionLength (default 180)
  • Sync tags are normalized to lowercase, trimmed, and deduplicated
  • Parser is lenient and does not throw for malformed content
  • AI path validates adapter output shape and retries on invalid/failed responses