Skip to content

Commit fd4d583

Browse files
authored
Change llms txt files to folllow semi-standards more closely (#3444)
1 parent 3cdc384 commit fd4d583

File tree

4 files changed

+64
-138
lines changed

4 files changed

+64
-138
lines changed

src/pages/[...llm_slug].ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

src/pages/llms-full.txt.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { getCollection } from 'astro:content';
2+
import type { APIRoute } from 'astro';
3+
import { aboutBlurb, groupDocsByPrefix } from './llms.txt';
4+
5+
function getHeaderLevel(slug: string): number {
6+
return slug.split('/').length + 1;
7+
}
8+
9+
export const GET: APIRoute = async ({ params, request }) => {
10+
const docs = await getCollection('docs');
11+
const docsBySection = groupDocsByPrefix(docs);
12+
let content = `# Tauri Full Documentation\n\n> ${aboutBlurb}\n`;
13+
14+
for (const [prefix, docs] of docsBySection) {
15+
content += `\n# ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
16+
content += docs
17+
.map((doc) => {
18+
return `# ${doc.data.title}\n\n${doc.body}\n\n`;
19+
})
20+
.join('');
21+
}
22+
23+
return new Response(content, {
24+
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
25+
});
26+
};

src/pages/llms.toc.txt.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/pages/llms.txt.ts

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,54 @@
11
import { getCollection } from 'astro:content';
22
import type { APIRoute } from 'astro';
3-
import { llmsTxtSections, groupDocsByPrefix } from './[...llm_slug]';
43

5-
const aboutBlurb = `Tauri is a framework for building tiny, fast binaries for all major desktop and mobile platforms. Developers can integrate any frontend framework that compiles to HTML, JavaScript, and CSS for building their user experience while leveraging languages such as Rust, Swift, and Kotlin for backend logic when needed.`;
4+
export function groupDocsByPrefix(docs: Awaited<ReturnType<typeof getCollection<'docs'>>>) {
5+
// TODO: This is missing the reference pages.
6+
const prefixes = ['start', 'concept', 'security', 'develop', 'distribute', 'learn', 'plugins'];
67

7-
function getHeaderLevel(slug: string): number {
8-
return slug.split('/').length + 1;
8+
const grouped = new Map<string, typeof docs>();
9+
prefixes.forEach((prefix) => {
10+
grouped.set(
11+
prefix,
12+
docs.filter((doc) => doc.id.startsWith(prefix))
13+
);
14+
});
15+
16+
return grouped;
917
}
1018

19+
export const aboutBlurb = `Tauri is a framework for building tiny, fast binaries for all major desktop and mobile platforms. Developers can integrate any frontend framework that compiles to HTML, JavaScript, and CSS for building their user experience while leveraging languages such as Rust, Swift, and Kotlin for backend logic when needed.`;
20+
21+
const organizationBlur = `This index links to documentation that covers everything from getting started to advanced concepts, and distribution of Tauri applications.
22+
23+
The index is organized into key sections:
24+
- **start**: Information for getting up and running with Tauri, including prerequisites and installation instructions
25+
- **core concepts**: Topics that you should get more intimately familiar with if you want to get the most out of the framework.
26+
- **security**: High-level concepts and security features at the core of Tauri's design and ecosystem that make you, your applications and your users more secure by default
27+
- **develop**: Topics pertaining to the development of Tauri applications, including how to use the Tauri API, communicating between the frontend and backend, configuration, state management, debugging and more.
28+
- **distribute**: Information on the tooling you need to distribute your application either to the platform app stores or as platform-specific installers.
29+
- **learn**: Tutorials intended to provided end-to-end learning experiences to guide you through specific Tauri topics and help you apply knowledge from the guides and reference documentation.
30+
- **plugins**: Information on the extensibility of Tauri from Built-in Tauri features and functionality to provided plugins and recipes built by the Tauri community
31+
- **about**: Various information about Tauri from governance, philosophy, and trademark guidelines.
32+
33+
Each section contains links to detailed markdown files that provide comprehensive information about Tauri's features and how to use them effectively.`;
34+
1135
export const GET: APIRoute = async ({ params, request }) => {
1236
const docs = await getCollection('docs');
13-
const docsBySection = groupDocsByPrefix(llmsTxtSections, docs);
14-
let content = `# Tauri app Full Documentation\n\n${aboutBlurb}\n\n**Table of Contents**\n`;
15-
16-
let n = 1;
17-
for (const [prefix, items] of docsBySection) {
37+
const grouped = groupDocsByPrefix(docs);
38+
let content = `# Tauri Full Documentation\n\n> ${aboutBlurb}\n\n${organizationBlur}\n\n**Table of Contents**\n`;
39+
for (const [prefix, items] of grouped) {
1840
if (items.length > 0) {
19-
content += `\n${n++}. ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
41+
content += `\n## ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
2042
items.forEach((doc) => {
21-
const level = getHeaderLevel(doc.id);
22-
const indent = ' '.repeat(level - 2);
23-
content += `${indent}- [${doc.data.title}](#${doc.id})\n`;
43+
content += `- [${doc.data.title}](https://v2.tauri.app/${doc.id})`;
44+
// TODO: We need to add a description on every docpage for it to show up here.
45+
if (doc.data.description && doc.data.description.trim() !== '') {
46+
content += `: ${doc.data.description}`;
47+
}
48+
content += '\n';
2449
});
2550
}
2651
}
27-
for (const [prefix, docs] of docsBySection) {
28-
content += `\n# ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
29-
content += docs
30-
.map((doc) => {
31-
return `# ${doc.data.title}\n\n${doc.body}\n\n`;
32-
})
33-
.join('');
34-
}
3552

3653
return new Response(content, {
3754
headers: { 'Content-Type': 'text/plain; charset=utf-8' },

0 commit comments

Comments
 (0)