Skip to content
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
30 changes: 29 additions & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,48 @@ http {
default "";
}

# Content negotiation: clients asking for markdown (Claude sends
# `Accept: text/markdown`) get the llms.txt rendition of the same URL.
map $http_accept $negotiated_index {
~*text/markdown llms.txt;
default index.html;
}

server {
listen 8080;
access_log /dev/stdout;
root /app/public;

add_header Vary Accept;

location ~ ^/openapi(.*)\.json$ {
add_header Access-Control-Allow-Origin *;
add_header Vary Accept;
}

# bin/compress.js writes a .br/.gz sibling for every file. gzip_static and
# brotli_static read those from disk while serving the original URL, so the
# siblings need no URL of their own. A genuine .br/.gz download would need
# an exception here.
location ~ \.(br|gz)$ {
internal;
}

# The markdown rendition Hugo writes alongside each index.html. `internal`
# keeps it reachable only via the negotiation above, so every page has
# exactly one public URL. mime.types would serve it as text/plain.
location ~ (^|/)llms\.txt$ {
internal;
types { }
default_type text/markdown;
charset_types text/markdown;
}

if ($redirect_uri != "") {
rewrite ^(.*)$ $redirect_uri redirect;
}

index index.html;
index $negotiated_index index.html;
error_page 404 /404.html;
}
}
8 changes: 0 additions & 8 deletions themes/hugo-docs/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@
rel="apple-touch-icon"
href="{{ "apple-touch-icon.png" | relURL }}"
/>
{{ with .OutputFormats.Get "llms" }}
<link
rel="alternate"
type="text/markdown"
title="LLM-friendly version"
href="{{ .Permalink }}"
/>
{{ end }}
<title>{{ .Page.Title }} - {{ .Section | default "Documentation" | humanize }}</title>
{{ block "meta" . }}{{ end }}
{{ partialCached "html-header-global-meta.html" . }}
Expand Down
13 changes: 5 additions & 8 deletions themes/hugo-docs/layouts/partials/link.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{{- /* Resolve an internal ref to the correct output format. Accepts a path
string (format auto-detected from the calling template) or a dict
{path, format} for callers that can't be auto-detected (e.g. nested
partials). RelRef preserves an inline #anchor. */ -}}
{{- $path := . -}}
{{- $fmt := cond (hasSuffix templates.Current.Parent.Name ".llms.txt") "llms" "html" -}}
{{- if reflect.IsMap . -}}{{ $path = .path }}{{ with .format }}{{ $fmt = . }}{{ end }}{{- end -}}
{{- page.RelRef (dict "path" $path "outputFormat" $fmt) -}}
{{- /* Resolve an internal ref to its canonical URL. Markdown output links to
the same URLs the HTML does; nginx serves the markdown rendition there
to clients sending `Accept: text/markdown`. RelRef preserves an inline
#anchor. */ -}}
{{- page.RelRef (dict "path" . "outputFormat" "html") -}}
2 changes: 1 addition & 1 deletion themes/hugo-docs/layouts/partials/prose-md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{{- /* ref -> absolute URL */ -}}
{{- range $m := findRE `\{\{<\s*ref\s+\\?"[^"\\]+\\?"\s*>\}\}` $text -}}
{{- $p := replaceRE `^\{\{<\s*ref\s+\\?"([^"\\]+)\\?"\s*>\}\}$` "$1" $m -}}
{{- $text = replace $text $m (partial "link" (dict "path" $p "format" "llms")) -}}
{{- $text = replace $text $m (partial "link" $p) -}}
{{- end -}}
{{- /* added/deprecated/removed-in -> release link */ -}}
{{- range $m := findRE `\{\{<\s*(?:added|deprecated|removed)-in\s+\\?"[^"\\]+\\?"[^}]*>\}\}` $text -}}
Expand Down
4 changes: 1 addition & 3 deletions themes/hugo-docs/layouts/shortcodes/illu-teaser.llms.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{{- $link := .Get "link" -}}
{{- if hasSuffix $link "/" }}{{ $link = print $link "llms.txt" }}{{ end -}}
- **[{{ .Get "flag" }}]({{ $link }})** — {{ .Get "title" }}
- **[{{ .Get "flag" }}]({{ .Get "link" }})** — {{ .Get "title" }}