Files
shakespeare/src/lib/llmstxt.ts
T
2025-08-28 14:12:16 -05:00

19 lines
377 B
TypeScript

/**
* Adds a markdown extension to the URL according to the
* [llms.txt](https://llmstxt.org/) specification.
*/
export function llmstxtUrl(url: URL | string): URL {
url = new URL(url);
if (url.pathname.endsWith('.md')) {
return url;
}
if (url.pathname.endsWith('/')) {
url.pathname += 'index.md';
} else {
url.pathname += '.md';
}
return url;
}