Add your pages to the sitemap and llms.txt
Use getAllPages() for sitemap.xml and floconLlmsTxt() for llms.txt. Both come from @flocon-ai/astro.
Drafts are never listed. A page scheduled for later is not listed until its publish date.
sitemap.xml
Create src/pages/sitemap.xml.ts:
import { getAllPages } from "@flocon-ai/astro"
export async function GET() {
const pages = await getAllPages()
const urls = pages
.map((p) => `<url><loc>https://example.com/${p.locale}${p.path}</loc><lastmod>${p.updatedAt}</lastmod></url>`)
.join("")
return new Response(
`<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${urls}</urlset>`,
{ headers: { "content-type": "application/xml" } }
)
}Want hreflang in your sitemap? floconSitemap({ url }) gives the same list. Each entry has:
urllastModified(the pageupdatedAt)alternates.languages: one URL per locale where the page exists
llms.txt
Create src/pages/llms.txt.ts:
import { floconLlmsTxt } from "@flocon-ai/astro"
export async function GET() {
const text = await floconLlmsTxt({ url: ({ locale, path }) => `https://example.com/${locale}${path}` })
return new Response(text, { headers: { "content-type": "text/plain; charset=utf-8" } })
}floconLlmsTxt() returns text with one Markdown link per published page:
- [Page title](https://example.com/guides/seo)The url rule
floconSitemap and floconLlmsTxt take a url function. It gets { locale, path } and returns the full URL of the page on your website.
localeis the page locale, likeenorfr.pathstarts with a slash, like/guides/seo.- Flocon AI adds no prefix of its own. Build the URL the way your website does.
getAllPages()
It returns the published pages, without their blocks. Each item has locale, path, title, updatedAt and alternates.
It throws an error if the API call fails.
Environment
These helpers run on the server only. They read your read token from FLOCON_TOKEN. On Cloudflare, pass the token option. See Install.
Updated