Hugo|在Stack主题上可行的短代码们

我不是短代码的生产者,我只是短代码的搬运工。

date-line
ic_fluent_keyboard_layout_float_24_regular Created with Sketch.

目录

Stack主题虽然自定义程度很高,但它并不像Fixit、Luna等主题那样自带很多短代码。

由于我对代码的掌握程度仅仅取决于我能不能在当中找到我认识的英语单词,Hugo官方文档里的自定义短代码教学对我来说基本等同于天书。

但这无法阻止我眼馋别人的各种花里胡哨小功能,我也成功在热心网友的分享下找到了不少可行的短代码,想着干脆做成合集,既方便后来的朋友抄作业,也能当作模板让我能一键查询自己搜集的短代码的写法。

这篇文章将会长期更新,如果以后我学会了更多的短代码,也会一并放在这里。

但其实我根本没打算在博客里放太多“技术性”的东西,天知道情况怎么会发展成这样。

作业大合集

按照本人的惯例,在展示我的搜集成果前应当感谢各位乐于分享的赛博友邻们。

  • 首先还是塔塔!短代码的部分主要参考了这两篇文章:Hugo|另一篇 Stack 主题装修记录Hugo|在文章中插入轮播图片,再次感谢塔塔!

  • 来写一些好玩的Hugo短代码吧 By吕楪,我最开始添加的短代码就是从她的博客里找到的,从那以后深刻体会到了短代码有多么好玩,遂开始努力收集……悄悄在她评论区留言也被温柔地回复了,好开心!

  • 短代码测试 By咖喱,是在互联网上赛博赶海时偶遇的博主,因为在她博客里看到了很想要的Shortcodes,从别的主题照搬文件复刻又失败了,只好厚着脸皮留言问她写法,过了几天居然在邮箱里收到了打包好的源码文件——!有点小小的感动,从我开始搭博客以来,遇到的都是非常非常好的朋友们!

  • 自定义Hugo Shortcodes简码 By一路向北,同样也是赛博赶海时偶遇到的博主,写的这篇教程简直比数学课本还简洁利落,好多都是我从没见过的新代码,值得收藏!

前置准备

没有什么特别的准备!但可以提前打开custom.scss文件和layouts/shortcodes文件夹。

文本样式类

重点标记

1.代码:

  • 新建mark.html,内容为:
1
<mark>{{ .Get "text" }}</mark>
  • custom.scss中添加:
1
2
3
4
//重点标记
mark{
    background: hsla(199, 64%, 63%, 0.696);
}

2.使用:好喜欢蓝色!

1
{< mark text="好喜欢蓝色!" >} //实际使用时应为双括号

文本缩写

1.代码:

  • 新建abbr.html,内容为:
1
<abbr title="{{ .Get "title" }}">{{ .Get "text" }}</abbr>

2.使用:这个短代码只在电脑端生效

1
{< abbr title="感觉很神秘" text="这个短代码只在电脑端生效" >} //实际使用时应为双括号

文本折叠

1.代码:

  • 新建detail.html,内容为:
1
2
3
4
<details>
    <summary>{{ (.Get 0) | markdownify }}</summary>
    {{ .Inner | markdownify }}
</details>

2.使用:

叠叠乐 实际使用时别忘了换成双括号!

1
2
3
{< detail "叠叠乐" >}
实际使用时别忘了换成双括号!
{< /detail >}

高斯模糊

1.代码:

  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
//文本高斯模糊
.blur {
    color: transparent;
    text-shadow:0px 0px 8px var(--card-text-color-main)
}
 
.blur:hover {
    color: transparent;
    text-shadow:0px 0px 0px var(--card-text-color-main)
   
}

2.使用:一些手动打码效果!
但总之换行的话就加个空标签。

1
<span class="blur">一些手动打码效果!<br>但总之换行的话就加个空标签。</span>

文本黑幕

1.代码:

  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
//文本黑幕效果
.shady {
    color:#000;
    font-weight: bold;
    box-shadow: 0px -20px 0px rgba(0,0,0,1) inset; 
    transition: all 0.3s ease;
}
.shady:hover{
   font-weight: bold;
    color:#FFF;
    box-shadow: 0px -20px 0px rgba(0,0,0,1) inset; 
}

2.使用:数据删除!数据删除!
但总之换行的话就加个空标签。

1
<span class="shady">数据删除!数据删除!<br>但总之换行的话就加个空标签。</span>

文字渐变

1.代码:

  • custom.scss中添加:
1
2
3
4
5
6
7
//文字颜色渐变
.colorfulfont {
    background: linear-gradient(to right, rgb(25, 221, 238), #ed4588); //第一个颜色代码是渐变起始色,第二个颜色代码是渐变结束色;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

2.使用:
我挑的配色很好看吧!
好喜欢蓝色(再次)(再次)
但总之换行的话就加个空标签。

1
<font class="colorfulfont"> 我挑的配色很好看吧!<br>好喜欢蓝色(再次)(再次)<br> 但总之换行的话就加个空标签。</font>

文本位置

1.代码:

  • 新建align.html,内容为:
1
<p style="text-align:{{ index .Params 0 }}">{{ index .Params 1 | markdownify }}</p>

2.使用:

文字居左

文字居中

文字居右

1
2
3
4
{< align left "文字居左" >}
{< align center "文字居中" >}
{< align right "文字居右" >}
//实际使用记得换成双括号。

摘录引用

1.代码:

  • 新建blockquote.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!-- reset scratch variables at the start -->
{{ $.Scratch.Set "bl_author" false }}
{{ $.Scratch.Set "bl_source" false }}
{{ $.Scratch.Set "bl_link" false }}
{{ $.Scratch.Set "bl_title" false }}

{{ if .IsNamedParams }}
  {{ $.Scratch.Set "bl_author" (.Get "author") }}
  {{ $.Scratch.Set "bl_source" (.Get "source") }}
  {{ $.Scratch.Set "bl_link" (.Get "link") }}
  {{ $.Scratch.Set "bl_title" (.Get "title") }}
{{ else }}
  <!-- for the positional version if any -->
{{ end }}

<!-- if title is not set explicitly then we need to beautify the link
     if length of link is more than 32 chars, we will cut it off by 32 and
     then drop everything after the last / if any and put it in into title -->

{{ with $.Scratch.Get "bl_title" }}
  <!-- do nothing -->
{{ else }}
  {{ with $.Scratch.Get "bl_link" }}    <!-- if link is given -->
    {{ range last 1 (split ($.Scratch.Get "bl_link" ) "://") }}  <!-- split by :// and then only take the items after it to remove protocol:// -->
      {{ $.Scratch.Set "title_without_protocol" . }}
    {{ end }}
    {{ range last 1 (split ($.Scratch.Get "title_without_protocol" ) "www.")  }} <!-- also remove the www. at the start if any. we are using a second split because all URLS may not start with it -->
      {{ $.Scratch.Set "title_without_protocol" . }}
    {{ end }}
    {{ $.Scratch.Set "bl_title" ($.Scratch.Get "title_without_protocol") }}

    <!-- if link is longer than 32 bytes we should trim it -->
    {{ if (gt (len ($.Scratch.Get "title_without_protocol") ) 32) }}
      {{ $title := (slicestr ($.Scratch.Get "title_without_protocol") 0 32) }}   <!-- get the first 32 characters of title_without_protocol -->
      {{ $split_by_fw_slash := split $title "/" }}   <!-- now split on / because we want to stop after the last forward slash -->
      {{ $count := (sub (len $split_by_fw_slash) 1) }}   <!-- we want everything but the last part so we adjust the count accordingly -->

      {{ $.Scratch.Set "tempstring" "" }}   <!-- temp variable to hold the concatinated string -->
      {{ range first $count $split_by_fw_slash  }}  <!-- loop through all parts except last and concat them (add / between halves) -->
        {{ $.Scratch.Set "tempstring" ( . | printf "%s%s/" ($.Scratch.Get "tempstring") | printf "%s" ) }}
      {{ end }}
      {{ $.Scratch.Set "bl_title" ( printf "%s..." ($.Scratch.Get "tempstring") | printf "%s" ) }}
    {{ end }}
  {{ end }}
{{ end }}

<blockquote>
  <p>{{ .Inner | markdownify }}</p>
  <footer style="text-align:right">
    <strong>{{ with $.Scratch.Get "bl_author" }}{{ . }}{{ end }}</strong>
    {{ with $.Scratch.Get "bl_source" }}
      <cite>{{ . }}</cite>
    {{ else }}
      {{ with $.Scratch.Get "bl_link" }}
        <cite>
          <a href="{{ . }}" title="{{ . }}" rel="noopener noreferrer">{{ $.Scratch.Get "bl_title" }}</a> <!-- can't have new lines here -->
        </cite>
      {{ else }}
        {{ with $.Scratch.Get "bl_title" }}
          <cite>
            {{ $.Scratch.Get "bl_title" }}</a>
          </cite>
        {{ end }}
      {{ end }}
    {{ end }}
  </footer>
</blockquote>

2.使用:

“年复一年,创作的冲动随年衰减,创作的能力逐渐消失——也许两者根本上是一回事,我们常把自己的写作冲动误认为自己的写作才能,自以为要写就意味着会写。”

1
2
3
{< blockquote author="作者" link="也可以不加啦" title="作品名" >}
这里写引用内容,实际使用记得换成双括号。
{< /blockquote >}

居中引用

1.代码:

  • 新建quote-center.html,内容为:
1
2
3
4
5
6
<blockquote class="quote-center">
  {{- $content := .Inner | markdownify -}} {{- if not (strings.HasPrefix $content "
  <p>") }} {{ printf `</p>
  <p>%s</p>
  ` $content | safeHTML }} {{- else }} {{- $content }} {{- end -}}
</blockquote>
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// 诗歌引用格式
blockquote.quote-center {
    position: relative;
    border-left: none;
    padding-left: 0;
    border-top: 0px solid var(--card-separator-color);
    border-bottom: 0px solid var(--card-separator-color);
    p {
      text-align: center !important;
      margin-top: 1.5em;
      margin-bottom: 1.5em;
    }
    &::before {
      position: absolute;
      left: 0;
      content: '“----';
      color: #6496c880;
      font-size: 3em;
      font-weight: normal;
      margin-top: -0.72em;
    }
    &::after {
      position: absolute;
      right: 0;
      content: '----”';
      color: #6496c880;
      font-size: 3em;
      font-weight: normal;
      margin-top: -1.42em;
    }
}

2.使用:

左右两边的符号可以自定义
使用需要双括号
换行需要空标签

1
2
3
{< quote-center >}
左右两边的符号可以自定义<br>使用需要双括号<br>换行需要空标签
{< /quote-center >}

键盘样式

1.代码:

  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
//键盘标签样式
kbd {
  margin: 0 .1em;
  padding: .1em .6em;
  font-size: .8em;
  color: #242729;
  background: #fff;
  border: 1px solid #adb3b9;
  border-radius: 3px;
  box-shadow: 0px 1px 0 rgba(12, 13, 14, 0.2), 0 0 0 2px #fff inset;
  white-space: nowrap;
  vertical-align: middle;
  font-family: SourceHanSerifSC;
}

2.使用:Ctrl+Alt+Del

1
<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Del</kbd>

评分样式

1.代码:

  • 新建rating.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<span class="star-rating">
    {{- if ge (.Get 0) (.Get 1) -}}
        {{- $star_outline := sub (int (.Get 0)) (int (.Get 1)) -}}
        {{- range $i, $sequence :=  (seq (.Get 1)) -}}
            <i class="star"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M381.2 150.3L524.9 171.5C536.8 173.2 546.8 181.6 550.6 193.1C554.4 204.7 551.3 217.3 542.7 225.9L438.5 328.1L463.1 474.7C465.1 486.7 460.2 498.9 450.2 506C440.3 513.1 427.2 514 416.5 508.3L288.1 439.8L159.8 508.3C149 514 135.9 513.1 126 506C116.1 498.9 111.1 486.7 113.2 474.7L137.8 328.1L33.58 225.9C24.97 217.3 21.91 204.7 25.69 193.1C29.46 181.6 39.43 173.2 51.42 171.5L195 150.3L259.4 17.97C264.7 6.954 275.9-.0391 288.1-.0391C300.4-.0391 311.6 6.954 316.9 17.97L381.2 150.3z"/></svg></i>
        {{- end -}}
        {{- range $i, $sequence :=  (seq $star_outline) -}}
            <i class="star-outline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M381.2 150.3L524.9 171.5C536.8 173.2 546.8 181.6 550.6 193.1C554.4 204.7 551.3 217.3 542.7 225.9L438.5 328.1L463.1 474.7C465.1 486.7 460.2 498.9 450.2 506C440.3 513.1 427.2 514 416.5 508.3L288.1 439.8L159.8 508.3C149 514 135.9 513.1 126 506C116.1 498.9 111.1 486.7 113.2 474.7L137.8 328.1L33.58 225.9C24.97 217.3 21.91 204.7 25.69 193.1C29.46 181.6 39.43 173.2 51.42 171.5L195 150.3L259.4 17.97C264.7 6.954 275.9-.0391 288.1-.0391C300.4-.0391 311.6 6.954 316.9 17.97L381.2 150.3z"/></svg></i>
        {{- end -}}
    {{- end -}}
</span>
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
//星星评级
i.star{
    color: hsl(61, 79%, 63%); /*星星的颜色*/
  }
  
  i.star-outline{
    color: hsl(211, 31%, 74%);/*空星星的颜色*/
  }
  
  i.star svg, i.star-outline svg{
    width: 20px;
    fill: currentColor;
}

2.使用:

1
{< rating 10 7 >} //总星数 实际星数;实际使用需要双括号;不可以打半星

卡片样式

1.代码:

  • 新建card.html,内容为:
1
2
3
4
5
6
{{- $raw := (markdownify .Inner | chomp) -}} {{- $block := findRE
    "(?is)^<(?:address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h(?:1|2|3|4|5|6)|header|hgroup|hr|li|main|nav|noscript|ol|output|p|pre|section|table|tfoot|ul|video)\\b"
    $raw 1 -}}
    <div class="mycard">
      <div class="content">{{- if or $block (not $raw) }}{{ $raw }}{{ else }} {{ $raw }} {{ end -}}</div>
    </div>
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
// 卡片样式
.mycard {
    padding: 10px 20px;
    margin: 20px 0;
    border-radius: 4px;
    word-break: break-all;
    background: #d2e5eb14;
    box-shadow: 0 6px 10px 0 #00000033;
    .content {
      line-height: 30px;
    }
}

2.使用:

可以在这里插入链接假装是卡片式链接。
好像不能插入图片?
换行需要空标签。实际使用需要双括号。

1
2
3
4
5
6
7
{< card >}
可以在这里插入链接假装是卡片式链接。
<br>
好像不能插入图片?
<br>
换行需要空标签。实际使用需要双括号。
{< /card >}

仿Github样式

1.代码:

  • 新建github.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<div class="github">
    <div class="logo">
        {{ replace $.Site.Data.SVG.repository "icon" "icon github-icon" | safeHTML }}
        <a class="name" href={{ .Get "link" }} target="_blank">{{ .Get "name" }}</a>
    </div>
    <div class="description">{{ .Get "description" }}</div>
    <div class="language">
        <span class="language-color" style="background-color: {{ .Get "color" }}"></span>
        <span class="language-name">{{ .Get "language" }}</span>
    </div>
</div>
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//github样式
.github {
    border: 1px solid var(--card-text-color-main);
    border-radius: 3px;
    margin: 0 auto;
    margin-bottom: 1em;
    padding: 1em;
    .github-icon {
      width: 1.2em;
      height: 1.2em;
      margin-right: 0.5em;
      margin-bottom: 0.2em;
      fill: var(--card-text-color-main);
      transition: all 0.5s;
    }
    .name {
      font-weight: bold;
      color: #2e97d9;
      text-decoration: underline;
      margin-left: 0.5em;
      position: relative;
      top: -5px; //加这个属性是因为我的图标和名称无法对齐,实际使用的时候要根据自己的网站修改
    }
    .description {
      margin-top: 0.5em;
      margin-bottom: 0.5em;
      color: var(--card-text-color-main);
      text-align: justify;
      font-size: 90%;
      transition: all 0.5s;
    }
    .language-color {
      position: relative;
      top: 1px;
      display: inline-block;
      width: 0.75em;
      height: 0.75em;
      border-radius: 50%;
    }
    .language-name {
      color: var(--card-text-color-main);
      font-size: 90%;
      margin-left: 0.5em;
      transition: all 0.5s;
    }
}  
  • data/SVG.toml中加入图标(给出的代码是Github自己的图标,我已经换成了自定义的):
1
repository = '<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 2.5C2 1.83696 2.26339 1.20107 2.73223 0.732233C3.20108 0.263392 3.83696 0 4.5 0L13.25 0C13.4489 0 13.6397 0.0790176 13.7803 0.21967C13.921 0.360322 14 0.551088 14 0.75V13.25C14 13.4489 13.921 13.6397 13.7803 13.7803C13.6397 13.921 13.4489 14 13.25 14H10.75C10.5511 14 10.3603 13.921 10.2197 13.7803C10.079 13.6397 10 13.4489 10 13.25C10 13.0511 10.079 12.8603 10.2197 12.7197C10.3603 12.579 10.5511 12.5 10.75 12.5H12.5V10.5H4.5C4.30308 10.5 4.11056 10.5582 3.94657 10.6672C3.78257 10.7762 3.65442 10.9312 3.57816 11.1128C3.50191 11.2943 3.48096 11.4943 3.51793 11.6878C3.5549 11.8812 3.64816 12.0594 3.786 12.2C3.92524 12.3422 4.0023 12.5338 4.00024 12.7328C3.99818 12.9318 3.91716 13.1218 3.775 13.261C3.63285 13.4002 3.4412 13.4773 3.24222 13.4752C3.04325 13.4732 2.85324 13.3922 2.714 13.25C2.25571 12.7829 1.99929 12.1544 2 11.5V2.5ZM12.5 1.5V9H4.5C4.144 9 3.806 9.074 3.5 9.208V2.5C3.5 2.23478 3.60536 1.98043 3.79289 1.79289C3.98043 1.60536 4.23478 1.5 4.5 1.5H12.5ZM5 12.25V15.5C5 15.5464 5.01293 15.5919 5.03734 15.6314C5.06175 15.6709 5.09667 15.7028 5.1382 15.7236C5.17972 15.7444 5.22621 15.7532 5.27245 15.749C5.31869 15.7448 5.36286 15.7279 5.4 15.7L6.85 14.613C6.89328 14.5805 6.94591 14.563 7 14.563C7.05409 14.563 7.10673 14.5805 7.15 14.613L8.6 15.7C8.63714 15.7279 8.68131 15.7448 8.72755 15.749C8.77379 15.7532 8.82028 15.7444 8.8618 15.7236C8.90333 15.7028 8.93826 15.6709 8.96266 15.6314C8.98707 15.5919 9 15.5464 9 15.5V12.25C9 12.1837 8.97366 12.1201 8.92678 12.0732C8.87989 12.0263 8.81631 12 8.75 12H5.25C5.1837 12 5.12011 12.0263 5.07322 12.0732C5.02634 12.1201 5 12.1837 5 12.25Z"/></svg>'

2.使用:这样是不是就能伪装成卡片式链接啦!

不知道说点什么了,我好想吃麦当劳,你看到这里想吃麦当劳了吗?好想用薯条蘸冰淇淋吃呀!冬天到了,感觉寿喜锅和老鸭汤也不错,我也很久没吃烤肉了,呜……
Blog

1
2
3
4
5
6
7
{< github
    name="链接标题"
    link="https://链接本体"
    description="链接内容描述"
    color="#小圆点颜色"
    language="可以当标签用?"//实际使用需要双括号
>}

标签块样式

1.代码:

  • 新建notice.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
<!-- 文件位置:~/layouts/shortcodes/notice.html -->

<!--https://github.com/martignoni/hugo-notice-->
{{- $noticeType := .Get 0 -}}

{{- $raw := (markdownify .Inner | chomp) -}}

{{- $block := findRE "(?is)^<(?:address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h(?:1|2|3|4|5|6)|header|hgroup|hr|li|main|nav|noscript|ol|output|p|pre|section|table|tfoot|ul|video)\\b" $raw 1 -}}

{{ $icon := (replace (index $.Site.Data.SVG $noticeType) "icon" "icon notice-icon") }}
<div class="notice {{ $noticeType }}" {{ if len .Params | eq 2 }} id="{{ .Get 1 }}" {{ end }}>
    <div class="notice-title">{{ $icon | safeHTML }}</div>
    {{- if or $block (not $raw) }}{{ $raw }}{{ else }}<p>{{ $raw }}</p>{{ end -}}
</div>
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//增加notice短代码
.notice {
  position:relative;
  padding: 1em 1em 1em 2.5em;
  margin-bottom: 1em;
  border-radius: 4px;
  p:last-child {
      margin-bottom: 0;
  }
  .notice-title {
      position: absolute;
      left: 0.8em;
      .notice-icon {
          width: 1.2em;
          height: 1.2em;
      }
  }
  &.notice-warning {
      background: hsla(0, 65%, 65%, 0.15);
      border-left: 5px solid hsl(0, 65%, 65%);
      .notice-title {
          color: hsl(0, 65%, 65%);
      }
  }
  &.notice-info {
      background: hsla(30, 80%, 70%, 0.15);
      border-left: 5px solid hsl(30, 80%, 70%);
      .notice-title {
          color: hsl(30, 80%, 70%);
      }
  }
  &.notice-note {
      background: hsla(200, 65%, 65%, 0.15);
      border-left: 5px solid hsl(200, 65%, 65%);
      .notice-title {
          color: hsl(200, 65%, 65%);
      }
  }
  &.notice-tip {
      background: hsla(140, 65%, 65%, 0.15);
      border-left: 5px solid hsl(140, 65%, 65%);
      .notice-title {
          color: hsl(140, 65%, 65%);
      }
  }
}

[data-theme="dark"] .notice {
  &.notice-warning {
      background: hsla(0, 25%, 35%, 0.15);
      border-left: 5px solid hsl(0, 25%, 35%);
      .notice-title {
          color: rgba(224, 108, 108, 0.5);
      }
  }
  &.notice-info {
      background: hsla(30, 25%, 35%, 0.15);
      border-left: 5px solid hsl(30, 25%, 35%);
      .notice-title {
          color: rgba(240, 178, 117, 0.5);
      }
  }
  &.notice-note {
      background: hsla(200, 25%, 35%, 0.15);
      border-left: 5px solid hsl(200, 25%, 35%);
      .notice-title {
          color: rgba(108, 185, 224, 0.5);
      }
  }
  &.notice-tip {
      background: hsla(140, 25%, 35%, 0.15);
      border-left: 5px solid hsl(140, 25%, 35%);
      .notice-title {
          color: rgba(108, 224, 147, 0.5);
      }
  }
}
  • data/SVG.toml中添加:
1
2
3
4
5
# Notice Icon
notice-warning = '<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 576 512" fill="hsl(0, 65%, 65%)"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zM124 296c-6.6.0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h264c6.6.0 12 5.4 12 12v56c0 6.6-5.4 12-12 12H124z"/></svg>'
notice-info = '<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 512 512" fill="hsl(30, 80%, 70%)"><path d="M256 8a248 248 0 100 496 248 248 0 000-496zm0 110a42 42 0 110 84 42 42 0 010-84zm56 254c0 7-5 12-12 12h-88c-7 0-12-5-12-12v-24c0-7 5-12 12-12h12v-64h-12c-7 0-12-5-12-12v-24c0-7 5-12 12-12h64c7 0 12 5 12 12v100h12c7 0 12 5 12 12v24z"/></svg>'
notice-note = '<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 512 512" fill="hsl(200, 65%, 65%)"><path d="M504 256a248 248 0 11-496 0 248 248 0 01496 0zm-248 50a46 46 0 100 92 46 46 0 000-92zm-44-165l8 136c0 6 5 11 12 11h48c7 0 12-5 12-11l8-136c0-7-5-13-12-13h-64c-7 0-12 6-12 13z"/></svg>'
notice-tip = '<svg xmlns="http://www.w3.org/2000/svg" class="icon" viewBox="0 0 512 512" fill="hsl(140, 65%, 65%)"><path d="M504 256a248 248 0 11-496 0 248 248 0 01496 0zM227 387l184-184c7-6 7-16 0-22l-22-23c-7-6-17-6-23 0L216 308l-70-70c-6-6-16-6-23 0l-22 23c-7 6-7 16 0 22l104 104c6 7 16 7 22 0z"/></svg>'

2.使用:

Warning:就像打开浏览器的开发者工具发现网站在报错。

info:咦,这是什么,点开看看!咦,这是什么,点开看看!咦,这是什么,点开看看!

note:可以标注一下,但是没必要。

tip:在示例里胡说八道会使观看者会心一笑。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{< notice notice-warning >}
Warning:需要双括号。
{< /notice >}

{< notice notice-info >}
info:这是一条信息。
{< /notice >}

{< notice notice-note >}
note:可以标注一下,但是没必要。
{< /notice >}

{< notice notice-tip >}
tip:在示例里胡说八道会使观看者会心一笑。
{< /notice >}

对话框

1.代码:

  • 新建message.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<link rel="stylesheet" href="/css/message.css" />

<div class="message {{if eq (.Get "from") "self"}}--self{{end}}">
    <div class="message__inner">
        {{if ne (.Get "accountID") ""}}
        <img class="avatar" src="https://unavatar.io/{{.Get "accountID"}}" width="24" height="24">
        {{else}}
        <img class="avatar" src="" width="24" height="24" style="visibility:hidden;">
        {{end}}
        <div class="message__text">
            <hstack class="message__meta">{{.Get "name"}} <spacer></spacer> {{.Get "timestamp"}}</hstack>
            {{.Inner}}

            {{if ne (.Get "images") ""}}
            <div class="grid-container">
                {{range split (.Get "images") ","}}
                <div class="grid-item">
                    <img class="message__img" src="{{.}}" alt="Image">
                </div>
                {{end}}
            </div>
            {{end}}
        </div>
    </div>
</div>
  • custom.scss中添加:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//对话框
.message {
  font-size: 16px;
  width: 80%;
  margin: 1rem 0;
  text-align: right;
}

.message.--self .message__text {
  background-color: var(--card-background);
  border: 1px solid #b7d8d865;
}

.dark .message.--self .message__text {
  background-color: var(--card-background);
  border: 1px solid #b7dddd15;
  }

.message.--self .message__text {
  text-align: left;
}

.message.--self .message__meta {
  text-align: right;
}


.message:not(.--self) {
  text-align: left;
}

.message__inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  align-items: flex-end;
}

.message__inner img {
  order: 1;
}

.message:not(.--self) .message__inner {
  justify-content: flex-start;
}

.message:not(.--self) .message__inner img {
  order: 0;
}

.message__text {
  margin-left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-right: 8px;
  --list-opacity: 1;
  background-color: var(--card-background);
}

.dark .message__text {
  border: 1px solid var(--border);
  background: var(--card-background);
}

.message__meta {
  color: #888;
  font-size: 0.8em;
}

.message.--self {
  margin-left: auto;
}

.message:not(.--self) {
  margin-right: auto;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 10px;
}

.grid-item {
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  position: relative;
}

.grid-item .message__img {
  object-fit: cover;
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.fullsize {
  object-fit: contain;
  max-width: 100%;
  max-height: 100%;
}

img.avatar{
  position: relative;
  width: 24px;
  height: 24px;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(105, 105, 105, 0.1);
  flex-shrink: 0;
  margin:unset !important;
}

img.message__img.medium-zoom-image.medium-zoom-image--opened {
  object-fit: contain;
  position: absolute;
  width: 100%;
  height: 100%;
  border: unset;
  box-shadow: unset;
}

img.message__img {
  margin: unset !important;
}

/* 定义手机端样式 */
@media screen and (max-width: 768px) {
  .message {
      width: 90%;
  }
}

2.使用:

鹤辞 2023-8-23 谢谢你教我写代码!
ChatGPT 2023-08-23 不客气!如果你还有任何其他问题,随时都可以问我。
祝你编写出漂亮的网页样式!
1
2
3
{< message from="self" accountID="twitter/昵称" images="图片链接" timestamp="自定义时间" name="name" >} 这里是自定义的信息内容。 {< /message >}  //从右边发出

{< message accountID="twitter/昵称" images="图片链接" timestamp="自定义时间" name="name" >} //从左边发出

时间轴

1.代码:

  • 新建timeline.html,内容为:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{{- $date := .Get "date" -}} {{- $title := .Get "title" -}} {{- $description := .Get "description" -}} {{- $tags := .Get "tags" -}}

<div class="timeline__row">
    <div class="timeline__time">
        <div class="timeline__time">{{ $date }}</div>
        <div class="timeline__split-line"></div>
    </div>
    <div class="timeline__content">
        <div class="timeline__tags">
            {{- with split $tags ", " -}} {{- range . }}{{- if eq . "样式" }}
            <span class="timeline__tag timeline__tag-style">{{ . }}</span> {{- else if eq . "文章" }}
            <span class="timeline__tag timeline__tag-article">{{ . }}</span> {{- else if eq . "页面" }}
            <span class="timeline__tag timeline__tag-page">{{ . }}</span> {{- else }}
            <span class="timeline__tag">{{ . }}</span> {{- end }} {{- end }} {{- end }}
        </div>
            <div class="timeline__title">{{ $title }}</div>
        <div class="timeline__description">
            {{ $description }}
        </div>
    </div>
</div>

<style>
    .timeline {
        display: flex;
        flex-direction: column;
    }
    
    .timeline__row {
        display: flex;
        padding-left: 4%;
        height: 90px;
    }
    
    .timeline__time {
        flex: 0 0 110px;
        color: #5d5d5d;
        font-size: 17px;
        text-transform: uppercase;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.5rem 0;
    }
    
    .timeline__time-text {
        margin: 0;
    }
    
    .timeline__split-line {
        position: absolute;
        top: 0.5rem;
        right: -20px;
        height: 100%;
        width: 2px;
        background-color: #84c4e240;
        z-index: 0;
    }
    
    .timeline__split-line:before {
        content: "";
        position: absolute;
        top: 24%;
        right: -4px;
        transform: translateY(-50%);
        width: 10px;
        height: 10px;
        background-color: #c9e5f2;
        box-shadow: 0 0 0 4px var(--theme);
        border-radius: 50%;
        border: 0px solid #84c4e2;
        z-index: -1;
    }
    
    .timeline__content {
        flex: 1;
        margin-left: 4.5rem;
        padding: 0.5rem 0 1.2rem 0;
    }
    
    .timeline__title {
        margin: 0;
        margin-bottom: 2px;
        padding-top: 3px;
        margin-left: 0.5rem;
        color: var(--content);
        font-family: var(--font-family-teshu);
        font-size: 19px;
        font-weight: 600;
        width: fit-content;
        display: inline-block;
        vertical-align: middle;
        /* 垂直居中对齐 */
    }
    
    .timeline__tags {
        display: inline-block;
        padding: 0;
        margin-left: 0.3rem;
        align-items: center;
        gap: 0.3rem;
    }
    
    .timeline__tag {
        display: inline-block;
        color: var(--secondary);
        background-color: #84c4e230;
        border: 1.5px solid #84c4e230;
        border-radius: 999px;
        padding: 0rem 0.5rem;
        font-size: 12px;
        white-space: nowrap;
        line-height: 1.4rem;
        opacity: 0.8;
        vertical-align: middle;
        /* 垂直居中对齐 */
    }
    
    .timeline__description {
        font-size: 15px;
        line-height: 1.6;
        color: #5d5d5d;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0.5rem 0 0.4rem 1.5rem;
        /* 添加 1.5rem 的左侧内边距 */
    }
    /* 为类名为 "timeline__tag-style" 的标签定义颜色 */
    
    .timeline__tag-style {
        background-color: #c581da;
        /* 替换为你希望的颜色 */
        border-color: #c581da;
        /* 与背景色相同或不同,根据需要自定义 */
        color: #FFFFFF;
        /* 根据需要选择文本颜色 */
    }
    /* 为类名为 "timeline__tag-article" 的标签定义颜色 */
    
    .timeline__tag-article {
        background-color: #92d392;
        /* 替换为你希望的颜色 */
        border-color: #92d392;
        /* 与背景色相同或不同,根据需要自定义 */
        color: #000000;
        /* 根据需要选择文本颜色 */
    }
    /* 为类名为 "timeline__tag-page" 的标签定义颜色 */
    
    .timeline__tag-page {
        background-color: #707070;
        /* 替换为你希望的颜色 */
        border-color: #707070;
        /* 与背景色相同或不同,根据需要自定义 */
        color: #FFFFFF;
        /* 根据需要选择文本颜色 */
    }
    
    @media screen and (max-width: 768px) {
        .timeline__time {
            font-size: 14px;
            /* 在小屏幕上使用较小的字体大小 */
        }
        .timeline__title {
            font-size: 16px;
            /* 在小屏幕上使用较小的字体大小 */
        }
        .timeline__description {
            font-size: 14px;
            /* 在小屏幕上使用较小的字体大小 */
        }
    }
</style>

2.使用:

2023
示例
时间轴
一段介绍。
2024
示例
时间轴
一段介绍。
1
{< timeline date="" title="" description="" tags=""  >}

插入外链类

图片轮播

1.代码:

  • 新建imgloop.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{{ if .Site.Params.enableimgloop }}
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/css/swiper.min.css">
    <!-- Swiper -->
    <div class="swiper-container">
        <div class="swiper-wrapper">
            {{$itItems := split (.Get 0) ","}}
            {{range $itItems }}
            <div class="swiper-slide">
                <img src="{{.}}" alt="">
            </div>
            {{end}}
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/js/swiper.min.js"></script>
     <!-- Initialize Swiper -->
     <script>
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true,
        //自动调节高度
        autoHeight: true,
        //键盘左右方向键控制
        keyboardControl : true,
        //鼠标滑轮控制
        mousewheelControl : true,
        //自动切换
        //autoplay : 5000,
        //懒加载
        lazyLoading : true,
		lazyLoadingInPrevNext : true,
		//无限循环
		loop : true,
        });
        </script>
{{ end }}
  • custom.scss中添加:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
//图片轮播
.swiper-container {
    max-width: 820px;
    margin: 2em auto;
}
.swiper-slide {
    text-align: center;
    font-size: 18px;
    background-color: #fff;
    /* Center slide text vertically */
    display: flex;
    justify-content: center;
    align-items: center;
    img {
        margin: 0 !important;
    }
}
  • config.yaml找到params:,添加enableimgloop: true

2.使用:

1
{< imgloop "1.jpg,2.jpg,3.jpg" >} //实际使用替换成双括号。

瀑布流相册

1.代码:

  • 新建gallery.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{{ $baseURL := .Site.BaseURL }}
{{- with (.Get 0) -}}
{{- $files := readDir (print "/static/" .) }}
<div class="gallery-photos">
  {{- range (sort $files "Name" "asc") -}}
    {{- if ( .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp|webp|avif|jxl)") }}
    {{- $linkURL := print $baseURL "/" ($.Get 0) "/" .Name | absURL }}
    <div class="gallery-photo">
      <img class="photo-img" loading='lazy' decoding="async" src="{{  $linkURL  }}" alt="{{ .Name }}" />
      <span class="photo-title">{{ .Name | replaceRE "\\..*" ""}}</span>
    </div>
    {{- end }}
  {{- end }}
</div>
{{- end }}
  • 在layouts/partials/footer/custom.html中插入:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!-- 瀑布流相册 -->
<script src="https://immmmm.com/waterfall.min.js"></script>
<script src="https://immmmm.com/imgStatus.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
  //外链 gallery 标签相册瀑布流
  var photosAll = document.getElementsByTagName('gallery') || '';
  if(photosAll){
    for(var i=0;i < photosAll.length;i++){
      photosAll[i].innerHTML = '<div class="gallery-photos">'+photosAll[i].innerHTML+'</div>'
      var photosIMG = photosAll[i].getElementsByTagName('img')
      for(var j=0;j < photosIMG.length;j++){
        wrap(photosIMG[j], document.createElement('div'));
      }
    }
  }
  function wrap(el, wrapper) {
    wrapper.className = "gallery-photo";
    el.parentNode.insertBefore(wrapper, el);
    wrapper.appendChild(el);
  }
  //相册瀑布流
  let galleryPhotos = document.querySelectorAll('.gallery-photos') || ''
  if(galleryPhotos){
    imgStatus.watch('.gallery-photo img', function(imgs) {
      if(imgs.isDone()){
        for(var i=0;i < galleryPhotos.length;i++){
          waterfall(galleryPhotos[i]);
          let pagePhoto = galleryPhotos[i].querySelectorAll('.gallery-photo');
          for(var j=0;j < pagePhoto.length;j++){pagePhoto[j].className += " visible"};
        }
      }
    });
    window.addEventListener('resize', function () {
      for(var i=0;i < galleryPhotos.length;i++){
        waterfall(galleryPhotos[i]);
      }
    });
  }
});
</script>
  • 在/layouts/partials/head/custom.html中插入:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<style>
  .gallery-photos{width:100%;break-inside: avoid;margin-bottom: 10px;}
  .gallery-photo{width:33.3%;position: relative;padding:0px 4px 0px 4px;visibility: hidden;overflow: hidden;}
  .gallery-photo.visible{visibility: visible;}
  .gallery-photo img{width: 100%;height: 100%;object-fit: cover;border-radius: 5px;box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);}
  @media screen and (min-width: 1200x) {
    .gallery-photo{
    width: 100%;
    columns: 3;
    column-gap: 20px;
    }
  }
  @media screen and (min-width: 860px) and (max-width: 1323.98px) {
    .gallery-photo{    
    width: 100%;
    columns: 2;
    column-gap: 20px;}
  }
  @media screen and (max-width: 860px) {
    .gallery-photo{    
    width: 100%;
    columns: 1;}
  }
  @media (max-width: 767.98px){
    .photo-time{display: none;}
  }
</style>

2.使用:

1
2
3
4
5
6
7
<gallery>![](1.jpg)![](2.jpg)![](3.jpg)</gallery> // markdown图片

<gallery>// 外链图片
    <img src="https://xxxxx.jpg">
    <img src="https://xxxxx.jpg">
    <img src="https://xxxxx.jpg">
</gallery>

多图排版

1.代码:

  • custom.scss中添加:
1
2
3
4
5
6
7
.post-content p:has(> img:nth-child(2)){column-count:2;column-gap:8px;margin:6px 0;}
.post-content p:has(> img:nth-child(3)){column-count:3;}
.post-content p:has(> img:nth-child(4)){column-count:4;}
.post-content p:has(> img:nth-child(5)){column-count:5;}
.post-content p:has(> img:nth-child(6)){column-count:4;}
.post-content p:has(> img:nth-child(2)) img{display:inherit;}
.post-content p:has(> img:nth-child(6)) img{margin-bottom:8px;}

2.使用:

1 2 3

1 2

1
2
3
4
5
6
![1](1.jpg)
![2](2.jpg)
![3](3.jpg)

![1](1.jpg)
![2](2.jpg)

PDF/PPT插入

1.代码:

  • 新建pdf.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<div class="pdf" style="
    padding-bottom: 66%;
    position: relative;
    display: block;
    width: 100%;
    border-bottom: 5px solid;
">
    <iframe
        width="100%"
        height="100%"
        src="{{ .Get "src" }}"
        frameborder="0"
        allowfullscreen=""
        style="
            position: absolute;
            top: 0;
            left: 0" >
    </iframe>
</div>

2.使用:在手机端上好像看不见,不过在电脑上浏览效果还不错!

1
{< pdf src="这里放pdf链接,本地文件当然也可以!跟md文件放在一个文件夹里就行。使用的时候请换成双括号。" >}

网易云音乐

1.代码:

  • 新建netease.html,内容为:
1
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=100% height=86 src="//music.163.com/outchain/player?type=2&id={{ index .Params 0 }}&auto={{ index .Params 1 }}&height=66"></iframe>

2.使用:

1
{< netease 557578993 0 >} //歌曲的id;是否自动播放(1为自动播放,0为手动播放)

Spotify

1.代码:

  • 新建spotify.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!--
Parameters:
    type - (Required) album / track / playlist / artist
    id - (Required) Target ID
    width - (Optional) width
    height - (Optional) height
-->

{{ if .IsNamedParams }}
<iframe src="https://open.spotify.com/embed/{{ .Get "type" }}/{{ .Get "id" }}"
    width="{{ default "100%" (.Get "width") }}"
    height="{{ default "380" (.Get "height") }}"
    frameborder="0"
    allowtransparency="true"
    allow="encrypted-media"></iframe>
{{ else }}
<iframe src="https://open.spotify.com/embed/{{ .Get 0 }}/{{ .Get 1 }}"
    width="{{ default "100%" (.Get 2) }}"
    height="{{ default "380" (.Get 3) }}"
    frameborder="0"
    allowtransparency="true"
    allow="encrypted-media"></iframe>
{{ end }}

2.使用:这是一个spotify的音乐模块,但是在中国大陆无法直连访问。

1
{< spotify type="track" id="2D3gvohUyOfXIVX6Mvhqae" height="80px">} //双括号

哔哩哔哩

1.代码:

  • 新建bilibili.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{{ $vid := (.Get 0) }}
{{ $videopage := default 1 (.Get 1) }}
{{ $basicQuery := querify "page" $videopage "high_quality" 1 "as_wide" 1 }}
{{ $videoQuery := "" }}

{{ if strings.HasPrefix (lower $vid) "av" }}
    {{ $videoQuery = querify "aid" (strings.TrimPrefix "av" (lower $vid)) }}
{{ else if strings.HasPrefix (lower $vid) "bv" }}
    {{ $videoQuery = querify "bvid" $vid }}
{{ else }}
    <p>Bilibili 视频av号或BV号错误!请检查视频av号或BV号是否正确</p>
    <p>当前视频av或BV号:{{ $vid }},视频分P:{{ $videopage }}</p>
{{ end }}

<div class="video-wrapper">
    <iframe src="https://player.bilibili.com/player.html?{{ $basicQuery | safeURL }}&{{ $videoQuery | safeURL }}"
            scrolling="no"
            frameborder="no"
            framespacing="0"
            allowfullscreen="true"
    >
    </iframe>
</div>

2.使用:夹带一点私货,来看岚少!

1
{< bilibili BV1V7411d7iW 0 >} //BV号,分p数,0/1为是否自动播放;使用记得双括号

引用长毛象嘟文

1.代码:

  • 新建mastodon.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{{ .Page.Scratch.Set "include_mastodon" true }}
{{ $server := .Get "server" | default "站点名称" }}
{{ $user := .Get "user" | default "站点用户名" }}
{{ $width := .Get "width" | default "100%" }}
{{ $height := .Get "height" | default "auto"}}
{{ $status := .Get "status" | default "false" }}

{{ if eq ($status) "false" }}
{{ else }}
<iframe src= "https://{{ $server }}/@{{ $user }}/{{ $status }}/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="{{ $width }}" height="{{ $height }}" allowfullscreen="allowfullscreen"></iframe><script src="https://{{ $server }}/embed.js" async="async"></script>
{{ end }}

2.使用:

1
{< mastodon status="嘟文ID(链接中的数字串)" >}

引用NeoDB条目

1.代码:

  • 新建neodb.html,内容为:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{{ $dbUrl := .Get 0 }}
{{ $dbApiUrl := "https://neodb.social/api/" }}
{{ $dbType := "" }}

{{ if ( findRE `^.*neodb\.social\/.*` $dbUrl ) }}
    {{ $dbType = replaceRE `.*neodb.social\/(.*\/.*)` "$1" $dbUrl }}
{{ else }}
    {{ $dbType = $dbUrl }}
    {{ $dbApiUrl = "https://neodb.social/api/catalog/fetch?url=" }}
{{ end }}

{{ $dbFetch := getJSON $dbApiUrl $dbType }}

{{ if $dbFetch }}
    {{ $itemRating := 0 }}{{ with $dbFetch.rating }}{{ $itemRating = . }}{{ end }}
    <div class="db-card">
        <div class="db-card-subject">
            <div class="db-card-post"><img loading="lazy" decoding="async" referrerpolicy="no-referrer" src="{{ $dbFetch.cover_image_url }}"></div>
            <div class="db-card-content">
                <div class="db-card-title"><a href="{{ $dbUrl }}" class="cute" target="_blank" rel="noreferrer">{{ $dbFetch.title }}</a></div>
                <div class="rating"><span class="allstardark"><span class="allstarlight" style="width:{{mul 10 $itemRating }}%"></span></span><span class="rating_nums">{{ $itemRating }}</span></div>
                <div class="db-card-abstract">{{ $dbFetch.brief }}</div>
            </div>
            <div class="db-card-cate">{{ $dbFetch.category }}</div>
        </div>
    </div>
{{else}}
    <p style="text-align: center;"><small>远程获取内容失败,请检查 API 有效性。</small></p>
{{end}}
  • css样式:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
/* db-card -------- start*/
.db-card{margin:2.5rem 3rem;background:var(--card-background);border-radius: 7px;box-shadow: 0 6px 10px 0 #00000053;}
.db-card-subject{display: flex;align-items:flex-start;line-height:1.6;padding:12px;position:relative;}
.dark .db-card{background:var(--card-background);}
.db-card-content {flex:1 1 auto;}
.db-card-post {width: 100px;margin-right: 15px;display: flex;flex: 0 0 auto;}
.db-card-title {margin-bottom: 3px;font-size: 14px;color: var(--card-text-color-main);;}
.db-card-title a{text-decoration: none!important}
.db-card-abstract,.db-card-comment{font-size:13px;overflow: auto;max-height:10rem;color: var(--card-text-color-main);;}
.db-card-cate{position: absolute;top:0;right:0;background:#f99b01;padding:1px 8px;font-size:small;font-style:italic;border-radius:0 8px 0 8px;text-transform:capitalize;}
.db-card-post img{width: 100px!important;height: 150px!important;border-radius: 4px;-o-object-fit: cover;object-fit: cover;}
.rating{margin: 0 0 5px;font-size:13px;line-height: 1;display: flex;align-items: center;}
.rating .allstardark{position:relative;color: #f99b01;height: 16px;width: 80px;background-size: auto 100%;margin-right: 8px;background-repeat: repeat;background-image: url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiPjxwYXRoIGQ9Ik05MDguMSAzNTMuMWwtMjUzLjktMzYuOUw1NDAuNyA4Ni4xYy0zLjEtNi4zLTguMi0xMS40LTE0LjUtMTQuNS0xNS44LTcuOC0zNS0xLjMtNDIuOSAxNC41TDM2OS44IDMxNi4ybC0yNTMuOSAzNi45Yy03IDEtMTMuNCA0LjMtMTguMyA5LjMtMTIuMyAxMi43LTEyLjEgMzIuOS42IDQ1LjNsMTgzLjcgMTc5LjEtNDMuNCAyNTIuOWMtMS4yIDYuOS0uMSAxNC4xIDMuMiAyMC4zIDguMiAxNS42IDI3LjYgMjEuNyA0My4yIDEzLjRMNTEyIDc1NGwyMjcuMSAxMTkuNGM2LjIgMy4zIDEzLjQgNC40IDIwLjMgMy4yIDE3LjQtMyAyOS4xLTE5LjUgMjYuMS0zNi45bC00My40LTI1Mi45IDE4My43LTE3OS4xYzUtNC45IDguMy0xMS4zIDkuMy0xOC4zIDIuNy0xNy41LTkuNS0zMy43LTI3LTM2LjN6TTY2NC44IDU2MS42bDM2LjEgMjEwLjNMNTEyIDY3Mi43IDMyMy4xIDc3MmwzNi4xLTIxMC4zLTE1Mi44LTE0OUw0MTcuNiAzODIgNTEyIDE5MC43IDYwNi40IDM4MmwyMTEuMiAzMC43LTE1Mi44IDE0OC45eiIgZmlsbD0iI2Y5OWIwMSIvPjwvc3ZnPg==);
}
.rating .allstarlight{position: absolute;left: 0;color: #f99b01;height:16px;overflow: hidden;background-size: auto 100%;background-repeat: repeat;background-image: url(data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMzIiIGhlaWdodD0iMzIiPjxwYXRoIGQ9Ik05MDguMSAzNTMuMWwtMjUzLjktMzYuOUw1NDAuNyA4Ni4xYy0zLjEtNi4zLTguMi0xMS40LTE0LjUtMTQuNS0xNS44LTcuOC0zNS0xLjMtNDIuOSAxNC41TDM2OS44IDMxNi4ybC0yNTMuOSAzNi45Yy03IDEtMTMuNCA0LjMtMTguMyA5LjMtMTIuMyAxMi43LTEyLjEgMzIuOS42IDQ1LjNsMTgzLjcgMTc5LjEtNDMuNCAyNTIuOWMtMS4yIDYuOS0uMSAxNC4xIDMuMiAyMC4zIDguMiAxNS42IDI3LjYgMjEuNyA0My4yIDEzLjRMNTEyIDc1NGwyMjcuMSAxMTkuNGM2LjIgMy4zIDEzLjQgNC40IDIwLjMgMy4yIDE3LjQtMyAyOS4xLTE5LjUgMjYuMS0zNi45bC00My40LTI1Mi45IDE4My43LTE3OS4xYzUtNC45IDguMy0xMS4zIDkuMy0xOC4zIDIuNy0xNy41LTkuNS0zMy43LTI3LTM2LjN6IiBmaWxsPSIjZjk5YjAxIi8+PC9zdmc+);}
@media (max-width:550px) {
	.db-card{margin:0.8rem 1rem;}
	.db-card-comment{display: none;}
}
/* db-card -------- end */

2.使用:

7.9
进入社会工作至今的十年间,胡安焉走南闯北,辗转于广东、广西、云南、上海、北京等地,做过快递员、夜班拣货工人、便利店店员、保安、自行车店销售、服装店导购、加油站加油工……他将日常的点滴和工作的甘苦化作真诚的自述,记录了一个平凡人在生活中的辛劳、私心、温情、正气。 在物流公司夜间拣货的一年,给他留下了深刻的生理印记:“这份工作还会令人脾气变坏,因为长期熬夜以及过度劳累,人的情绪控制力会明显下降……我已经感到脑子不好使了,主要是反应变得迟钝,记忆力开始衰退。”在北京送快递的两年,他“把自己看作一个时薪30元的送货机器,一旦达不到额定产出值就恼羞成怒、气急败坏”…… 但他最终认识到,怀着怨恨的人生是不值得过的。这些在事后追忆中写成的工作经历,渗透着他看待生活和世界的态度与反思,旨在表达个人在有限的选择和局促的现实中,对生活意义的直面和肯定:生活中许多平凡隽永的时刻,要比现实困扰的方方面面对人生更具有决定意义。
book
1
{< neodb "https://neodb.social/book/5SJvkuHNGL4XhBddW2J4EJ(条目链接)" >} //实际使用请添加双括号

最后更新于 2023 年, 12 月 26 日。

Copyright since 2023 by 鹤辞, All rights reserved.
Built with Hugo
主题 StackJimmy 设计