From b2e1301f5db47422f342ca524f18cd83c7629cb7 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Fri, 27 Feb 2026 12:21:18 -0600 Subject: [PATCH] llms.txt: fix issue with custom layout --- src/project/types/website/website-llms.ts | 4 +- .../smoke-all/website/llms-txt/_quarto.yml | 1 + .../website/llms-txt/custom-layout.qmd | 50 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/docs/smoke-all/website/llms-txt/custom-layout.qmd diff --git a/src/project/types/website/website-llms.ts b/src/project/types/website/website-llms.ts index 78e7fcaed6..5b8431f31e 100644 --- a/src/project/types/website/website-llms.ts +++ b/src/project/types/website/website-llms.ts @@ -147,10 +147,12 @@ function extractMainContent(doc: Document): string { } // Get the main content area + // Note: use querySelector("body") instead of clone.body because + // deno-dom's cloneNode() doesn't preserve the .body convenience getter const main = clone.querySelector("main") || clone.querySelector("#quarto-document-content") || clone.querySelector("article") || - clone.body; + clone.querySelector("body"); if (!main) { return ""; diff --git a/tests/docs/smoke-all/website/llms-txt/_quarto.yml b/tests/docs/smoke-all/website/llms-txt/_quarto.yml index 16837fcbd9..56fb6e0117 100644 --- a/tests/docs/smoke-all/website/llms-txt/_quarto.yml +++ b/tests/docs/smoke-all/website/llms-txt/_quarto.yml @@ -11,6 +11,7 @@ website: - href: index.qmd text: Home - about.qmd + - custom-layout.qmd sidebar: contents: - section: Info diff --git a/tests/docs/smoke-all/website/llms-txt/custom-layout.qmd b/tests/docs/smoke-all/website/llms-txt/custom-layout.qmd new file mode 100644 index 0000000000..09bc15e2cc --- /dev/null +++ b/tests/docs/smoke-all/website/llms-txt/custom-layout.qmd @@ -0,0 +1,50 @@ +--- +pagetitle: "Custom Layout Page" +page-layout: custom +section-divs: false +toc: false +_quarto: + tests: + html: + ensureLlmsMdExists: true + ensureLlmsMdRegexMatches: + - ["Welcome to the Custom Page", "Feature One", "Feature Two", "Learn more"] + - [] +--- + +::: {.hero-banner} +::: {.content-block} + +# Welcome to the Custom Page + +### A page using custom layout + +- This tests that llms-txt works with page-layout: custom. +- Custom layout pages lack a `
` element in the rendered HTML. + +::: +::: + +::: {.content-block} +::: {.features} + +::: {.feature} +### Feature One +Description of the first feature. + +::: {.learn-more} +[Learn more »](about.qmd) +::: +::: + +::: {.feature} +### Feature Two +Description of the second feature. + +::: {.learn-more} +[Learn more »](about.qmd) +::: +::: + +::: +:::