mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-11 12:03:10 +00:00
51 lines
2.1 KiB
HTML
51 lines
2.1 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/example.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" "example" "args" .Params) }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments -->
|
|
{{- $id := .Get "id" | default "" -}}
|
|
{{- $class := .Get "class" | default "" -}}
|
|
{{- $lang := .Get "lang" | default "markdown" -}}
|
|
{{- $show_markup := .Get "show_markup" | default true -}}
|
|
{{- $show_preview := .Get "show_preview" | default true -}}
|
|
{{- $content := .InnerDeindent -}}
|
|
{{- if eq $lang "hugo" }}{{ $lang = "markdown" }}{{ end -}}
|
|
|
|
<!-- Main code -->
|
|
{{ if not $error }}
|
|
<div class="rounded border mb-3">
|
|
{{- if eq $show_preview true -}}
|
|
<div {{ with $id }}id="{{ . }}"{{ end }} class="rounded-top p-3 {{ with $class }} {{ . }}{{ end }}">
|
|
{{- $content | .Page.RenderString | safeHTML -}}
|
|
</div>
|
|
{{- end -}}
|
|
{{- if eq $show_markup true -}}
|
|
<div class="d-flex align-items-center ps-3 pe-3 py-1{{ if $show_preview }} border-top{{ else }} rounded-top{{ end }} border-bottom syntax-highlight">
|
|
<small class="font-monospace text-body text-uppercase">{{- $lang -}}</small>
|
|
</div>
|
|
<div class="rounded-bottom syntax-highlight border-none">
|
|
{{- highlight (trim $content "\r\n") $lang "" | safeHTML -}}
|
|
</div>
|
|
{{- end -}}
|
|
</div>
|
|
{{ end }}
|