Skip to content
Merged
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
4 changes: 4 additions & 0 deletions apps/svelte.dev/src/lib/server/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const defaults: MinimizeOptions = {
remove_prettier_ignore: false
};

export function remove_playground_links(content: string): string {
return content.replaceAll(/\[([^\]]+)\]\((https:\/\/svelte\.dev)?\/playground.+\)/g, '$1');
}

export function generate_llm_content(options: GenerateLlmContentOptions): string {
let content = '';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { error } from '@sveltejs/kit';
import { docs } from '$lib/server/content.js';
import { generate_llm_content, get_documentation_title } from '$lib/server/llms';
import {
generate_llm_content,
get_documentation_title,
remove_playground_links
} from '$lib/server/llms';
import { topics } from '$lib/topics';

export const prerender = true;
Expand All @@ -19,7 +23,7 @@ export function GET({ params }) {
error(404, 'Not Found');
}

return new Response(page.body, {
return new Response(remove_playground_links(page.body), {
status: 200,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
Expand All @@ -34,7 +38,7 @@ export function GET({ params }) {
}

const prefix = `<SYSTEM>${get_documentation_title(topic)}</SYSTEM>`;
const content = `${prefix}\n\n${generate_llm_content({ topics: [topic] })}`;
const content = `${prefix}\n\n${remove_playground_links(generate_llm_content({ topics: [topic] }))}`;

return new Response(content, {
status: 200,
Expand Down
4 changes: 2 additions & 2 deletions apps/svelte.dev/src/routes/llms-full.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { generate_llm_content } from '$lib/server/llms';
import { generate_llm_content, remove_playground_links } from '$lib/server/llms';
import { topics } from '$lib/topics';

export const prerender = true;

export function GET() {
const content = `<SYSTEM>This is the full developer documentation for Svelte and SvelteKit.</SYSTEM>\n\n${generate_llm_content({ topics })}`;

return new Response(content, {
return new Response(remove_playground_links(content), {
status: 200,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
Expand Down
4 changes: 2 additions & 2 deletions apps/svelte.dev/src/routes/llms-medium.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generate_llm_content } from '$lib/server/llms';
import { generate_llm_content, remove_playground_links } from '$lib/server/llms';
import { topics } from '$lib/topics';

export function GET() {
Expand Down Expand Up @@ -35,7 +35,7 @@ export function GET() {
});
const content = `<SYSTEM>This is the abridged developer documentation for Svelte and SvelteKit.</SYSTEM>\n\n${main_content}`;

return new Response(content, {
return new Response(remove_playground_links(content), {
status: 200,
headers: {
'Content-Type': 'text/plain; charset=utf-8',
Expand Down
4 changes: 2 additions & 2 deletions apps/svelte.dev/src/routes/llms.txt/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { get_documentation_title } from '$lib/server/llms';
import { get_documentation_title, remove_playground_links } from '$lib/server/llms';
import { topics } from '$lib/topics';
import template from './template.md?raw';

Expand All @@ -14,7 +14,7 @@ export function GET() {

const content = template.replace('%PACKAGE_DOCS%', package_docs.join('\n'));

return new Response(content, {
return new Response(remove_playground_links(content), {
headers: {
'Content-Type': 'text/plain; charset=utf-8',
'Cache-Control': 'public, max-age=3600'
Expand Down