From 9ba0d667b511f955a4fc78553167b6e02ff3d53d Mon Sep 17 00:00:00 2001 From: Paul Osinski Date: Wed, 18 Nov 2026 16:19:41 -0500 Subject: [PATCH 1/8] docs: serve each page as Markdown and add a Copy page as Markdown button Every docs page now has a Markdown copy at /index.md, built from its source with the highlight, tabs and quiz shortcodes turned into plain Markdown and its links made absolute. The theme advertises it with a rel="alternate" type="text/markdown" link, and llms.txt now links each page's Markdown copy, as llmstxt.org recommends. Under each page title, "Copy page as Markdown" puts that copy on the clipboard and "View as Markdown" opens it. Labels are translated in all eight docs languages. Co-Authored-By: Claude Opus 5.5 --- docs/assets/js/custom.js | 39 +++++++++++++++++++ docs/assets/scss/common/_custom.scss | 23 +++++++++++ docs/config/_default/hugo.toml | 10 +++++ docs/config/_default/languages.toml | 1 + docs/i18n/de.toml | 12 ++++++ docs/i18n/en.toml | 12 ++++++ docs/i18n/es.toml | 12 ++++++ docs/i18n/fr.toml | 12 ++++++ docs/i18n/it.toml | 12 ++++++ docs/i18n/ja.toml | 12 ++++++ docs/i18n/pt-br.toml | 12 ++++++ docs/i18n/zh-hans.toml | 12 ++++++ docs/layouts/_partials/main/page-actions.html | 12 ++++++ docs/layouts/home.llmstxt.txt | 11 ++++-- docs/layouts/single.html | 1 + docs/layouts/single.markdown.md | 28 +++++++++++++ 16 files changed, 218 insertions(+), 3 deletions(-) create mode 100644 docs/layouts/_partials/main/page-actions.html create mode 100644 docs/layouts/single.markdown.md diff --git a/docs/assets/js/custom.js b/docs/assets/js/custom.js index 35d4f3c343d..02d79f0b3a1 100644 --- a/docs/assets/js/custom.js +++ b/docs/assets/js/custom.js @@ -356,3 +356,42 @@ window.ddOffcanvas = Offcanvas; replay() { fields.forEach((f) => { f.seed(); f.resolve(); }); }, }; })(); + + +// "Copy page as Markdown" (layouts/_partials/main/page-actions.html): fetch the +// page's Markdown copy and put it on the clipboard. The fetch result is handed +// to ClipboardItem as a promise so Safari still counts the write as part of the +// click; browsers without ClipboardItem fall back to writeText. +(() => { + "use strict"; + + document.querySelectorAll('[data-dd-copy-markdown]').forEach((button) => { + const status = button.parentElement.querySelector('.dd-page-actions-status'); + let clearTimer = null; + + const say = (text) => { + if (!status) return; + status.textContent = text; + clearTimeout(clearTimer); + clearTimer = setTimeout(() => { status.textContent = ''; }, 4000); + }; + + button.addEventListener('click', async () => { + const text = fetch(button.dataset.ddCopyMarkdown).then((response) => { + if (!response.ok) throw new Error(`HTTP ${response.status}`); + return response.text(); + }); + try { + if (window.ClipboardItem && navigator.clipboard.write) { + const blob = text.then((t) => new Blob([t], { type: 'text/plain' })); + await navigator.clipboard.write([new ClipboardItem({ 'text/plain': blob })]); + } else { + await navigator.clipboard.writeText(await text); + } + say(button.dataset.ddCopied); + } catch (e) { + say(button.dataset.ddFailed); + } + }); + }); +})(); diff --git a/docs/assets/scss/common/_custom.scss b/docs/assets/scss/common/_custom.scss index d51377f6a76..a47a0609b1f 100644 --- a/docs/assets/scss/common/_custom.scss +++ b/docs/assets/scss/common/_custom.scss @@ -1972,3 +1972,26 @@ body.home .site-footer { .bg-dots { background-image: none !important; } + +// "Copy page as Markdown" row under the page title (page-actions.html) +.dd-page-actions { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 0.25rem 0.5rem; + margin: -0.5rem 0 1.5rem; + + // The theme's secondary teal is too dark to read on the dark background + .btn-outline-secondary { + --bs-btn-color: var(--bs-body-color); + --bs-btn-border-color: var(--bs-border-color); + --bs-btn-hover-color: var(--bs-body-color); + --bs-btn-hover-bg: var(--bs-tertiary-bg); + --bs-btn-hover-border-color: var(--bs-body-color); + } +} + +.dd-page-actions-status { + font-size: 0.875rem; + color: var(--bs-secondary-color); +} diff --git a/docs/config/_default/hugo.toml b/docs/config/_default/hugo.toml index a384ddac755..60f292d2cf8 100644 --- a/docs/config/_default/hugo.toml +++ b/docs/config/_default/hugo.toml @@ -29,6 +29,7 @@ copyRight = "Copyright (c) 2020-2025 DefectDojo, Inc." [outputs] home = ["HTML", "RSS", "searchIndex", "SITEMAP"] + page = ["HTML", "markdown"] section = ["HTML", "RSS", "SITEMAP"] [outputFormats.searchIndex] @@ -46,6 +47,15 @@ copyRight = "Copyright (c) 2020-2025 DefectDojo, Inc." isPlainText = true notAlternative = true +# /index.md: each page's source as plain Markdown, for AI assistants and +# the "Copy page as Markdown" button. Generated by layouts/single.markdown.md; +# /llms.txt links to these files rather than to the HTML pages. +[outputFormats.markdown] + mediaType = "text/markdown" + baseName = "index" + isPlainText = true + rel = "alternate" + # Add output format for section sitemap.xml [outputFormats.SITEMAP] mediaType = "application/xml" diff --git a/docs/config/_default/languages.toml b/docs/config/_default/languages.toml index e706e32fc74..ac7d6e3c933 100644 --- a/docs/config/_default/languages.toml +++ b/docs/config/_default/languages.toml @@ -18,6 +18,7 @@ # with that one. [en.outputs] home = ["HTML", "RSS", "searchIndex", "SITEMAP", "llmstxt"] + page = ["HTML", "markdown"] section = ["HTML", "RSS", "SITEMAP"] [de] diff --git a/docs/i18n/de.toml b/docs/i18n/de.toml index cb5b08cb013..98cab45f115 100644 --- a/docs/i18n/de.toml +++ b/docs/i18n/de.toml @@ -189,3 +189,15 @@ other = "Neu in {{ .release }}" [card_connectors_title] other = "Connectors" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Seite als Markdown kopieren" + +[dd_copy_markdown_done] +other = "Kopiert" + +[dd_copy_markdown_failed] +other = "Kopieren fehlgeschlagen. Verwenden Sie stattdessen „Als Markdown anzeigen“." + +[dd_view_markdown] +other = "Als Markdown anzeigen" diff --git a/docs/i18n/en.toml b/docs/i18n/en.toml index 450bc9048d3..e851172f08a 100644 --- a/docs/i18n/en.toml +++ b/docs/i18n/en.toml @@ -195,3 +195,15 @@ other = "What's new in {{ .release }}" [card_connectors_title] other = "Connectors" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Copy page as Markdown" + +[dd_copy_markdown_done] +other = "Copied" + +[dd_copy_markdown_failed] +other = "Copy failed. Use View as Markdown instead." + +[dd_view_markdown] +other = "View as Markdown" diff --git a/docs/i18n/es.toml b/docs/i18n/es.toml index e68d520b4b8..c96a8f7394e 100644 --- a/docs/i18n/es.toml +++ b/docs/i18n/es.toml @@ -189,3 +189,15 @@ other = "Novedades de {{ .release }}" [card_connectors_title] other = "Conectores" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Copiar página como Markdown" + +[dd_copy_markdown_done] +other = "Copiado" + +[dd_copy_markdown_failed] +other = "No se pudo copiar. Use «Ver como Markdown»." + +[dd_view_markdown] +other = "Ver como Markdown" diff --git a/docs/i18n/fr.toml b/docs/i18n/fr.toml index 56c3a4bb698..c23fddd027a 100644 --- a/docs/i18n/fr.toml +++ b/docs/i18n/fr.toml @@ -189,3 +189,15 @@ other = "Nouveautés de {{ .release }}" [card_connectors_title] other = "Connecteurs" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Copier la page en Markdown" + +[dd_copy_markdown_done] +other = "Copié" + +[dd_copy_markdown_failed] +other = "La copie a échoué. Utilisez « Afficher en Markdown »." + +[dd_view_markdown] +other = "Afficher en Markdown" diff --git a/docs/i18n/it.toml b/docs/i18n/it.toml index 21268b3cb5c..f4c5dd8351d 100644 --- a/docs/i18n/it.toml +++ b/docs/i18n/it.toml @@ -250,3 +250,15 @@ other = "Novità di {{ .release }}" [card_connectors_title] other = "Connectors" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Copia pagina come Markdown" + +[dd_copy_markdown_done] +other = "Copiato" + +[dd_copy_markdown_failed] +other = "Copia non riuscita. Usa «Visualizza come Markdown»." + +[dd_view_markdown] +other = "Visualizza come Markdown" diff --git a/docs/i18n/ja.toml b/docs/i18n/ja.toml index ed6a71493de..d1f4a17b9aa 100644 --- a/docs/i18n/ja.toml +++ b/docs/i18n/ja.toml @@ -250,3 +250,15 @@ other = "{{ .release }} の新機能" [card_connectors_title] other = "コネクター" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "ページを Markdown でコピー" + +[dd_copy_markdown_done] +other = "コピーしました" + +[dd_copy_markdown_failed] +other = "コピーできませんでした。「Markdown で表示」を使ってください。" + +[dd_view_markdown] +other = "Markdown で表示" diff --git a/docs/i18n/pt-br.toml b/docs/i18n/pt-br.toml index ce042040968..39d8656ca57 100644 --- a/docs/i18n/pt-br.toml +++ b/docs/i18n/pt-br.toml @@ -250,3 +250,15 @@ other = "Novidades em {{ .release }}" [card_connectors_title] other = "Conectores" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "Copiar página como Markdown" + +[dd_copy_markdown_done] +other = "Copiado" + +[dd_copy_markdown_failed] +other = "Não foi possível copiar. Use \"Ver como Markdown\"." + +[dd_view_markdown] +other = "Ver como Markdown" diff --git a/docs/i18n/zh-hans.toml b/docs/i18n/zh-hans.toml index b067d6d465f..cd4b1d470d8 100644 --- a/docs/i18n/zh-hans.toml +++ b/docs/i18n/zh-hans.toml @@ -250,3 +250,15 @@ other = "{{ .release }} 中的新增功能" [card_connectors_title] other = "连接器" +# Page actions under the title (layouts/_partials/main/page-actions.html) +[dd_copy_markdown] +other = "将页面复制为 Markdown" + +[dd_copy_markdown_done] +other = "已复制" + +[dd_copy_markdown_failed] +other = "复制失败。请改用“以 Markdown 查看”。" + +[dd_view_markdown] +other = "以 Markdown 查看" diff --git a/docs/layouts/_partials/main/page-actions.html b/docs/layouts/_partials/main/page-actions.html new file mode 100644 index 00000000000..52644f6f15d --- /dev/null +++ b/docs/layouts/_partials/main/page-actions.html @@ -0,0 +1,12 @@ +{{- /* + "Copy page as Markdown" and "View as Markdown" under the page title. Both + use the page's Markdown copy (layouts/single.markdown.md); the copy click + is wired in assets/js/custom.js. Rendered only for pages that have one. +*/ -}} +{{- with .OutputFormats.Get "markdown" }} +
+ + {{ i18n "dd_view_markdown" }} + +
+{{- end }} diff --git a/docs/layouts/home.llmstxt.txt b/docs/layouts/home.llmstxt.txt index 066d15fc46e..fe83602ec02 100644 --- a/docs/layouts/home.llmstxt.txt +++ b/docs/layouts/home.llmstxt.txt @@ -2,8 +2,9 @@ /llms.txt for docs.defectdojo.com, following https://llmstxt.org. Built from the English page tree on every build, so new pages appear automatically. Sections are listed in sidebar order and pages in weight - order. A top-level section missing from $order still appears, under its - own title, before Optional. The "en" section only holds legacy redirect + order, and each entry links the page's Markdown copy (/index.md). + A top-level section missing from $order still appears, under its own + title, before Optional. The "en" section only holds legacy redirect stubs and is skipped. Other languages get no llms.txt content. */ -}} {{- if eq site.Language.Lang "en" -}} @@ -39,6 +40,7 @@ Key facts: - It deduplicates findings within a tool, across tools and across reimports, as described in {{ absURL "triage_findings/finding_deduplication/deduplication_across_tools/" }} - The remaining findings are tracked through remediation with SLAs, risk acceptance, reimports that close fixed findings, and ticketing integrations such as Jira. - DefectDojo Sensei is the AI layer in DefectDojo Pro. +- The links below go to each page as Markdown. Any docs page, in any language, is available as Markdown at its URL followed by index.md. - Company website: https://defectdojo.com (its own llms.txt is https://defectdojo.com/llms.txt). Source code: https://github.com/DefectDojo/django-DefectDojo {{- range $order }} {{- $heading := index . 1 }} @@ -84,5 +86,8 @@ Key facts: {{- else if and (eq . "opensource") (not (findRE `(?i)open.?source` $title)) }}{{ $title = printf "%s (Open Source)" $title }}{{ end }} {{- end }} {{- $desc := .Description | plainify | replaceRE `\s+` " " | strings.TrimSpace }} -{{ printf "- [%s](%s)" $title .Permalink }}{{ with $desc }}: {{ . }}{{ end }} + {{- /* Link the Markdown copy of the page (layouts/single.markdown.md), as llmstxt.org recommends. */}} + {{- $url := .Permalink }} + {{- with .OutputFormats.Get "markdown" }}{{ $url = .Permalink }}{{ end }} +{{ printf "- [%s](%s)" $title $url }}{{ with $desc }}: {{ . }}{{ end }} {{- end }} diff --git a/docs/layouts/single.html b/docs/layouts/single.html index 5b89dd5b26a..1af64a45c5c 100644 --- a/docs/layouts/single.html +++ b/docs/layouts/single.html @@ -28,6 +28,7 @@ {{ end }}

{{ .Title }}{{ with .Params.audience }}{{ if eq . "opensource" }} (Open Source){{ else if eq . "pro" }} (Pro){{ end }}{{ end }}

+ {{ partial "main/page-actions.html" . }} {{ if ne .Params.toc false -}}