Skip to content

Commit d110a07

Browse files
authored
feat: add hugo/preview shortcode, a alias of hugo/shortcode-example (#66)
1 parent 944db1e commit d110a07

File tree

7 files changed

+41
-3
lines changed

7 files changed

+41
-3
lines changed

i18n/en.toml

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[hugo_preview_result]
2+
other = "Result"
3+
4+
[hugo_preview_source]
5+
other = "Source"
6+
17
[parameter_context]
28
other = "Context"
39

i18n/vi.toml

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[hugo_preview_result]
2+
other = "Result"
3+
4+
[hugo_preview_source]
5+
other = "Source"
6+
17
[parameter_context]
28
other = "Context"
39

i18n/zh-hans.toml

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[hugo_preview_result]
2+
other = "结果"
3+
4+
[hugo_preview_source]
5+
other = "源码"
6+
17
[parameter_context]
28
other = "上下文"
39

i18n/zh-hant.toml

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[hugo_preview_result]
2+
other = "結果"
3+
4+
[hugo_preview_source]
5+
other = "源碼"
6+
17
[parameter_context]
28
other = "上下文"
39

layouts/partials/hugo/preview.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- $source := trim .Source "\r\n" -}}
2+
<div class="hugo-preview">
3+
<div class="hugo-preview-source">
4+
<div class="hugo-preview-source-title" style="font-weight: bold; margin-bottom: .25rem;">
5+
{{- i18n "hugo_preview_source" | default "Source" -}}
6+
</div>
7+
{{- highlight $source "markdown" -}}
8+
</div>
9+
<div class="hugo-preview-result">
10+
<div class="hugo-preview-result-title" style="font-weight: bold; margin-bottom: .25rem;">
11+
{{- i18n "hugo_preview_result" | default "Result" -}}
12+
</div>
13+
{{- $source | .Page.RenderString }}
14+
</div>
15+
</div>

layouts/shortcodes/hugo/preview.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{- partial "hugo/preview" (dict "Source" .Inner "Page" .Page) }}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
{{- $inner := trim .Inner "\r\n" -}}
2-
{{- highlight $inner "markdown" -}}
3-
{{- $inner | .Page.RenderString }}
1+
{{- partial "hugo/preview" (dict "Source" .Inner "Page" .Page) }}

0 commit comments

Comments
 (0)