Skip to content

Change llms txt files to folllow semi-standards more closely #3444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions src/pages/[...llm_slug].ts

This file was deleted.

26 changes: 26 additions & 0 deletions src/pages/llms-full.txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { getCollection } from 'astro:content';
import type { APIRoute } from 'astro';
import { aboutBlurb, groupDocsByPrefix } from './llms.txt';

function getHeaderLevel(slug: string): number {
return slug.split('/').length + 1;
}

export const GET: APIRoute = async ({ params, request }) => {
const docs = await getCollection('docs');
const docsBySection = groupDocsByPrefix(docs);
let content = `# Tauri Full Documentation\n\n> ${aboutBlurb}\n`;

for (const [prefix, docs] of docsBySection) {
content += `\n# ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
content += docs
.map((doc) => {
return `# ${doc.data.title}\n\n${doc.body}\n\n`;
})
.join('');
}

return new Response(content, {
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
};
55 changes: 0 additions & 55 deletions src/pages/llms.toc.txt.ts

This file was deleted.

59 changes: 38 additions & 21 deletions src/pages/llms.txt.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
import { getCollection } from 'astro:content';
import type { APIRoute } from 'astro';
import { llmsTxtSections, groupDocsByPrefix } from './[...llm_slug]';

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.`;
export function groupDocsByPrefix(docs: Awaited<ReturnType<typeof getCollection<'docs'>>>) {
// TODO: This is missing the reference pages.
const prefixes = ['start', 'concept', 'security', 'develop', 'distribute', 'learn', 'plugins'];

function getHeaderLevel(slug: string): number {
return slug.split('/').length + 1;
const grouped = new Map<string, typeof docs>();
prefixes.forEach((prefix) => {
grouped.set(
prefix,
docs.filter((doc) => doc.id.startsWith(prefix))
);
});

return grouped;
}

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.`;

const organizationBlur = `This index links to documentation that covers everything from getting started to advanced concepts, and distribution of Tauri applications.

The index is organized into key sections:
- **start**: Information for getting up and running with Tauri, including prerequisites and installation instructions
- **core concepts**: Topics that you should get more intimately familiar with if you want to get the most out of the framework.
- **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
- **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.
- **distribute**: Information on the tooling you need to distribute your application either to the platform app stores or as platform-specific installers.
- **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.
- **plugins**: Information on the extensibility of Tauri from Built-in Tauri features and functionality to provided plugins and recipes built by the Tauri community
- **about**: Various information about Tauri from governance, philosophy, and trademark guidelines.

Each section contains links to detailed markdown files that provide comprehensive information about Tauri's features and how to use them effectively.`;

export const GET: APIRoute = async ({ params, request }) => {
const docs = await getCollection('docs');
const docsBySection = groupDocsByPrefix(llmsTxtSections, docs);
let content = `# Tauri app Full Documentation\n\n${aboutBlurb}\n\n**Table of Contents**\n`;

let n = 1;
for (const [prefix, items] of docsBySection) {
const grouped = groupDocsByPrefix(docs);
let content = `# Tauri Full Documentation\n\n> ${aboutBlurb}\n\n${organizationBlur}\n\n**Table of Contents**\n`;
for (const [prefix, items] of grouped) {
if (items.length > 0) {
content += `\n${n++}. ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
content += `\n## ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
items.forEach((doc) => {
const level = getHeaderLevel(doc.id);
const indent = ' '.repeat(level - 2);
content += `${indent}- [${doc.data.title}](#${doc.id})\n`;
content += `- [${doc.data.title}](https://v2.tauri.app/${doc.id})`;
// TODO: We need to add a description on every docpage for it to show up here.
if (doc.data.description && doc.data.description.trim() !== '') {
content += `: ${doc.data.description}`;
}
content += '\n';
});
}
}
for (const [prefix, docs] of docsBySection) {
content += `\n# ${prefix.charAt(0).toUpperCase() + prefix.slice(1)}\n`;
content += docs
.map((doc) => {
return `# ${doc.data.title}\n\n${doc.body}\n\n`;
})
.join('');
}

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