From a69a1292c2c6b4db8f22b60c1927714b99ec3eb5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Feb 2026 09:20:24 +0000 Subject: [PATCH] fix: remove basePath from llms.txt URL generation to avoid duplicated paths SITE_URL already includes the base path (e.g., https://aszenz.github.io/data-explorer), so appending basePath again caused URLs like /data-explorer/data-explorer/. https://claude.ai/code/session_013EEswtBtNGKgqVDj7GPw6j --- plugins/vite-plugin-llms-txt.ts | 1 - src/llms-txt/generator.ts | 34 +++++++++------------------------ 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/plugins/vite-plugin-llms-txt.ts b/plugins/vite-plugin-llms-txt.ts index b5de04b..56ff8e4 100644 --- a/plugins/vite-plugin-llms-txt.ts +++ b/plugins/vite-plugin-llms-txt.ts @@ -52,7 +52,6 @@ export default function llmsTxtPlugin(options: LlmsTxtPluginOptions): Plugin { return generateLlmsTxtContent({ siteTitle, - basePath: config.base, siteUrl, models, dataFiles, diff --git a/src/llms-txt/generator.ts b/src/llms-txt/generator.ts index d730606..5a15032 100644 --- a/src/llms-txt/generator.ts +++ b/src/llms-txt/generator.ts @@ -8,7 +8,6 @@ import type { ExtractedModel } from "./types"; export interface GeneratorOptions { siteTitle: string; - basePath: string; siteUrl: string; models: ExtractedModel[]; dataFiles: string[]; @@ -16,20 +15,12 @@ export interface GeneratorOptions { } export function generateLlmsTxtContent(options: GeneratorOptions): string { - const { siteTitle, basePath, siteUrl, models, dataFiles, notebooks } = - options; + const { siteTitle, siteUrl, models, dataFiles, notebooks } = options; const sections = [ - generateHeader(siteTitle, basePath, siteUrl), - generateOverview( - siteTitle, - basePath, - siteUrl, - models, - dataFiles, - notebooks, - ), - generateModelsSection(models, basePath), + generateHeader(siteTitle, siteUrl), + generateOverview(siteTitle, siteUrl, models, dataFiles, notebooks), + generateModelsSection(models, siteUrl), generateQueryParametersSection(), generateMalloyQueryGuide(), ]; @@ -37,13 +28,8 @@ export function generateLlmsTxtContent(options: GeneratorOptions): string { return sections.join("\n\n"); } -function generateHeader( - siteTitle: string, - basePath: string, - siteUrl: string, -): string { - const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; - const fullUrl = `${siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl}${base}/`; +function generateHeader(siteTitle: string, siteUrl: string): string { + const fullUrl = `${siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl}/`; return `# ${siteTitle} > Malloy Data Explorer - Static web app for exploring semantic data models @@ -54,14 +40,12 @@ function generateHeader( function generateOverview( _siteTitle: string, - basePath: string, siteUrl: string, models: ExtractedModel[], dataFiles: string[], notebooks: string[], ): string { - const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; - const fullBase = `${siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl}${base}`; + const fullBase = siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl; // Content summary const contentItems = [ @@ -136,13 +120,13 @@ function generateOverview( function generateModelsSection( models: ExtractedModel[], - basePath: string, + siteUrl: string, ): string { if (models.length === 0) { return "## Models\n\nNo models available."; } - const base = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath; + const base = siteUrl.endsWith("/") ? siteUrl.slice(0, -1) : siteUrl; const modelSections = models.map((model) => { const sourceSections = model.sources