Skip to content

blazardsky/madao

Repository files navigation

disclaimer this is an experiment, not guaranteed to work as it depends on how the ai crawls your website. It will hopefully become more useful as time passes and standards are created and adopted

NPM Version NPM Last Update NPM Downloads

MADAO – Making Astro AI-friendly

(no it's not an acronym)

madao is a tiny Astro integration that injects a <link rel="alternate" type="text/markdown" …> tag into every rendered HTML page. The tag points to a generated Markdown representation of the page under a /md/ folder, making the site AI‑ready: LLMs can consume the raw Markdown alongside the HTML. It also generates llms.txt and llms-full.txt to assure compatibility with more ai-bots.

MADAO (マダオ)?

Taizou Hasegawa (Madao) from Gintama

We are bound to become "totally hopeless old guy"s as AI will replace us and we lose our job, kinda like Hasegawa from (Gintama). And also MD-AI is written similar to madao.

Features

  • Zero‑config: add the integration to your astro.config.mjs and the middleware is wired automatically.
  • SSR‑friendly: runs as an Astro middleware, works with static builds and server‑side rendering.
  • Markdown export: on astro:build:done you can implement a conversion pipeline that writes the page HTML to Markdown files under dist/md/.
  • Developer tooling: includes Biome for lint/format, Changesets for versioning & releasing, and a CI workflow.

Installation

npm i -D astro-madao
# install peer dependency if you haven't already
npm i astro

Add the integration to astro.config.mjs:

import { defineConfig } from "astro";
import madao from "astro-madao";

export default defineConfig({
  integrations: [madao()],
});

Options

You don't have to configure Madao, but you may want to personalize some settings:

Option Default Value What it Does
folder "md" Sets the name of the subfolder where the generated Markdown files will be placed.
title (your homepage title) Sets the site title for the llms.txt and llms-full.txt files.
description (your homepage description) Sets the site description for llms.txt and llms-full.txt.
excludePaths [] (empty list) List of URL patterns to exclude from Markdown file generation (e.g., folders you don't want exported).

Example:

  integrations: [madao({
    folder: 'ai',
    title: 'Madao',
    excludePaths: 'homeworks'
  })],
});

Usage

The middleware will automatically append a <link> tag pointing to the Markdown file for the current page. You can then flesh out the astro:build:done hook to generate those Markdown files.

Development

# lint & format
npm run lint
npm run format

# build
npm run build

Releasing

We use Changesets to manage releases:

# create a changeset
npm run changeset
# version bump & changelog generation
npm run version
# publish to npm
npm run release

The CI workflow runs lint, type‑checking and the build on every push.

ROADMAP

  • [] Next update: handle i18n better

About

An Astro interation to generate the markdown equivalent of each page for easier AI access, llms.txt adding alternate meta tag to point the LLM in the right direction

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages