@ontosdk/next 1.2.0 → 1.3.1
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/JSON_LD_GUIDE.md +403 -0
- package/LLMS_TXT_GUIDE.md +297 -0
- package/ONTOROVIDER_USAGE.md +89 -0
- package/QUICKSTART.md +71 -0
- package/README.md +253 -0
- package/SCHEMA_QUICKSTART.md +97 -0
- package/dist/OntoHead.d.mts +27 -0
- package/dist/OntoHead.d.ts +27 -0
- package/dist/OntoHead.js +2 -0
- package/dist/OntoHead.js.map +1 -0
- package/dist/OntoHead.mjs +2 -0
- package/dist/OntoHead.mjs.map +1 -0
- package/dist/OntoProvider.d.mts +52 -0
- package/dist/OntoProvider.d.ts +52 -0
- package/dist/OntoProvider.js +2 -0
- package/dist/OntoProvider.js.map +1 -0
- package/dist/OntoProvider.mjs +2 -0
- package/dist/OntoProvider.mjs.map +1 -0
- package/dist/config.d.mts +85 -0
- package/dist/config.d.ts +85 -0
- package/dist/config.js +4 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +4 -0
- package/dist/config.mjs.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/dist/middleware.d.mts +3 -2
- package/dist/middleware.d.ts +3 -2
- package/dist/middleware.js +4 -2
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +4 -2
- package/dist/middleware.mjs.map +1 -1
- package/dist/schemas.d.mts +73 -0
- package/dist/schemas.d.ts +73 -0
- package/dist/schemas.js +2 -0
- package/dist/schemas.js.map +1 -0
- package/dist/schemas.mjs +2 -0
- package/dist/schemas.mjs.map +1 -0
- package/onto.config.example.ts +111 -0
- package/package.json +28 -2
- package/src/OntoHead.tsx +59 -0
- package/src/OntoProvider.tsx +95 -0
- package/src/bots.ts +6 -3
- package/src/config.ts +151 -0
- package/src/index.ts +14 -0
- package/src/middleware.ts +62 -12
- package/src/schemas.ts +186 -0
- package/tsconfig.json +1 -0
- package/tsup.config.ts +2 -2
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# OntoProvider Usage Guide
|
|
2
|
+
|
|
3
|
+
The `OntoProvider` component is the high-level, "Zero-Config" entry point for AI optimization. It handles both **Auto-Discovery** (link tags) and **Semantic SEO** (JSON-LD schemas) in one wrapper.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Automatic Link Tag Injection**: Adds `<link rel="alternate" type="text/markdown">` to every page.
|
|
8
|
+
- **JSON-LD Schema Injection**: Automatically generates structured data (Schema.org) for pages based on your `onto.config.ts`.
|
|
9
|
+
- **Dynamic Path Detection**: Uses `usePathname()` to construct full URLs for AI agents.
|
|
10
|
+
- **AIO Scoring Methodology**: Automatically injects methodology schemas for routes marked as `pageType: 'scoring'`.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @ontosdk/next
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### 1. Basic Setup in Root Layout
|
|
21
|
+
|
|
22
|
+
Wrap your application and provide your `baseUrl`. For best results, also pass your `onto.config.ts` object.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { OntoProvider } from '@ontosdk/next/provider';
|
|
26
|
+
import config from '../onto.config';
|
|
27
|
+
|
|
28
|
+
export default function RootLayout({ children }) {
|
|
29
|
+
return (
|
|
30
|
+
<OntoProvider baseUrl="https://example.com" config={config}>
|
|
31
|
+
<html lang="en">
|
|
32
|
+
<head />
|
|
33
|
+
<body>{children}</body>
|
|
34
|
+
</html>
|
|
35
|
+
</OntoProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Page Type Configuration
|
|
41
|
+
|
|
42
|
+
In your `onto.config.ts`, you can specify `pageType` for automatic schema generation:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const config: OntoConfig = {
|
|
46
|
+
// ... basic info
|
|
47
|
+
routes: [
|
|
48
|
+
{
|
|
49
|
+
path: '/pricing',
|
|
50
|
+
description: 'Pricing & Methodology',
|
|
51
|
+
pageType: 'scoring' // Triggers AIOMethodologySchema (AIO Scoring)
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
path: '/about',
|
|
55
|
+
description: 'About Us',
|
|
56
|
+
pageType: 'about' // Triggers Organization/AboutPage Schema
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## How It Works
|
|
63
|
+
|
|
64
|
+
### Auto-Discovery
|
|
65
|
+
For a page at `/docs`, the provider injects:
|
|
66
|
+
```html
|
|
67
|
+
<link rel="alternate" type="text/markdown" href="https://example.com/docs?format=md" />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Semantic SEO (JSON-LD)
|
|
71
|
+
If the route matches a `pageType`, it injects a `<script type="application/ld+json">` with highly specific AI-friendly metadata. For example, a `scoring` page receives the **Onto AIO Methodology** schema, explaining your content negotiation and token efficiency weights to LLM crawlers.
|
|
72
|
+
|
|
73
|
+
## Comparison with OntoHead
|
|
74
|
+
|
|
75
|
+
| Feature | OntoHead | OntoProvider |
|
|
76
|
+
| :--- | :--- | :--- |
|
|
77
|
+
| **Path Pattern** | Static `/.onto/*.md` | Dynamic `?format=md` |
|
|
78
|
+
| **JSON-LD** | No | **Yes** |
|
|
79
|
+
| **Manifests** | Injects `llms.txt` link | No (handled by Middleware) |
|
|
80
|
+
| **Best For** | Static exports (CLI) | Dynamic & Meta-heavy sites |
|
|
81
|
+
|
|
82
|
+
## Requirements
|
|
83
|
+
|
|
84
|
+
- Next.js ≥14.0.0
|
|
85
|
+
- React ^18.0.0 || ^19.0.0
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
MIT
|
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Quick Start: Dynamic llms.txt
|
|
2
|
+
|
|
3
|
+
Get AI discovery working in 60 seconds.
|
|
4
|
+
|
|
5
|
+
## Step 1: Create Config
|
|
6
|
+
|
|
7
|
+
Create `onto.config.ts` in your project root:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import type { OntoConfig } from '@ontosdk/next';
|
|
11
|
+
|
|
12
|
+
const config: OntoConfig = {
|
|
13
|
+
name: 'My Site',
|
|
14
|
+
summary: 'Brief description for AI agents',
|
|
15
|
+
baseUrl: 'https://example.com',
|
|
16
|
+
|
|
17
|
+
routes: [
|
|
18
|
+
{ path: '/', description: 'Homepage' },
|
|
19
|
+
{ path: '/docs', description: 'Documentation' }
|
|
20
|
+
]
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default config;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Step 2: Test
|
|
27
|
+
|
|
28
|
+
Start your dev server and visit:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
http://localhost:3000/llms.txt
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You should see your dynamically generated llms.txt content!
|
|
35
|
+
|
|
36
|
+
## Step 3: Deploy
|
|
37
|
+
|
|
38
|
+
Deploy normally—the middleware automatically serves llms.txt to AI agents.
|
|
39
|
+
|
|
40
|
+
## What Happens
|
|
41
|
+
|
|
42
|
+
1. **AI bot requests `/llms.txt`**
|
|
43
|
+
2. **Middleware detects the request**
|
|
44
|
+
3. **Loads your `onto.config.ts`**
|
|
45
|
+
4. **Generates llms.txt dynamically**
|
|
46
|
+
5. **Returns with proper headers**
|
|
47
|
+
|
|
48
|
+
No static files needed—it just works! ✨
|
|
49
|
+
|
|
50
|
+
## Example Output
|
|
51
|
+
|
|
52
|
+
```markdown
|
|
53
|
+
# My Site
|
|
54
|
+
|
|
55
|
+
> Brief description for AI agents
|
|
56
|
+
|
|
57
|
+
## Key Routes
|
|
58
|
+
|
|
59
|
+
- [/](https://example.com/): Homepage
|
|
60
|
+
- [/docs](https://example.com/docs): Documentation
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Next Steps
|
|
64
|
+
|
|
65
|
+
- [Full Configuration Guide](./LLMS_TXT_GUIDE.md)
|
|
66
|
+
- [Example Config](./onto.config.example.ts)
|
|
67
|
+
- [API Reference](./README.md)
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
Need help? Check the [docs](https://buildonto.dev/docs) or [open an issue](https://github.com/anthropics/onto-sdk/issues).
|
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# @ontosdk/next
|
|
2
|
+
|
|
3
|
+
> Optimize your Next.js site for AI agents in 2 minutes
|
|
4
|
+
|
|
5
|
+
The Onto SDK automatically converts your Next.js pages into AI-friendly Markdown and intelligently routes bot traffic to optimized endpoints. Reduce token usage by 95% and improve AI agent comprehension.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🤖 **AI Bot Detection**: Recognizes 21+ AI crawlers (GPTBot, ClaudeBot, Perplexity, etc.)
|
|
10
|
+
- 📄 **Automatic Extraction**: Converts React/HTML to clean, semantic Markdown
|
|
11
|
+
- 🚀 **Edge Middleware**: Sub-10ms routing on Vercel/Cloudflare Edge
|
|
12
|
+
- 🔍 **AI Discovery**: Auto-generates `llms.txt` from config
|
|
13
|
+
- 📊 **Analytics**: Optional Control Plane for bot tracking (premium)
|
|
14
|
+
- ⚡ **Zero Config**: Works out-of-the-box with sensible defaults
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### 1. Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @ontosdk/next
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Add Middleware
|
|
25
|
+
|
|
26
|
+
Create `middleware.ts` in your project root:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { ontoMiddleware as middleware } from '@ontosdk/next/middleware';
|
|
30
|
+
|
|
31
|
+
export { middleware };
|
|
32
|
+
|
|
33
|
+
export const config = {
|
|
34
|
+
matcher: ['/((?!api|_next|.*\\..*).*)'],
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. Configure Build
|
|
39
|
+
|
|
40
|
+
Update your `package.json`:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "next build && onto-next"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 4. Create `onto.config.ts`
|
|
51
|
+
|
|
52
|
+
Create `onto.config.ts` in your project root for dynamic `llms.txt` generation:
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import type { OntoConfig } from '@ontosdk/next';
|
|
56
|
+
|
|
57
|
+
const config: OntoConfig = {
|
|
58
|
+
name: 'My Project',
|
|
59
|
+
summary: 'A brief description of what your site does',
|
|
60
|
+
baseUrl: 'https://example.com',
|
|
61
|
+
|
|
62
|
+
routes: [
|
|
63
|
+
{ path: '/', description: 'Homepage' },
|
|
64
|
+
{ path: '/docs', description: 'Documentation' }
|
|
65
|
+
]
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default config;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
That's it! Your site is now optimized for AI agents.
|
|
72
|
+
|
|
73
|
+
## How It Works
|
|
74
|
+
|
|
75
|
+
### Build Time
|
|
76
|
+
The `onto-next` CLI scans your `.next/server/app/` directory and converts rendered HTML pages to clean Markdown files in `public/.onto/`.
|
|
77
|
+
|
|
78
|
+
### Runtime
|
|
79
|
+
The Edge middleware:
|
|
80
|
+
1. Detects AI bots via User-Agent or Accept headers
|
|
81
|
+
2. Rewrites requests to serve pre-generated `.onto/*.md` files
|
|
82
|
+
3. Returns optimized content in <10ms
|
|
83
|
+
|
|
84
|
+
### AI Discovery
|
|
85
|
+
When AI agents request `/llms.txt`, the middleware dynamically generates it from your `onto.config.ts` file—no static file needed.
|
|
86
|
+
|
|
87
|
+
## Components
|
|
88
|
+
|
|
89
|
+
### OntoHead
|
|
90
|
+
|
|
91
|
+
Auto-discovery component for AI agents. Injects link tags into your page head.
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { OntoHead } from '@ontosdk/next/components';
|
|
95
|
+
|
|
96
|
+
export default function RootLayout({ children }) {
|
|
97
|
+
return (
|
|
98
|
+
<html>
|
|
99
|
+
<head>
|
|
100
|
+
<OntoHead />
|
|
101
|
+
</head>
|
|
102
|
+
<body>{children}</body>
|
|
103
|
+
</html>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### OntoProvider
|
|
109
|
+
|
|
110
|
+
Wraps your app and automatically injects AI discovery tags with dynamic paths.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { OntoProvider } from '@ontosdk/next/provider';
|
|
114
|
+
|
|
115
|
+
export default function RootLayout({ children }) {
|
|
116
|
+
return (
|
|
117
|
+
<OntoProvider baseUrl="https://example.com">
|
|
118
|
+
<html>
|
|
119
|
+
<head />
|
|
120
|
+
<body>{children}</body>
|
|
121
|
+
</html>
|
|
122
|
+
</OntoProvider>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Configuration
|
|
128
|
+
|
|
129
|
+
### Environment Variables
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Optional: Enable Control Plane analytics
|
|
133
|
+
ONTO_API_KEY=onto_live_xxxx
|
|
134
|
+
ONTO_DASHBOARD_URL=https://app.buildonto.dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### onto.config.ts Schema
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
interface OntoConfig {
|
|
141
|
+
name: string; // Site name (required)
|
|
142
|
+
summary: string; // Brief description (required)
|
|
143
|
+
baseUrl: string; // Base URL (required)
|
|
144
|
+
routes?: { // Key routes
|
|
145
|
+
path: string;
|
|
146
|
+
description: string;
|
|
147
|
+
}[];
|
|
148
|
+
externalLinks?: { // External resources
|
|
149
|
+
title: string;
|
|
150
|
+
url: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
}[];
|
|
153
|
+
sections?: { // Custom markdown sections
|
|
154
|
+
heading: string;
|
|
155
|
+
content: string;
|
|
156
|
+
}[];
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
See [LLMS_TXT_GUIDE.md](./LLMS_TXT_GUIDE.md) for complete configuration documentation.
|
|
161
|
+
|
|
162
|
+
## Detected Bots
|
|
163
|
+
|
|
164
|
+
| Company | Bots |
|
|
165
|
+
| :--- | :--- |
|
|
166
|
+
| OpenAI | GPTBot, ChatGPT-User, OAI-SearchBot |
|
|
167
|
+
| Anthropic | ClaudeBot, Claude-User, anthropic-ai |
|
|
168
|
+
| Google | Googlebot, Google-CloudVertexBot, Google-Extended |
|
|
169
|
+
| Perplexity | PerplexityBot, Perplexity-User |
|
|
170
|
+
| Meta | Meta-ExternalAgent, Meta-ExternalFetcher |
|
|
171
|
+
| Others | CCBot, Bytespider, Applebot-Extended, cohere-ai, YouBot |
|
|
172
|
+
|
|
173
|
+
## Benefits
|
|
174
|
+
|
|
175
|
+
### For Your Site
|
|
176
|
+
- **Reduced Load**: AI bots get static Markdown instead of triggering server renders
|
|
177
|
+
- **Better Indexing**: AI agents comprehend your content with 95% fewer tokens
|
|
178
|
+
- **Edge Performance**: Middleware runs in <10ms on the edge
|
|
179
|
+
- **SEO+**: Following emerging "Agent SEO" best practices
|
|
180
|
+
|
|
181
|
+
### For AI Agents
|
|
182
|
+
- **Clean Data**: No React boilerplate, Tailwind classes, or layout noise
|
|
183
|
+
- **Structured**: Markdown with proper headings, lists, and links
|
|
184
|
+
- **Fast**: Instant responses from edge cache
|
|
185
|
+
- **Discoverable**: Standard `llms.txt` manifest for site navigation
|
|
186
|
+
|
|
187
|
+
## Control Plane (Premium)
|
|
188
|
+
|
|
189
|
+
Unlock analytics and dynamic features:
|
|
190
|
+
|
|
191
|
+
- **Bot Analytics**: Track which AI agents visit your site
|
|
192
|
+
- **Context Injection**: Append dynamic "hidden prompts" to specific routes
|
|
193
|
+
- **Route Monitoring**: See which pages AI agents access most
|
|
194
|
+
|
|
195
|
+
[Sign up at buildonto.dev](https://buildonto.dev)
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
- [Demo App](../../apps/demo) - Full working example with config
|
|
200
|
+
- [onto.config.example.ts](./onto.config.example.ts) - Configuration template
|
|
201
|
+
- [LLMS_TXT_GUIDE.md](./LLMS_TXT_GUIDE.md) - Complete llms.txt guide
|
|
202
|
+
|
|
203
|
+
## API Reference
|
|
204
|
+
|
|
205
|
+
### Middleware
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { ontoMiddleware } from '@ontosdk/next/middleware';
|
|
209
|
+
|
|
210
|
+
// Export as default middleware
|
|
211
|
+
export { ontoMiddleware as middleware };
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Config Types
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import type { OntoConfig, OntoRoute } from '@ontosdk/next';
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Utility Functions
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { loadOntoConfig, generateLlmsTxt } from '@ontosdk/next';
|
|
224
|
+
|
|
225
|
+
// Load config from project root
|
|
226
|
+
const config = await loadOntoConfig();
|
|
227
|
+
|
|
228
|
+
// Generate llms.txt content
|
|
229
|
+
const llmsTxt = generateLlmsTxt(config);
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## TypeScript Support
|
|
233
|
+
|
|
234
|
+
Full TypeScript support with comprehensive type definitions for all exports.
|
|
235
|
+
|
|
236
|
+
## Requirements
|
|
237
|
+
|
|
238
|
+
- Next.js ≥14.0.0
|
|
239
|
+
- React ^18.0.0 || ^19.0.0
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
MIT
|
|
244
|
+
|
|
245
|
+
## Support
|
|
246
|
+
|
|
247
|
+
- [Documentation](https://buildonto.dev/docs)
|
|
248
|
+
- [GitHub Issues](https://github.com/anthropics/onto-sdk/issues)
|
|
249
|
+
- [Twitter](https://twitter.com/buildonto)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
Made with ❤️ by the Onto team
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Quick Start: Automatic JSON-LD Schemas
|
|
2
|
+
|
|
3
|
+
Get AI-friendly structured data in 60 seconds. Zero manual JSON writing required.
|
|
4
|
+
|
|
5
|
+
## Step 1: Pass Config to Provider
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// app/layout.tsx
|
|
9
|
+
import { OntoProvider } from '@ontosdk/next/provider';
|
|
10
|
+
import config from '../onto.config'; // ← Import your config
|
|
11
|
+
|
|
12
|
+
export default function RootLayout({ children }) {
|
|
13
|
+
return (
|
|
14
|
+
<OntoProvider
|
|
15
|
+
baseUrl="https://example.com"
|
|
16
|
+
config={config} // ← Pass it here
|
|
17
|
+
>
|
|
18
|
+
<html>
|
|
19
|
+
<head />
|
|
20
|
+
<body>{children}</body>
|
|
21
|
+
</html>
|
|
22
|
+
</OntoProvider>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Step 2: Configure Page Types
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// onto.config.ts
|
|
31
|
+
const config: OntoConfig = {
|
|
32
|
+
name: 'My Site',
|
|
33
|
+
summary: 'Description',
|
|
34
|
+
baseUrl: 'https://example.com',
|
|
35
|
+
|
|
36
|
+
routes: [
|
|
37
|
+
{
|
|
38
|
+
path: '/score',
|
|
39
|
+
description: 'AIO Score Calculator',
|
|
40
|
+
pageType: 'scoring' // ← Injects Methodology schema
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: '/about',
|
|
44
|
+
description: 'About us',
|
|
45
|
+
pageType: 'about' // ← Injects Organization schema
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
organization: {
|
|
50
|
+
name: 'My Company',
|
|
51
|
+
url: 'https://example.com'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Step 3: Verify
|
|
57
|
+
|
|
58
|
+
Visit `/score` or `/about` and view page source. You'll see:
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<script type="application/ld+json">
|
|
62
|
+
{
|
|
63
|
+
"@context": "https://schema.org",
|
|
64
|
+
"@type": "HowTo",
|
|
65
|
+
"name": "AIO Score Calculation Methodology",
|
|
66
|
+
"step": [...]
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## What Gets Injected?
|
|
72
|
+
|
|
73
|
+
| Page Type | Schema Type | Use For |
|
|
74
|
+
|-----------|-------------|---------|
|
|
75
|
+
| `scoring` | HowTo | Score calculators, methodology pages |
|
|
76
|
+
| `about` | AboutPage + Organization | Company info, team pages |
|
|
77
|
+
| `default` | None | Everything else (no automatic injection) |
|
|
78
|
+
|
|
79
|
+
## AIO Scoring Weights (Included in Schema)
|
|
80
|
+
|
|
81
|
+
The `scoring` page type automatically documents:
|
|
82
|
+
- **40%** - Content Negotiation
|
|
83
|
+
- **35%** - Token Efficiency
|
|
84
|
+
- **25%** - Structured Data ← You get these points!
|
|
85
|
+
- **Bonus** - Semantic HTML
|
|
86
|
+
|
|
87
|
+
By using this feature, you automatically gain **+25 points** on AIO scoring! 🎉
|
|
88
|
+
|
|
89
|
+
## Next Steps
|
|
90
|
+
|
|
91
|
+
- [Complete JSON-LD Guide](./JSON_LD_GUIDE.md) - Full documentation
|
|
92
|
+
- [onto.config.example.ts](./onto.config.example.ts) - Example config
|
|
93
|
+
- [Validation Tips](./JSON_LD_GUIDE.md#validation) - Test your schemas
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
**Pro Tip**: AI agents can now confidently extract your scoring methodology without hallucinating the weights!
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OntoHead — Auto-Discovery component for AI agents.
|
|
5
|
+
*
|
|
6
|
+
* Injects `<link rel="alternate">` tags into the page `<head>` so AI crawlers
|
|
7
|
+
* can discover the optimized markdown endpoint for the current route.
|
|
8
|
+
*
|
|
9
|
+
* Usage in a Next.js App Router layout:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { OntoHead } from '@ontosdk/next/components';
|
|
12
|
+
*
|
|
13
|
+
* export default function RootLayout({ children }) {
|
|
14
|
+
* return (
|
|
15
|
+
* <html>
|
|
16
|
+
* <head>
|
|
17
|
+
* <OntoHead />
|
|
18
|
+
* </head>
|
|
19
|
+
* <body>{children}</body>
|
|
20
|
+
* </html>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function OntoHead(): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { OntoHead };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* OntoHead — Auto-Discovery component for AI agents.
|
|
5
|
+
*
|
|
6
|
+
* Injects `<link rel="alternate">` tags into the page `<head>` so AI crawlers
|
|
7
|
+
* can discover the optimized markdown endpoint for the current route.
|
|
8
|
+
*
|
|
9
|
+
* Usage in a Next.js App Router layout:
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { OntoHead } from '@ontosdk/next/components';
|
|
12
|
+
*
|
|
13
|
+
* export default function RootLayout({ children }) {
|
|
14
|
+
* return (
|
|
15
|
+
* <html>
|
|
16
|
+
* <head>
|
|
17
|
+
* <OntoHead />
|
|
18
|
+
* </head>
|
|
19
|
+
* <body>{children}</body>
|
|
20
|
+
* </html>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function OntoHead(): react_jsx_runtime.JSX.Element;
|
|
26
|
+
|
|
27
|
+
export { OntoHead };
|
package/dist/OntoHead.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";"use client";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var a in e)l(t,a,{get:e[a],enumerable:!0})},f=(t,e,a,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of m(e))!p.call(t,i)&&i!==a&&l(t,i,{get:()=>e[i],enumerable:!(o=d(e,i))||o.enumerable});return t};var h=t=>f(l({},"__esModule",{value:!0}),t);var c={};s(c,{OntoHead:()=>k});module.exports=h(c);var r=require("next/navigation"),n=require("react/jsx-runtime");function k(){let e=(0,r.usePathname)();(e==="/"||e==="")&&(e="/index"),e.endsWith("/")&&e!=="/"&&(e=e.slice(0,-1));let a=`/.onto${e}.md`;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("link",{rel:"alternate",type:"text/markdown",href:a,title:"AI-optimized Markdown version"}),(0,n.jsx)("link",{rel:"alternate",type:"text/plain",href:"/llms.txt",title:"LLM-readable site manifest"})]})}0&&(module.exports={OntoHead});
|
|
2
|
+
//# sourceMappingURL=OntoHead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/OntoHead.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\n\n/**\n * OntoHead — Auto-Discovery component for AI agents.\n * \n * Injects `<link rel=\"alternate\">` tags into the page `<head>` so AI crawlers\n * can discover the optimized markdown endpoint for the current route.\n * \n * Usage in a Next.js App Router layout:\n * ```tsx\n * import { OntoHead } from '@ontosdk/next/components';\n * \n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <head>\n * <OntoHead />\n * </head>\n * <body>{children}</body>\n * </html>\n * );\n * }\n * ```\n */\nexport function OntoHead() {\n const pathname = usePathname();\n\n // Map current route to its .onto markdown payload path\n let payloadPath = pathname;\n if (payloadPath === '/' || payloadPath === '') {\n payloadPath = '/index';\n }\n if (payloadPath.endsWith('/') && payloadPath !== '/') {\n payloadPath = payloadPath.slice(0, -1);\n }\n\n const markdownHref = `/.onto${payloadPath}.md`;\n\n return (\n <>\n {/* Per-page markdown alternate for AI agents */}\n <link\n rel=\"alternate\"\n type=\"text/markdown\"\n href={markdownHref}\n title=\"AI-optimized Markdown version\"\n />\n {/* Site-wide llms.txt manifest */}\n <link\n rel=\"alternate\"\n type=\"text/plain\"\n href=\"/llms.txt\"\n title=\"LLM-readable site manifest\"\n />\n </>\n );\n}\n"],"mappings":"sbAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAA4B,2BAuCpBC,EAAA,6BAfD,SAASH,GAAW,CAIvB,IAAII,KAHa,eAAY,GAIzBA,IAAgB,KAAOA,IAAgB,MACvCA,EAAc,UAEdA,EAAY,SAAS,GAAG,GAAKA,IAAgB,MAC7CA,EAAcA,EAAY,MAAM,EAAG,EAAE,GAGzC,IAAMC,EAAe,SAASD,CAAW,MAEzC,SACI,oBAEI,oBAAC,QACG,IAAI,YACJ,KAAK,gBACL,KAAMC,EACN,MAAM,gCACV,KAEA,OAAC,QACG,IAAI,YACJ,KAAK,aACL,KAAK,YACL,MAAM,6BACV,GACJ,CAER","names":["OntoHead_exports","__export","OntoHead","__toCommonJS","import_navigation","import_jsx_runtime","payloadPath","markdownHref"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{usePathname as a}from"next/navigation";import{Fragment as i,jsx as t,jsxs as l}from"react/jsx-runtime";function d(){let e=a();(e==="/"||e==="")&&(e="/index"),e.endsWith("/")&&e!=="/"&&(e=e.slice(0,-1));let n=`/.onto${e}.md`;return l(i,{children:[t("link",{rel:"alternate",type:"text/markdown",href:n,title:"AI-optimized Markdown version"}),t("link",{rel:"alternate",type:"text/plain",href:"/llms.txt",title:"LLM-readable site manifest"})]})}export{d as OntoHead};
|
|
2
|
+
//# sourceMappingURL=OntoHead.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/OntoHead.tsx"],"sourcesContent":["'use client';\n\nimport { usePathname } from 'next/navigation';\n\n/**\n * OntoHead — Auto-Discovery component for AI agents.\n * \n * Injects `<link rel=\"alternate\">` tags into the page `<head>` so AI crawlers\n * can discover the optimized markdown endpoint for the current route.\n * \n * Usage in a Next.js App Router layout:\n * ```tsx\n * import { OntoHead } from '@ontosdk/next/components';\n * \n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <head>\n * <OntoHead />\n * </head>\n * <body>{children}</body>\n * </html>\n * );\n * }\n * ```\n */\nexport function OntoHead() {\n const pathname = usePathname();\n\n // Map current route to its .onto markdown payload path\n let payloadPath = pathname;\n if (payloadPath === '/' || payloadPath === '') {\n payloadPath = '/index';\n }\n if (payloadPath.endsWith('/') && payloadPath !== '/') {\n payloadPath = payloadPath.slice(0, -1);\n }\n\n const markdownHref = `/.onto${payloadPath}.md`;\n\n return (\n <>\n {/* Per-page markdown alternate for AI agents */}\n <link\n rel=\"alternate\"\n type=\"text/markdown\"\n href={markdownHref}\n title=\"AI-optimized Markdown version\"\n />\n {/* Site-wide llms.txt manifest */}\n <link\n rel=\"alternate\"\n type=\"text/plain\"\n href=\"/llms.txt\"\n title=\"LLM-readable site manifest\"\n />\n </>\n );\n}\n"],"mappings":"aAEA,OAAS,eAAAA,MAAmB,kBAuCpB,mBAAAC,EAEI,OAAAC,EAFJ,QAAAC,MAAA,oBAfD,SAASC,GAAW,CAIvB,IAAIC,EAHaL,EAAY,GAIzBK,IAAgB,KAAOA,IAAgB,MACvCA,EAAc,UAEdA,EAAY,SAAS,GAAG,GAAKA,IAAgB,MAC7CA,EAAcA,EAAY,MAAM,EAAG,EAAE,GAGzC,IAAMC,EAAe,SAASD,CAAW,MAEzC,OACIF,EAAAF,EAAA,CAEI,UAAAC,EAAC,QACG,IAAI,YACJ,KAAK,gBACL,KAAMI,EACN,MAAM,gCACV,EAEAJ,EAAC,QACG,IAAI,YACJ,KAAK,aACL,KAAK,YACL,MAAM,6BACV,GACJ,CAER","names":["usePathname","Fragment","jsx","jsxs","OntoHead","payloadPath","markdownHref"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { OntoConfig } from './config.mjs';
|
|
4
|
+
|
|
5
|
+
interface OntoProviderProps {
|
|
6
|
+
/**
|
|
7
|
+
* The base URL of your site (e.g., 'https://example.com')
|
|
8
|
+
* Used to construct the full href for the AI discovery link tag.
|
|
9
|
+
*/
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* Child components to render
|
|
13
|
+
*/
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Optional: Onto configuration for automatic JSON-LD schema injection
|
|
17
|
+
* If provided, the provider will automatically inject JSON-LD schemas
|
|
18
|
+
* based on the page type configuration
|
|
19
|
+
*/
|
|
20
|
+
config?: OntoConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* OntoProvider — Automatic AI Discovery Provider
|
|
24
|
+
*
|
|
25
|
+
* Wraps your application and automatically injects:
|
|
26
|
+
* 1. `<link rel="alternate">` tags for AI discovery
|
|
27
|
+
* 2. JSON-LD structured data schemas based on page type
|
|
28
|
+
*
|
|
29
|
+
* With config, automatically generates JSON-LD schemas:
|
|
30
|
+
* - 'scoring' pages get Methodology schema with AIO weights (40/35/25)
|
|
31
|
+
* - 'about' pages get Organization/AboutPage schema
|
|
32
|
+
*
|
|
33
|
+
* Usage in a Next.js App Router layout:
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { OntoProvider } from '@ontosdk/next/provider';
|
|
36
|
+
* import config from '../onto.config';
|
|
37
|
+
*
|
|
38
|
+
* export default function RootLayout({ children }) {
|
|
39
|
+
* return (
|
|
40
|
+
* <OntoProvider baseUrl="https://example.com" config={config}>
|
|
41
|
+
* <html>
|
|
42
|
+
* <head />
|
|
43
|
+
* <body>{children}</body>
|
|
44
|
+
* </html>
|
|
45
|
+
* </OntoProvider>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function OntoProvider({ baseUrl, children, config }: OntoProviderProps): react_jsx_runtime.JSX.Element;
|
|
51
|
+
|
|
52
|
+
export { OntoProvider, type OntoProviderProps };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { OntoConfig } from './config.js';
|
|
4
|
+
|
|
5
|
+
interface OntoProviderProps {
|
|
6
|
+
/**
|
|
7
|
+
* The base URL of your site (e.g., 'https://example.com')
|
|
8
|
+
* Used to construct the full href for the AI discovery link tag.
|
|
9
|
+
*/
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/**
|
|
12
|
+
* Child components to render
|
|
13
|
+
*/
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Optional: Onto configuration for automatic JSON-LD schema injection
|
|
17
|
+
* If provided, the provider will automatically inject JSON-LD schemas
|
|
18
|
+
* based on the page type configuration
|
|
19
|
+
*/
|
|
20
|
+
config?: OntoConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* OntoProvider — Automatic AI Discovery Provider
|
|
24
|
+
*
|
|
25
|
+
* Wraps your application and automatically injects:
|
|
26
|
+
* 1. `<link rel="alternate">` tags for AI discovery
|
|
27
|
+
* 2. JSON-LD structured data schemas based on page type
|
|
28
|
+
*
|
|
29
|
+
* With config, automatically generates JSON-LD schemas:
|
|
30
|
+
* - 'scoring' pages get Methodology schema with AIO weights (40/35/25)
|
|
31
|
+
* - 'about' pages get Organization/AboutPage schema
|
|
32
|
+
*
|
|
33
|
+
* Usage in a Next.js App Router layout:
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { OntoProvider } from '@ontosdk/next/provider';
|
|
36
|
+
* import config from '../onto.config';
|
|
37
|
+
*
|
|
38
|
+
* export default function RootLayout({ children }) {
|
|
39
|
+
* return (
|
|
40
|
+
* <OntoProvider baseUrl="https://example.com" config={config}>
|
|
41
|
+
* <html>
|
|
42
|
+
* <head />
|
|
43
|
+
* <body>{children}</body>
|
|
44
|
+
* </html>
|
|
45
|
+
* </OntoProvider>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function OntoProvider({ baseUrl, children, config }: OntoProviderProps): react_jsx_runtime.JSX.Element;
|
|
51
|
+
|
|
52
|
+
export { OntoProvider, type OntoProviderProps };
|