赛博房子装修计划(1)文章样式

东抄抄西抄抄

文字渐变、左中右对齐

参考

custom.scss添加

//文字颜色渐变
.colorfulfont {
    background: linear-gradient(to right, rgb(25, 221, 238), #ed4588); //第一个颜色代码是渐变起始色,第二个颜色代码是渐变结束色;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

使用

我挑的配色很好看吧!
我改成了黄绿色(再次)(再次)
但总之换行的话就加个空标签。

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

新建layouts/shortcodes/align.html

<p style="text-align:{{ index .Params 0 }}">{{ index .Params 1 | markdownify }}</p>

使用

文字居左

文字居中

文字居右

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

极乐迪斯科风格着色

其实就是html标签,插入md过程稍显复杂,先凑合用着。极乐迪24个技能汇总

效果:

故弄玄虚 [极难:失败] - 不幸的是,您的成就当中似乎没什么值得一提的。您应该求助于谎言了。

内陆帝国 [简单:成功] - 是时候面对源头了。不要害怕,因为宇宙的力量会支持你完成这次的超自然任务。

五感发达(视觉) [中等:成功] - 一群附近的海鸥被轰鸣的电台吓了一跳,惊慌飞起。

天人感应 - 抬头望向天空,冰冷的雨水从你的头发上滴落。

custom.scss添加:(为了同时适配light/dark mode对原作颜色进行了一些更改)

.disco-purple {
    color: #8266d1;
    font-weight: bold;
}

.disco-pink {
color: #c75372;
font-weight: bold;
}

.disco-grey {
    color: #a0a0a0
}

.disco-blue {
    color: #4ea7b7;
    font-weight: bold;
  }
  
.disco-yellow {
color: #c39f2d;
font-weight: bold;
}

使用:

<span class="disco-blue">故弄玄虚</span> <span class="disco-grey">[极难:失败]</span> - 不幸的是,您的成就当中似乎没什么值得一提的。您应该求助于谎言了。

<span class="disco-purple">内陆帝国</span> <span class="disco-grey">[简单:成功]</span> - 是时候面对源头了。不要害怕,因为宇宙的力量会支持你完成这次的超自然任务。

<span class="disco-yellow">五感发达(视觉)</span> <span class="disco-grey">[中等:成功]</span> - 一群附近的海鸥被轰鸣的电台吓了一跳,惊慌飞起。

<span class="disco-pink">天人感应</span> - 抬头望向天空,冰冷的雨水从你的头发上滴落。

Safari浏览器书签收录网站icon

  1. static/文件夹,添加一个exactly named apple-touch-icon.png 的文件

  2. layouts/partials/head/custom.html,添加

<link rel="apple-touch-icon" href="/apple-touch-icon.png">
  1. 清除Safari中关于网站的cache

  2. 添加书签到启动页

聊天气泡

参考:Yelle - hugo stack 主题美化

效果:

John Doe   2025-04-12 14:30
这是左边的消息内容。
2025-04-12 14:45   Alice
这是右边的消息内容,测试长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长度。

新建layouts/shortcodes/chat.html

  {{ if eq (.Get "position") "left" }}
<div class="chat --other">
    <div class="chat__inner">
        <div class="chat__meta">{{ .Get "name" }}&nbsp;&nbsp;&nbsp;{{ .Get "timestamp" }}</div>
        <div class="chat__text">
            {{ .Inner }}
        </div>
    </div>
</div>
{{ else if eq (.Get "position") "right" }}
<div class="chat --self">
    <div class="chat__inner">
        <div class="chat__meta" style="text-align: right;">{{ .Get "timestamp" }}&nbsp;&nbsp;&nbsp;{{ .Get "name" }}</div>
        <div class="chat__text">
            {{ .Inner }}
        </div>
    </div>
</div>
{{ end }}

<style>
    .chat {
        margin: 10px;
        padding: 10px;
        position: relative;
        /* 添加相对定位,以便定位尖角箭头 */
        transition: transform 0.2s;
        /* 添加过渡效果,使放大平滑 */
        max-width: 80%;
        min-width: 15%;
    }
    
    .chat:hover {
        transform: scale(1.05);
    }
    
    .chat.--self {
        text-align: left;
        background-color: #ecf5ff;
        color: #000000;
        border-radius: 15px;
        width: fit-content;
        margin-left: auto;
    }
    /* 尖角箭头 */
    
    .chat.--self::before {
        content: "";
        position: absolute;
        right: -18px;
        /* 调整箭头位置 */
        bottom: 5px;
        transform: translateY(-50%);
        border-width: 15px 0 0 20px;
        border-style: solid;
        border-color: transparent transparent transparent #ecf5ff;
        /* 箭头颜色与对话框背景颜色一致 */
    }
    /* 左边对话框样式 */
    
    .chat.--other {
        text-align: left;
        background-color: #ffecec;
        color: #333;
        border-radius: 15px;
        position: relative;
        width: fit-content;
    }
    /* 左边对话框的尖角箭头 */
    
    .chat.--other::before {
        content: "";
        position: absolute;
        left: -18px;
        bottom: 5px;
        transform: translateY(-50%);
        border-width: 15px 20px 0 0;
        border-style: solid;
        border-color: transparent #ffecec transparent transparent;
    }
    /* 消息元数据样式(名称和时间戳) */
    
    .chat__meta {
        font-weight: bold;
        font-size: 0.67em;
        color: #707070;
        margin-bottom: 5px;
    }
    /* 消息文本样式 */
    
    .chat__text {
        font-size: 0.9em;
        margin-left: 10px;
        word-break: break-all;
    }
    
    [data-scheme="dark"] {
        .chat.--self {
            color: #fefefe;
            background-color: #253958;
        }
        .chat.--self::before {
            border-color: transparent transparent transparent #253958;
        }
        .chat.--other {
            color: #fefefe;
            background-color: #1a1a1a;
        }
        .chat.--other::before {
            border-color: transparent #1a1a1a transparent transparent;
        }
        .chat__meta {
            color: #b1b1b1;
        }
    }
</style>

固定代码块高度

参考:Hugo Stack 魔改美化

remove苹果相册自带的EXIF方向信息

从MacBook的相册拖拽到vscode的时候发现渲染之后图片方向会变。询问gpt以后发现是mac自带了方向信息来保证显示正确,但hugo并不识别这个信息。遂使用命令行把方向校正一下。在mac的相册里转一下再转回来也可以。

cd content/page/gallery
mogrify -auto-orient *.jpeg

notice

参考 Naive Koala_一些Hugo短代码

使用例

{\{< notice notice-warning >}}
你好。
{\{< /notice >}}

{\{< notice notice-info >}}
你好。
{\{< /notice >}}

{\{< notice notice-note >}}
你好。
{\{< /notice >}}

{\{< notice notice-tip >}}
你好。
{\{< /notice >}}

你好。

你好。

你好。

你好。

neodb

参考

使用

{\{< neodb "NeoDB 网址/豆瓣网址" >}\}

示例

9.5
《极乐迪斯科》是在一款奇幻都市设定下,极具开创性的硬汉风侦探类等距视角角色扮演游戏。 你将扮演一位落魄潦倒的中尉侦探,身处堕落的港口城市雷瓦科城,这里腐败横行,谋杀案一波未平一波又起,青少年们也整天只想着蹦迪。你在其中或是搜寻线索,审讯疑犯,或是探索这座广袤迷人的手绘城市,揭露它深埋的秘密。与此同时,局势逐渐恶化,城中冲突加剧,危机一触即发…… 极乐迪斯科原创的全套技能系统使你可以与游戏产生高维度的对话,谈论你内心深处的感受、疑惑、甚至记忆,逐渐养成专属于你的人设。强化理性思维系统?磨练社交能力?抑或是屈服于本能?只有你能决定成为怎样的警探。
game

美化滚动条

参考

custom.scss中添加

//美化滚动条
html{
    ::-webkit-scrollbar {
        width: 20px;
      }
      
      ::-webkit-scrollbar-track {
        background-color: transparent;
      }
      
      ::-webkit-scrollbar-thumb {
        background-color: #d6dee1;
        border-radius: 20px;
        border: 6px solid transparent;
        background-clip: content-box;
      }
      
      ::-webkit-scrollbar-thumb:hover {
        background-color: #a8bbbf;
      }
}

相关文章添加日期

参考

layouts/partials/article-list/tile.html中修改line 33 article details:

        <div class="article-details">
            <h2 class="article-title">
                {{- .context.Title -}}
            </h2>
            <!-- 自行增加的文章发布日期 -->
            <h2 class="article-time">
                <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
                    {{- .context.Date.Format (or .Site.Params.dateFormat.published "Jan 02, 2006") -}}
                </time>
            </h2>
        </div>
Reproduction in any form is strictly prohibited without permission.
发表了46篇文章 · 总计81.43k字
本博客已稳定运行
使用 Hugo 构建
主题 StackJimmy 设计