mirror of
https://github.com/docker/docs.git
synced 2026-10-23 18:09:02 +03:00
The include shortcode previously called readFile directly, which renders nothing when the target is missing instead of failing. That let renamed or deleted snippets linger as silent no-ops (for example the stale scout-early-access.md and compose/develop.md references). Check fileExists first and errorf with the shortcode position when the target is missing, mirroring the file/files shortcodes. Verified against Hugo 0.163.0: valid includes still render; a missing target now fails the build with the offending file and line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
640 B
HTML
18 lines
640 B
HTML
{{/*
|
|
include shortcode — inlines a reusable snippet from content/includes.
|
|
|
|
Usage:
|
|
{{% include "root-errors.md" %}}
|
|
{{% include "compose/services.md" %}}
|
|
|
|
The argument is a path relative to content/includes. The build fails with
|
|
a clear message if the target does not exist, so a renamed or deleted
|
|
snippet surfaces immediately instead of silently rendering nothing.
|
|
*/}}
|
|
{{ $fileToInclude := .Get 0 }}
|
|
{{ $filePath := printf "includes/%s" $fileToInclude }}
|
|
{{ if not (fileExists $filePath) }}
|
|
{{- errorf "include shortcode: file %q not found: %s" $filePath .Position -}}
|
|
{{ end }}
|
|
{{ readFile $filePath | safeHTML }}
|