mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-11 12:03:10 +00:00
65 lines
2.6 KiB
HTML
65 lines
2.6 KiB
HTML
<!--
|
|
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
|
|
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
|
|
Visit gethinode.com/license for more details.
|
|
|
|
This source code adapts the original embedded shortcode as maintained by the The Bootstrap Authors. It introduces
|
|
the following modifications:
|
|
- Added validation of shortcode arguments
|
|
- Modified the layout
|
|
|
|
The original source code is available on:
|
|
Source: https://github.com/twbs/bootstrap/blob/main/site/layouts/shortcodes/scss-docs.html
|
|
Copyright (c) 2011-2023 The Bootstrap Authors. Licensed under The MIT License (MIT).
|
|
-->
|
|
|
|
{{ $error := false -}}
|
|
|
|
<!-- Validate arguments -->
|
|
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "file" "args" .Params) }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments -->
|
|
{{- $basePath := .Site.Params.docs.basePath -}}
|
|
{{- $file := .Get "path" | default "" -}}
|
|
{{- if hasPrefix $file "./" -}}
|
|
{{- $file = path.Clean $file -}}
|
|
{{- else -}}
|
|
{{- $file = path.Join $basePath (path.Clean $file) -}}
|
|
{{- end -}}
|
|
|
|
{{- $extension := strings.TrimLeft "." (path.Ext $file) }}
|
|
{{- $lang := .Get "lang" | default $extension -}}
|
|
{{- $id := .Get "id" | default (printf "file-collapse-%d" .Ordinal) -}}
|
|
{{ $show := .Get "show" | default true -}}
|
|
{{ $full := .Get "full" | default true -}}
|
|
{{- $class := .Get "class" | default "" -}}
|
|
|
|
<!-- Main code -->
|
|
{{- if not $error -}}
|
|
{{- /* Force-check if the file exists */ -}}
|
|
{{ $tmp := os.Stat $file }}
|
|
{{- $content := readFile $file -}}
|
|
|
|
<ul class="nav nav-tabs{{ with $class }} {{ . }}{{ end }}">
|
|
<li class="nav-item">
|
|
<a class="nav-link active font-monospace"
|
|
href="#body-{{ $id }}"
|
|
aria-current="page"
|
|
data-bs-toggle="collapse"
|
|
data-bs-target=".multi-{{ $id }}"
|
|
aria-expanded="false"
|
|
aria-controls="body-{{ $id }} footer-{{ $id }}">
|
|
<small>{{ if $full }}{{ strings.TrimPrefix $basePath $file }}{{ else }}{{ path.Base $file }}{{ end }}</small>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
<div class="border-start border-end border-bottom mb-3">
|
|
<div class="collapse multi-{{ $id }}{{ if $show }} show{{ end }} syntax-highlight" id="body-{{ $id }}">
|
|
{{- highlight (trim $content "\r\n") $lang "" -}}
|
|
</div>
|
|
<div class="collapse multi-{{ $id }}{{ if not $show }} show{{ end }} p-3" id="footer-{{ $id }}"><i>...</i></div>
|
|
</div>
|
|
{{- end -}} |