@nuasite/llm-enhancements 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +360 -0
- package/dist/types/build-processor.d.ts +11 -0
- package/dist/types/build-processor.d.ts.map +1 -0
- package/dist/types/cms-marker.d.ts +19 -0
- package/dist/types/cms-marker.d.ts.map +1 -0
- package/dist/types/dev-middleware.d.ts +7 -0
- package/dist/types/dev-middleware.d.ts.map +1 -0
- package/dist/types/html-to-markdown.d.ts +14 -0
- package/dist/types/html-to-markdown.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/llm-endpoint.d.ts +15 -0
- package/dist/types/llm-endpoint.d.ts.map +1 -0
- package/dist/types/markdown-generator.d.ts +29 -0
- package/dist/types/markdown-generator.d.ts.map +1 -0
- package/dist/types/paths.d.ts +31 -0
- package/dist/types/paths.d.ts.map +1 -0
- package/dist/types/tests/tsconfig.tsbuildinfo +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +34 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +48 -0
- package/src/build-processor.ts +173 -0
- package/src/cms-marker.ts +56 -0
- package/src/dev-middleware.ts +240 -0
- package/src/html-to-markdown.ts +351 -0
- package/src/index.ts +29 -0
- package/src/llm-endpoint.ts +80 -0
- package/src/llms-txt-endpoint.ts +123 -0
- package/src/markdown-generator.ts +138 -0
- package/src/paths.ts +90 -0
- package/src/tsconfig.json +6 -0
- package/src/types.ts +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# @nuasite/llm-enhancements
|
|
2
|
+
|
|
3
|
+
An Astro integration that exposes pages as `.md` endpoints. During development, any page can be accessed as markdown by appending `.md` to its URL. In production builds, corresponding `.md` files are generated alongside your HTML output.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Dev Server Support**: Access any page as markdown (e.g., `/about.md`)
|
|
8
|
+
- **Build Output**: Generates `.md` files during `astro build`
|
|
9
|
+
- **Content Collections**: Preserves original markdown from Astro content collections
|
|
10
|
+
- **HTML to Markdown**: Converts static pages to clean markdown
|
|
11
|
+
- **Alternate Links**: Injects `<link rel="alternate" type="text/markdown">` into HTML
|
|
12
|
+
- **Frontmatter**: Includes metadata like title, description, and source path
|
|
13
|
+
- **LLM Discovery**: Auto-generated `/.well-known/llm.md` endpoint for LLM-friendly site discovery
|
|
14
|
+
- **llms.txt**: Auto-generated `/llms.txt` following the [llms.txt convention](https://llmstxt.org/) for crawler/LLM guidance
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun add -D @nuasite/llm-enhancements
|
|
20
|
+
# or: npm install -D @nuasite/llm-enhancements
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Add the integration to your `astro.config.mjs`:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import pageMarkdown from '@nuasite/llm-enhancements'
|
|
29
|
+
import { defineConfig } from 'astro/config'
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
integrations: [
|
|
33
|
+
pageMarkdown({
|
|
34
|
+
// Optional configuration
|
|
35
|
+
contentDir: 'src/content',
|
|
36
|
+
includeStaticPages: true,
|
|
37
|
+
includeFrontmatter: true,
|
|
38
|
+
llmEndpoint: true, // or configure with options
|
|
39
|
+
llmsTxt: true, // or configure with options
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## How It Works
|
|
46
|
+
|
|
47
|
+
### Development Mode
|
|
48
|
+
|
|
49
|
+
When running `astro dev`, any page can be accessed as markdown by appending `.md` to its URL:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
/about → /about.md
|
|
53
|
+
/blog/hello → /blog/hello.md
|
|
54
|
+
/ → /index.md
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The dev server intercepts these requests and generates markdown on-the-fly.
|
|
58
|
+
|
|
59
|
+
### Production Build
|
|
60
|
+
|
|
61
|
+
During `astro build`, the integration processes each page and generates a corresponding `.md` file in the dist directory:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
dist/
|
|
65
|
+
├── index.html
|
|
66
|
+
├── index.md
|
|
67
|
+
├── about/
|
|
68
|
+
│ ├── index.html
|
|
69
|
+
├── about.md
|
|
70
|
+
└── blog/
|
|
71
|
+
└── hello/
|
|
72
|
+
├── index.html
|
|
73
|
+
└── hello.md
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Content Collection Pages
|
|
77
|
+
|
|
78
|
+
For pages that come from Astro content collections, the integration reads the original markdown source and preserves it in the output:
|
|
79
|
+
|
|
80
|
+
```md
|
|
81
|
+
---
|
|
82
|
+
title: My Blog Post
|
|
83
|
+
description: An example post
|
|
84
|
+
url: /blog/hello
|
|
85
|
+
type: collection
|
|
86
|
+
source: src/content/blog/hello.md
|
|
87
|
+
generatedAt: 2024-01-15T10:30:00.000Z
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
# My Blog Post
|
|
91
|
+
|
|
92
|
+
This is the original markdown content from the collection...
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Static Pages
|
|
96
|
+
|
|
97
|
+
For static `.astro` pages, the integration converts the rendered HTML to markdown:
|
|
98
|
+
|
|
99
|
+
```md
|
|
100
|
+
---
|
|
101
|
+
title: About Us
|
|
102
|
+
description: Learn more about our company
|
|
103
|
+
url: /about
|
|
104
|
+
type: static
|
|
105
|
+
generatedAt: 2024-01-15T10:30:00.000Z
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# About Us
|
|
109
|
+
|
|
110
|
+
Our company was founded in 2020...
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### HTML Alternate Links
|
|
114
|
+
|
|
115
|
+
The integration automatically injects a `<link>` tag into HTML pages pointing to their markdown version:
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<head>
|
|
119
|
+
<link rel="alternate" type="text/markdown" href="/about.md">
|
|
120
|
+
</head>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### LLM Discovery Endpoint
|
|
124
|
+
|
|
125
|
+
> **Note**: The `/.well-known/llm.md` and `/llms.txt` endpoints require a `site` to be configured in your `astro.config.mjs` to generate valid absolute URLs. If no site is configured, these endpoints will be skipped with a warning.
|
|
126
|
+
|
|
127
|
+
The integration generates a `/.well-known/llm.md` endpoint that provides LLM-friendly site discovery information:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
http://localhost:4321/.well-known/llm.md
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
This endpoint includes:
|
|
134
|
+
- Site title and description (extracted from homepage metadata)
|
|
135
|
+
- List of all available markdown endpoints
|
|
136
|
+
- Usage instructions for accessing markdown versions
|
|
137
|
+
|
|
138
|
+
Example output:
|
|
139
|
+
|
|
140
|
+
```md
|
|
141
|
+
---
|
|
142
|
+
generatedAt: 2024-01-15T10:30:00.000Z
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
# My Site
|
|
146
|
+
|
|
147
|
+
Welcome to my site.
|
|
148
|
+
|
|
149
|
+
## Markdown Endpoints
|
|
150
|
+
|
|
151
|
+
This site exposes page content as markdown at `.md` URLs.
|
|
152
|
+
|
|
153
|
+
### Pages
|
|
154
|
+
|
|
155
|
+
- [https://example.com/index.md](https://example.com/index.md) - My Site
|
|
156
|
+
- [https://example.com/about.md](https://example.com/about.md) - About Us
|
|
157
|
+
- [https://example.com/blog/hello.md](https://example.com/blog/hello.md) - Hello World
|
|
158
|
+
|
|
159
|
+
## Usage
|
|
160
|
+
|
|
161
|
+
Append `.md` to any page URL to get the markdown version:
|
|
162
|
+
- `https://example.com/about` → `https://example.com/about.md`
|
|
163
|
+
- `https://example.com/blog/hello` → `https://example.com/blog/hello.md`
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### llms.txt Endpoint
|
|
167
|
+
|
|
168
|
+
The integration also generates a `/llms.txt` file following the [llms.txt convention](https://llmstxt.org/). This provides a standardized way to communicate site structure to LLMs and crawlers:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
http://localhost:4321/llms.txt
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Example output:
|
|
175
|
+
|
|
176
|
+
```txt
|
|
177
|
+
# My Site
|
|
178
|
+
|
|
179
|
+
> Welcome to my site.
|
|
180
|
+
|
|
181
|
+
This site provides markdown versions of all pages for LLM consumption.
|
|
182
|
+
|
|
183
|
+
## LLM Discovery
|
|
184
|
+
|
|
185
|
+
- [LLM Discovery Endpoint](https://example.com/.well-known/llm.md): Full site map with all available markdown endpoints
|
|
186
|
+
|
|
187
|
+
## Markdown Endpoints
|
|
188
|
+
|
|
189
|
+
All pages are available as markdown by appending `.md` to the URL.
|
|
190
|
+
|
|
191
|
+
### Content
|
|
192
|
+
|
|
193
|
+
- [My Blog Post](https://example.com/blog/hello.md): /blog/hello
|
|
194
|
+
|
|
195
|
+
### Pages
|
|
196
|
+
|
|
197
|
+
- [My Site](https://example.com/index.md): /
|
|
198
|
+
- [About Us](https://example.com/about.md): /about
|
|
199
|
+
|
|
200
|
+
## Permissions
|
|
201
|
+
|
|
202
|
+
LLMs and crawlers are welcome to access markdown endpoints.
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Configuration Options
|
|
206
|
+
|
|
207
|
+
### `contentDir`
|
|
208
|
+
|
|
209
|
+
- **Type**: `string`
|
|
210
|
+
- **Default**: `'src/content'`
|
|
211
|
+
- Directory containing Astro content collections.
|
|
212
|
+
|
|
213
|
+
### `includeStaticPages`
|
|
214
|
+
|
|
215
|
+
- **Type**: `boolean`
|
|
216
|
+
- **Default**: `true`
|
|
217
|
+
- Whether to generate markdown for static (non-collection) pages.
|
|
218
|
+
|
|
219
|
+
### `includeFrontmatter`
|
|
220
|
+
|
|
221
|
+
- **Type**: `boolean`
|
|
222
|
+
- **Default**: `true`
|
|
223
|
+
- Whether to include YAML frontmatter in the output.
|
|
224
|
+
|
|
225
|
+
### `llmEndpoint`
|
|
226
|
+
|
|
227
|
+
- **Type**: `boolean | LlmEndpointOptions`
|
|
228
|
+
- **Default**: `true`
|
|
229
|
+
- Enable or configure the `/.well-known/llm.md` endpoint.
|
|
230
|
+
|
|
231
|
+
When set to `true`, the endpoint is enabled with default settings. You can also pass an options object:
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
pageMarkdown({
|
|
235
|
+
llmEndpoint: {
|
|
236
|
+
siteName: 'My Custom Site Name',
|
|
237
|
+
description: 'A custom description for my site',
|
|
238
|
+
additionalContent: '## Contact\n\nReach us at hello@example.com',
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### `LlmEndpointOptions`
|
|
244
|
+
|
|
245
|
+
| Option | Type | Description |
|
|
246
|
+
| ------------------- | -------- | ---------------------------------------- |
|
|
247
|
+
| `siteName` | `string` | Override the site name in llm.md |
|
|
248
|
+
| `description` | `string` | Override the site description |
|
|
249
|
+
| `baseUrl` | `string` | Override base URL (defaults to Astro's `site`) |
|
|
250
|
+
| `additionalContent` | `string` | Additional markdown content to append |
|
|
251
|
+
|
|
252
|
+
Set to `false` to disable the endpoint entirely:
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
pageMarkdown({
|
|
256
|
+
llmEndpoint: false,
|
|
257
|
+
})
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### `llmsTxt`
|
|
261
|
+
|
|
262
|
+
- **Type**: `boolean | LlmsTxtOptions`
|
|
263
|
+
- **Default**: `true`
|
|
264
|
+
- Enable or configure the `/llms.txt` endpoint.
|
|
265
|
+
|
|
266
|
+
When set to `true`, the endpoint is enabled with default settings. URLs are generated using the `site` value from your Astro config. You can also pass an options object:
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
pageMarkdown({
|
|
270
|
+
llmsTxt: {
|
|
271
|
+
siteName: 'My Custom Site Name',
|
|
272
|
+
description: 'A custom description for my site',
|
|
273
|
+
baseUrl: 'https://example.com', // Override Astro's site config
|
|
274
|
+
allowCrawling: true,
|
|
275
|
+
instructions: 'Please be respectful of rate limits.',
|
|
276
|
+
additionalContent: '## Contact\n\nReach us at hello@example.com',
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### `LlmsTxtOptions`
|
|
282
|
+
|
|
283
|
+
| Option | Type | Description |
|
|
284
|
+
| ------------------- | --------- | ----------------------------------------------- |
|
|
285
|
+
| `siteName` | `string` | Override the site name in llms.txt |
|
|
286
|
+
| `description` | `string` | Override the site description |
|
|
287
|
+
| `baseUrl` | `string` | Override base URL (defaults to Astro's `site`) |
|
|
288
|
+
| `allowCrawling` | `boolean` | Whether crawling is allowed (default: true) |
|
|
289
|
+
| `instructions` | `string` | Custom instructions for LLMs |
|
|
290
|
+
| `additionalContent` | `string` | Additional content to append |
|
|
291
|
+
|
|
292
|
+
Set to `false` to disable the endpoint entirely:
|
|
293
|
+
|
|
294
|
+
```js
|
|
295
|
+
pageMarkdown({
|
|
296
|
+
llmsTxt: false,
|
|
297
|
+
})
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## HTML to Markdown Conversion
|
|
301
|
+
|
|
302
|
+
When converting static pages, the integration:
|
|
303
|
+
|
|
304
|
+
- Extracts main content from `<main>`, `<article>`, or similar containers
|
|
305
|
+
- Converts headings, paragraphs, lists, code blocks, tables, and links
|
|
306
|
+
- Excludes navigation, footer, header, scripts, and forms
|
|
307
|
+
- Extracts title and description from meta tags
|
|
308
|
+
- Cleans up excessive whitespace
|
|
309
|
+
|
|
310
|
+
### Supported Elements
|
|
311
|
+
|
|
312
|
+
| HTML | Markdown |
|
|
313
|
+
| ---------------------- | --------------- |
|
|
314
|
+
| `<h1>` - `<h6>` | `#` - `######` |
|
|
315
|
+
| `<p>` | Paragraph |
|
|
316
|
+
| `<strong>`, `<b>` | `**bold**` |
|
|
317
|
+
| `<em>`, `<i>` | `*italic*` |
|
|
318
|
+
| `<code>` | `` `code` `` |
|
|
319
|
+
| `<pre><code>` | Code blocks |
|
|
320
|
+
| `<a>` | `[text](url)` |
|
|
321
|
+
| `<img>` | `` |
|
|
322
|
+
| `<ul>`, `<ol>`, `<li>` | Lists |
|
|
323
|
+
| `<blockquote>` | `> quote` |
|
|
324
|
+
| `<table>` | Markdown tables |
|
|
325
|
+
|
|
326
|
+
## Integration with @nuasite/cms-marker
|
|
327
|
+
|
|
328
|
+
When used alongside `@nuasite/cms-marker`, the integration can access content collection data through the CMS manifest. This is optional and works without it.
|
|
329
|
+
|
|
330
|
+
```js
|
|
331
|
+
import cmsMarker from '@nuasite/cms-marker'
|
|
332
|
+
import pageMarkdown from '@nuasite/llm-enhancements'
|
|
333
|
+
import { defineConfig } from 'astro/config'
|
|
334
|
+
|
|
335
|
+
export default defineConfig({
|
|
336
|
+
integrations: [
|
|
337
|
+
cmsMarker(),
|
|
338
|
+
pageMarkdown(),
|
|
339
|
+
],
|
|
340
|
+
})
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Output Structure
|
|
344
|
+
|
|
345
|
+
Each markdown file includes:
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
interface MarkdownOutput {
|
|
349
|
+
/** YAML frontmatter fields */
|
|
350
|
+
frontmatter: Record<string, unknown>
|
|
351
|
+
/** Markdown body content */
|
|
352
|
+
body: string
|
|
353
|
+
/** Path to the original source file (if from collection) */
|
|
354
|
+
sourcePath?: string
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Contributing
|
|
359
|
+
|
|
360
|
+
Contributions are welcome! Please feel free to submit issues and pull requests.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AstroIntegrationLogger } from 'astro';
|
|
2
|
+
import type { ResolvedOptions } from './types';
|
|
3
|
+
interface PageInfo {
|
|
4
|
+
pathname: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Process build output and generate .md files for all pages
|
|
8
|
+
*/
|
|
9
|
+
export declare function processBuildOutput(dir: URL, pages: PageInfo[], options: ResolvedOptions, logger: AstroIntegrationLogger): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=build-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-processor.d.ts","sourceRoot":"","sources":["../../src/build-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAA;AAQnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,UAAU,QAAQ;IACjB,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,QAAQ,EAAE,EACjB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,sBAAsB,iBAyF9B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface CollectionInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
slug: string;
|
|
4
|
+
file: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ParsedContent {
|
|
7
|
+
frontmatter: Record<string, {
|
|
8
|
+
value: string;
|
|
9
|
+
line: number;
|
|
10
|
+
}>;
|
|
11
|
+
body: string;
|
|
12
|
+
bodyStartLine: number;
|
|
13
|
+
file: string;
|
|
14
|
+
collectionName: string;
|
|
15
|
+
collectionSlug: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getCollectionContent(pagePath: string, contentDir: string): Promise<ParsedContent | undefined>;
|
|
18
|
+
export declare function hasCmsMarker(): boolean;
|
|
19
|
+
//# sourceMappingURL=cms-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cms-marker.d.ts","sourceRoot":"","sources":["../../src/cms-marker.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,aAAa;IAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;CACtB;AAsBD,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAapC;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ViteDevServer } from 'vite';
|
|
2
|
+
import type { ResolvedOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Create dev server middleware to handle markdown requests
|
|
5
|
+
*/
|
|
6
|
+
export declare function createDevMiddleware(server: ViteDevServer, options: ResolvedOptions): void;
|
|
7
|
+
//# sourceMappingURL=dev-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-middleware.d.ts","sourceRoot":"","sources":["../../src/dev-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAMzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAgG9C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,QA8FlF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface HtmlToMarkdownResult {
|
|
2
|
+
/** Extracted metadata for frontmatter */
|
|
3
|
+
metadata: {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
};
|
|
7
|
+
/** Converted markdown body */
|
|
8
|
+
body: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Convert HTML string to markdown
|
|
12
|
+
*/
|
|
13
|
+
export declare function htmlToMarkdown(html: string): HtmlToMarkdownResult;
|
|
14
|
+
//# sourceMappingURL=html-to-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-to-markdown.d.ts","sourceRoot":"","sources":["../../src/html-to-markdown.ts"],"names":[],"mappings":"AAkTA,MAAM,WAAW,oBAAoB;IACpC,yCAAyC;IACzC,QAAQ,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;IACD,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CA+BjE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AstroIntegration } from 'astro';
|
|
2
|
+
import { type PageMarkdownOptions } from './types';
|
|
3
|
+
export default function pageMarkdown(options?: PageMarkdownOptions): AstroIntegration;
|
|
4
|
+
export type { LlmEndpointOptions, MarkdownOutput, PageMarkdownOptions } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAG7C,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,SAAS,CAAA;AAElE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,gBAAgB,CAgBxF;AAED,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LlmEndpointOptions } from './types';
|
|
2
|
+
export interface PageEntry {
|
|
3
|
+
pathname: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
type: 'collection' | 'static';
|
|
6
|
+
}
|
|
7
|
+
export interface SiteMetadata {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generate the content for /.well-known/llm.md
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateLlmMarkdown(pages: PageEntry[], siteMetadata: SiteMetadata, options: LlmEndpointOptions): string;
|
|
15
|
+
//# sourceMappingURL=llm-endpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-endpoint.d.ts","sourceRoot":"","sources":["../../src/llm-endpoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,MAAM,WAAW,SAAS;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAA;CAC7B;AAED,MAAM,WAAW,YAAY;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,SAAS,EAAE,EAClB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,kBAAkB,GACzB,MAAM,CA6DR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MarkdownOutput } from './types';
|
|
2
|
+
export interface GenerateOptions {
|
|
3
|
+
/** URL path of the page */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Type of content (collection or static) */
|
|
6
|
+
type: 'collection' | 'static';
|
|
7
|
+
/** Path to source file (for collections) */
|
|
8
|
+
sourcePath?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generate complete markdown output with frontmatter
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateMarkdown(output: MarkdownOutput, options: GenerateOptions, includeFrontmatter?: boolean): string;
|
|
14
|
+
/**
|
|
15
|
+
* Create a simple markdown output for collection content
|
|
16
|
+
* that already has markdown body
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCollectionOutput(frontmatter: Record<string, {
|
|
19
|
+
value: string;
|
|
20
|
+
line: number;
|
|
21
|
+
}>, body: string, sourcePath: string): MarkdownOutput;
|
|
22
|
+
/**
|
|
23
|
+
* Create markdown output from HTML conversion result
|
|
24
|
+
*/
|
|
25
|
+
export declare function createStaticOutput(metadata: {
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
}, body: string): MarkdownOutput;
|
|
29
|
+
//# sourceMappingURL=markdown-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-generator.d.ts","sourceRoot":"","sources":["../../src/markdown-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAyD7C,MAAM,WAAW,eAAe;IAC/B,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,6CAA6C;IAC7C,IAAI,EAAE,YAAY,GAAG,QAAQ,CAAA;IAC7B,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,eAAe,EACxB,kBAAkB,UAAO,GACvB,MAAM,CAoBR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,EAC5D,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAChB,cAAc,CAYhB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,EAClD,IAAI,EAAE,MAAM,GACV,cAAc,CAchB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Well-known path for LLM discovery endpoint */
|
|
2
|
+
export declare const LLM_ENDPOINT_PATH = "/.well-known/llm.md";
|
|
3
|
+
/**
|
|
4
|
+
* Normalize a URL path by removing query strings, hashes, and trailing slashes
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizePath(url: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Get the markdown URL for a given page path
|
|
9
|
+
*/
|
|
10
|
+
export declare function getMarkdownUrl(pagePath: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a .md URL back to a page path
|
|
13
|
+
*/
|
|
14
|
+
export declare function mdUrlToPagePath(url: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get the output path for a .md file in dist
|
|
17
|
+
*/
|
|
18
|
+
export declare function getMdOutputPath(distDir: string, pagePath: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the HTML file path for a page in dist
|
|
21
|
+
*/
|
|
22
|
+
export declare function getHtmlPath(distDir: string, pagePath: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get the output path for llm.md in dist
|
|
25
|
+
*/
|
|
26
|
+
export declare function getLlmOutputPath(distDir: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Inject markdown alternate link into HTML head
|
|
29
|
+
*/
|
|
30
|
+
export declare function injectMarkdownLink(html: string, pagePath: string): string;
|
|
31
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/paths.ts"],"names":[],"mappings":"AAEA,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,wBAAwB,CAAA;AAEtD;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWzE"}
|