mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
{{/* prettier-ignore-start */ -}}
|
||||
{{- /*
|
||||
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
|
||||
Renders syntax-highlighted configuration data in JSON, TOML, and YAML formats.
|
||||
|
||||
@param {string} [config] The section of site.Data.docs.config to render.
|
||||
@param {bool} [copy=false] If true, display a copy to clipboard button.
|
||||
@param {string} [file] The file name to display above the rendered code.
|
||||
@param {bool} [fm=false] If true, render the code as front matter.
|
||||
@param {bool} [skipHeader=false] If false, omit top level key(s) when rendering a section of site.Data.docs.config.
|
||||
@param {string} [config] The section of site.Data.docs.config to render.
|
||||
@param {bool} [copy=false] Whether to display a copy-to-clipboard button.
|
||||
@param {string} [dataKey] The section of site.Data.docs to render.
|
||||
@param {string} [file] The file name to display above the rendered code.
|
||||
@param {bool} [fm=false] Whether to render the code as front matter.
|
||||
@param {bool} [skipHeader=false] Whether to omit top level key(s) when rendering a section of site.Data.docs.config.
|
||||
|
||||
@returns {template.HTML}
|
||||
*/}}
|
||||
@example {{< code-toggle file=hugo config=build />}}
|
||||
|
||||
@example {{< code-toggle file=content/example.md fm="true" }}
|
||||
title='Example'
|
||||
draft='false
|
||||
{{< /code-toggle }}
|
||||
*/ -}}
|
||||
{{/* prettier-ignore-end */ -}}
|
||||
{{- /* Initialize. */}}
|
||||
{{- $config := "" }}
|
||||
{{- $dataKey := "" }}
|
||||
{{- $copy := false }}
|
||||
{{- $dataKey := "" }}
|
||||
{{- $file := "" }}
|
||||
{{- $fm := false }}
|
||||
{{- $skipHeader := false }}
|
||||
@@ -60,22 +67,26 @@
|
||||
{{- else }}
|
||||
{{- $code = $.Inner }}
|
||||
{{- end }}
|
||||
<div x-data class="shortcode-code not-prose relative p-0 mt-2 mb-4 sm:mb-8">
|
||||
<svg
|
||||
class="absolute right-2 top-0 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-8"
|
||||
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
|
||||
<use href="#icon--copy"></use>
|
||||
</svg>
|
||||
|
||||
|
||||
<div x-data class="shortcode-code not-prose relative p-0 mt-6 mb-8">
|
||||
{{- if $copy }}
|
||||
<svg
|
||||
class="absolute right-4 top-12 z-30 text-blue-600 hover:text-blue-500 cursor-pointer w-6 h-6"
|
||||
@click="$copy($refs[$store.nav.userSettings.settings.configFileType])">
|
||||
<use href="#icon--copy"></use>
|
||||
</svg>
|
||||
{{- end }}
|
||||
<nav class="relative flex" aria-label="Tabs">
|
||||
{{ with $file }}
|
||||
{{- with $file }}
|
||||
<div
|
||||
class="flex-none text-sm px-2 content-center border-b-1 border-gray-300 dark:border-gray-700"
|
||||
aria-lbabel="Filename">
|
||||
class="select-none flex-none text-sm px-2 content-center border-b-1 border-gray-300 dark:border-gray-700"
|
||||
aria-label="Filename">
|
||||
{{ . }}{{ if not $fm }}.{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ range $i, $lang := $langs }}
|
||||
{{ $isLast := eq (add $i 1) (len $langs) }}
|
||||
{{- end }}
|
||||
{{- range $i, $lang := $langs }}
|
||||
{{- $isLast := eq (add $i 1) (len $langs) }}
|
||||
<button
|
||||
x-on:click="$store.nav.userSettings.settings.configFileType = '{{ index $langs $i }}'"
|
||||
aria-label="{{ printf `Toggle %s` . }}"
|
||||
@@ -83,14 +94,14 @@
|
||||
border-r-1
|
||||
{{ end }} border-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 dark:border-gray-700 cursor-pointer relative min-w-0 flex-1 overflow-hidden text-sm no-underline text-center focus:z-10 overflow-x-auto"
|
||||
:class="$store.nav.userSettings.settings.configFileType === '{{ index $langs $i }}' ? 'border-b-0 bg-light dark:bg-dark' : 'border-b-1'">
|
||||
<span>
|
||||
<span class="select-none">
|
||||
{{ . }}
|
||||
</span>
|
||||
</button>
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
</nav>
|
||||
{{ if $code }}
|
||||
{{ range $i, $lang := $langs }}
|
||||
{{- if $code }}
|
||||
{{- range $i, $lang := $langs }}
|
||||
<div
|
||||
class="max-h-96 overflow-y-auto border-l-1 border-b-1 border-r-1 border-gray-300 dark:border-gray-700"
|
||||
x-ref="{{ $lang }}"
|
||||
@@ -102,8 +113,8 @@
|
||||
{{- $hCode = printf "%s\n%s\n%s" $placeHolder $hCode $placeHolder }}
|
||||
{{- end }}
|
||||
{{- $hCode = $hCode | replaceRE `\n+` "\n" }}
|
||||
{{ highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
|
||||
{{- highlight $hCode . "" | replaceRE $placeHolder (index $delimiters .) | safeHTML }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user