首页 > 其他分享 >hugp-MemE关键美化

hugp-MemE关键美化

时间:2023-06-07 22:22:05浏览次数:41  
标签:MemE Get 33 aplayer color hugp background font 美化

配置front matter

使用vscode snippet快捷生成front matter
参考博客:vs-code-workflows-for-hugomarkdown-snippets-not-working-in-vscode
在使用了obsidian后,加入一些插件如quickadd等,优化了文章撰写,但是obsidian不能在网页端登陆,虽然多个平台都有部署安装包,此外仅支持md文件使我不能继续使用下去。
后来沉思一下现有写文章流程,缺点是什么,发现是不能生成front matter,故东找西找,甚至一度又回归到obsidian后,终于发现vscode的snippet,正好几乎完美符合我的需求(不能自动呈现所有tags)。
目前我的写作流程是:

  1. 语雀上写好文章后导出md
  2. 用pic-go插件pic-migrate转换语雀图片并生成新md文件
  3. 在vscode上加入front matter
  4. 在vscode上上传至github
{
	"hugo post template":{
		"scope": "markdown",  // Add comma separated ids of the languages where the snippet is applicable in the scope field.
        "prefix": "post",  // trigger the snippet
        "body": [  // expanded and inserted where trigger
            "---",
            "title: ${TM_FILENAME/(.*)\\..+$/$1/}",
            "date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND +0800",
			"lastmod: ",
            "summary: ",
            "slug: $2", // url: www.keepjolly.com/tags/:slug/
			"toc: ${3|true,false|}",
			"rightToc: ${4|false,true|}",
			"categories: ",
			"- ${5|tech,learn,algorithm,error,create,other,life|}",
			"tags: ",
			"- ${6|ComputerVision,C++,LeetCode,Blog,Others,Install|}",
			"original: true",
			"author: Rurouni",
			"website: www.keepjolly.com",
			"---"
        ]
    },
	"update time":{
		"scope": "markdown",
		"prefix": "update",
		"body": "$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND +0800"
	}
}

完整可支持的front-matter,貌似也可以定制,自行百度吧

配置搜索功能

参考博客:修改algolia的设置hugo添加algolia搜索支持

配置config.toml

# Algolia 的搜索索引
[outputFormats.Algolia]
    mediaType = "application/json"
    baseName = "algolia"
    isPlainText = true
    notAlternative = true
# 摘要的字数限制  此处用于algolia检索
summaryLength = 70

# Hugo 的输出控制
[outputs]
    page = ["HTML"]
    home = ["HTML", "SectionsAtom", "SectionsRSS", "SearchIndex", "Algolia"]
    section = ["HTML"]
    taxonomy = ["HTML"]
    term = ["HTML"]

# 菜单配置
[menu]
    ## 菜单栏
    [[menu.main]]  # 多加入一个搜索栏
        weight = 8
        identifier = "search"
        post = "search"

######################################
# Algolia search

# 说明:需要开启 `Algolia` 在Hugo 的输出控制,且需要每
#      次将生成的 algolia.json 文件上传到
#      Algolia

enableAlgoliaSearch = true

algoliaAppId = ""
algoliaApiKey = ""
algoliaIndexName = ""
# 说明:https://www.algolia.com/

algolia官网查找key

image.png
或者登录后访问网址,然后找到对应Application ID、ApiKey、IndexName,找不到可以自行在参考博客中查找。

覆盖index.algolia.json配置

然后在博客主目录/layouts下新建index.algolia.json来覆盖meme中的配置,此处内容参考dreamsafari的json
此处需多加一个参数summary,内容为content内容,或者$page.Summary(但是此处显示会无法转义字符,目前无法解决,以后应该也不会解决,等有缘人),否则会显示undefined

{{- range $i, $c := $chunked -}}
{{- $index = $index | append (dict "objectID" (print $page.File.UniqueID "_" $i) "order" $i "title" $page.Title "date" $page.Date "url" $page.Permalink "tags" $page.Params.tags "categories" $page.Params.Categories "summary" $c) -}}
{{- end -}}

修改algolia搜索配置

此处配置搜索选项,参考修改algolia的设置
image.png

自动上传algolia.json

详见github action处

配置about页及视频

视频

<video src="QmTz7jzWdGrTVKT7YwNwX9cEgfg4smNFHVxnaFDR82BrXt" poster="../images/Gypsy Heart.jpg" controls >
  如需下载:<a href="https://gateway.pinata.cloud/ipfs/QmTz7jzWdGrTVKT7YwNwX9cEgfg4smNFHVxnaFDR82BrXt">MP4</a>
</video>

config.toml
# 是否开启
enableVideoHost = true  # 相对路径获取图片,用于poster属性

# 视频外链地址
videoHostURL = "https://gateway.pinata.cloud/ipfs/"  # 用于src属性,使其链接干净
# !!必须src开头,否则无法识别到hash!!

为了使封面图poster与视频适配:
设置object-fit: 无效,被迫剪裁图片以适配视频。

音乐

如果想配置音乐

  1. 根目录下的layouts\shortcodes\创建music.html

该代码同时支持列表和单曲模式

<!-- 使用meting-js的方式  https://immmmm.com/hugo-shortcodes-music/ -->
<!-- require APlayer https://aplayer.js.org/#/zh-Hans/?id=%E5%85%A5%E9%97%A8 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css">
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
{{- if .IsNamedParams -}}

<div id="player"></div>

{{- if .Get "url" -}}
<script>
    const ap1 = new APlayer({
        container: document.getElementById('player'),
        lrcType: 3,
        audio: [{
            name: '{{ .Get `name` }}',
            artist: '{{ .Get `artist` }}',
            url: '{{ .Get `url` }}',
            cover: '{{ .Get `cover` }}',
            lrc: '{{ .Get `lrc` }}',
            theme: '#f44336'
        }]
    });
</script>
{{- else if .Get "auto" -}}
<script>
    const ap = new APlayer({
        container: document.getElementById('player'),
        mini: false,
        autoplay: false,
        theme: '#FADFA3',
        loop: 'all',
        order: 'random',
        preload: 'auto',
        volume: 0.7,
        mutex: true,
        listFolded: false,
        listMaxHeight: 90,
        lrcType: 3,
        audio: [
            {
                name: '{{ .Get `name1` }}',
                artist: '{{ .Get `artist1` }}',
                url: '{{ .Get `url1` }}',
                cover: '{{ .Get `cover1` }}',
                lrc: '{{ .Get `lrc1` }}',
                theme: '#f44336'
            },
            {
                name: '{{ .Get `name2` }}',
                artist: '{{ .Get `artist2` }}',
                url: '{{ .Get `url2` }}',
                cover: '{{ .Get `cover2` }}',
                lrc: '{{ .Get `lrc2` }}',
                theme: '#46718b'
            }
        ]
    });
</script>
{{- end -}}

{{- end -}}

  1. 在about/_index.md中修改代码
{{< music url="xxx.mp3" 
 name="Try" artist="Colbie Caillat" cover="../songs/Gypsy Heart song.jpg" lrc="xxx.lrc">}}
  1. 在assets\scss\custom_custom.scss中修改暗夜样式
// Aplayer
:root[data-theme="light"]{
    .aplayer-pic{
        background-color: #b7daff;
    }
}
:root[data-theme="dark"]{
    .aplayer {
        background: #212121
    }

     .aplayer.aplayer-withlist .aplayer-info {
        border-bottom-color: #5c5c5c
    }

     .aplayer.aplayer-fixed .aplayer-list {
        border-color: #5c5c5c
    }

     .aplayer .aplayer-body {
        background-color: #212121
    }

     .aplayer .aplayer-info {
        border-top-color: #212121
    }

     .aplayer .aplayer-info .aplayer-music .aplayer-title {
        color: #fff
    }

     .aplayer .aplayer-info .aplayer-music .aplayer-author {
        color: #fff
    }

     .aplayer .aplayer-info .aplayer-controller .aplayer-time {
        color: #eee
    }

     .aplayer .aplayer-info .aplayer-controller .aplayer-time .aplayer-icon path {
        fill: #eee
    }

     .aplayer .aplayer-list {
        background-color: #212121
    }

     .aplayer .aplayer-list::-webkit-scrollbar-thumb {
        background-color: #999
    }

     .aplayer .aplayer-list::-webkit-scrollbar-thumb:hover {
        background-color: #bbb
    }

     .aplayer .aplayer-list li {
        color: #fff;
        border-top-color: #666
    }

     .aplayer .aplayer-list li:hover {
        background: #4e4e4e
    }

     .aplayer .aplayer-list li.aplayer-list-light {
        background: #6c6c6c
    }

     .aplayer .aplayer-list li .aplayer-list-index {
        color: #ddd
    }

     .aplayer .aplayer-list li .aplayer-list-author {
        color: #ddd
    }

     .aplayer .aplayer-lrc {
        text-shadow: -1px -1px 0 #666
    }

     .aplayer .aplayer-lrc:before {
        background: -moz-linear-gradient(top, #212121 0%, rgba(33, 33, 33, 0) 100%);
        background: -webkit-linear-gradient(top, #212121 0%, rgba(33, 33, 33, 0) 100%);
        background: linear-gradient(to bottom, #212121 0%, rgba(33, 33, 33, 0) 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#212121', endColorstr='#00212121', GradientType=0)
    }

     .aplayer .aplayer-lrc:after {
        background: -moz-linear-gradient(top, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
        background: -webkit-linear-gradient(top, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
        background: linear-gradient(to bottom, rgba(33, 33, 33, 0) 0%, rgba(33, 33, 33, 0.8) 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00212121', endColorstr='#cc212121', GradientType=0)
    }

     .aplayer .aplayer-lrc p {
        color: #fff
    }

     .aplayer .aplayer-miniswitcher {
        background: #484848
    }

     .aplayer .aplayer-miniswitcher .aplayer-icon path {
        fill: #eee
    }
}

配置视频介绍文字

  1. _index.md
<h2 class="try">Try</h2>
<!-- <p style="text-align:center" class="colbie">Colbie Caillat</p> -->
<p style="text-align:center">
<em>
You don't have to try so hard<br>
You don't have to, give it all away<br>
You just have to get up, get up, get up, get up<br>
You don't have to change a single thing</em>
</p>
  1. config.toml
# 网络字体链接
fontsLink = "https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;700&family=Source+Code+Pro:ital,wght@0,400;0,700;1,400;1,700&family=Cinzel+Decorative:wght@700&display=swap"
  1. assets/scss/custom/_custom.scss
// about页
.try {   // io-oi.me
      margin-top: 50px;
      text-align: center;
      font-family: 'Cinzel Decorative', serif !important;
      background-image: linear-gradient(90deg, #f37055 0, #ef4e7b 40%, #f37055 45%, #a166ab 50%, #f37055 55%, #ef4e7b 60%, #f37055 100%);
      background-size: cover;
      background-clip: text;
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
     }
.colbie {
  text-align: center;
  font-family: 'Cinzel Decorative', serif !important;
  background-image: linear-gradient(90deg, #f37055 0, #ef4e7b 40%, #f37055 45%, #a166ab 50%, #f37055 55%, #ef4e7b 60%, #f37055 100%);
  background-size: cover;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}


// https://io-oi.me/tech/get-started-with-variable-fonts/
@font-face {
  font-family: 'Amstelvar';
  font-display: swap;
  src: url('#{$baseRelURL}/fonts/Amstelvar-Italic-VF.woff2') format('woff2-variations'),
    url('#{$baseRelURL}/fonts/Amstelvar-Italic-VF.woff2') format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-style: italic;
}


@font-face {
  font-family: 'Amstelvar';
  font-display: swap;
  src: url('#{$baseRelURL}/fonts/Amstelvar-Roman-VF.woff2') format('woff2-variations'),
    url('#{$baseRelURL}/fonts/Amstelvar-Roman-VF.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-style: normal;
}


body {
  font-family: 'Amstelvar', 'Noto Serif SC',  serif;
}


:root {
  --text-wdth: 90;
  --text-opsz: 40;
  --text-YTLC: 460;
}


body {
  font-variation-settings:
    'wdth' var(--text-wdth),
    'opsz' var(--text-opsz),
    'YTLC' var(--text-YTLC);
}


.post-title {
  font-family: 'glyph-correction', 'Amstelvar', 'Noto Serif SC', serif;
  font-variation-settings:
    'wght' 550,
    'opsz' 60,
    'YOPQ' 90;
}


.list-item-time {
  font-feature-settings: 'tnum';
}


blockquote.quote {
  position: relative;
  margin: 2em auto !important;
  padding-left: 3em;
  color: inherit;
  border: none;
  p {
    text-indent: 0 !important;
  }
  &::before {
    position: absolute;
    left: 0;
    content: '“';
    font-size: 3em;
    font-weight: bold;
    line-height: 1;
  }
  &.poetry {
    display: table;
    padding: 0;
    &::before {
      left: -1em;
    }
    p {
      margin: 0 0 1em;
    }
    p:last-child {
      margin: 0;
    }
  }
  &.en {
    p {
      line-height: 1.618;
      text-align: left;
      hyphens: auto;
      -webkit-hyphens: auto;
      -moz-hyphens: auto;
    }
  }
  &.italic {
    p {
      font-style: italic;
    }
  }
}


@media (max-width: $maxWidth) {
  blockquote.quote {
    &.poetry {
      padding-left: 3em;
      &::before {
        left: 0;
      }
      }
      }
      }

配置toc到页面右边

参考博客
原本想实现滚动动画的,技术力不够,等大佬

创建mytoc.html

<!-- 注意需要在页面的front-matter中toc:false并rightToc:true -->
{{ if (.Params.rightToc | default false ) }}
<div class="post-toc" id="post-toc">
  <aside>
    <header>
      <h4>文章の字数: {{ .WordCount }}</h4> 
    </header>
    {{ $emtLiPtrn := "(?s)<ul>\\s<li>\\s<ul>(.*)</li>\\s</ul>" }}
    {{ $rplcEmtLi := "<ul>$1" }}
      {{ .TableOfContents | replaceRE $emtLiPtrn $rplcEmtLi | safeHTML }}
      <!-- https://github.com/gohugoio/hugo/issues/1778#issuecomment-483880269 -->
      <!-- {{.TableOfContents}} -->
  </aside>
  <a href="#" id="toc-toggle"></a>
</div>

{{ end }}

创建single.html

{{ define "main" }}
    {{ partial "pages/post.html" . }}
<!--   	将主题的single复制后新加的内容 -->
    <div class = "toc-wrapper">  
        {{ partial "mytoc.html" . }}
    </div>
{{ end }}

修改_custom.scss样式

.post-toc {
  position: fixed;
  right: 5px;
  max-width: 40%;
  overflow: auto;
  top: 5%;
  width: 25vw;
  bottom: 30px
}

.toc-wrapper {
  ::-webkit-scrollbar {
    width: 6px;
    height: 8px;
  }

  ::-webkit-scrollbar-thumb {
    height: 40px;
    background-color: #eee;
    border-radius: 16px;

    &:hover {
      background-color: #ddd;
    }
  }
}
@media only screen and (max-width: 1224px) {
  .post-toc {
    display: none;
  }
} 

标签:MemE,Get,33,aplayer,color,hugp,background,font,美化
From: https://www.cnblogs.com/zds1366/p/17464760.html

相关文章

  • 【zsh使用技巧】Linux shell美化,ohmyzsh安装+Xshell美化,体验Mac命令行
    解决oh-my-zsh主题乱码问题解决RockyLinux下ohmyzsh按Tab键自动补全命令时重复字符且无法删除问题Solve:RemnantcharacterswhentabcompletingIseeduplicatetypedcharactersafterIcompleteacommand愿你美化半生,归来仍是默认一、背景厌倦了Linux单调的命令行,......
  • cpp: Memento Pattern
     /*****************************************************************//***\fileActorMemento.h*\brief备忘录模式MementoPattern亦称:快照、Snapshot、MementoC++14*2023年6月6日涂聚文GeovinDuVisualStudio2022edit.*\authorgeovindu*\da......
  • 记录6年时间3套easyui前端框架主题皮肤美化的ui设计历程
    沉寂了许久,是该发点东西了,要不然2023年都要过去一半了!第一次接触Easyui前端框架,还是在2016年的时候,有个美化easyui界面的需求,自己是设计师,前端知识也只会最基本的html和css样式,JS只能网上找例子来套用。于是就找前端的朋友一起合作,我设计系统界面的UI,然后前端根据设计,在easyui主题......
  • Git + msys2 + ohmyzsh 打造Win11美化终端及代码高亮
    1.下载最新版zshPackage:zsh-MSYS2Packages2.下载PeaZiphttps://peazip.github.io/解压zsh-5.9-2-x86_64.pkg.tar.zst文件全部放入安装的Git目录下。3.设置zsh为默认终端1.打开git-bash2.键入zsh3.vi~/.bashrc#LaunchZshif[-t1];thenexeczshfi4.......
  • 权限控制,美化admin,签发token逻辑,放在序列化类中写
    1权限控制#ACL(访问控制列表)的权限控制:(针对互联网用户的产品) 用户表idnamepassword1zhangsan123权限表iduser_id权限11评论权限21发抖音权限张三:[评论权限,发抖音权限]#R......
  • 几行代码教你美化excel
    数据统计我们可以很方便地用python计算,但是数据统计好后,呈现给领导或客户时,还是以excel为主,pandas直接生成的excel太丑,不符合福报人的品位,本文教大家一步步变美。01背景先看丑的,通常pandas一行代码就能生成excel,如图:df.to_excel(xlsx_path,header=False)01准备通常python读取ex......
  • 设计模式之备忘录(Memento)
    概述备忘录模式(MementoPattern),是行为型模式设计模式之一,该模式用于保存对象当前状态,并且在之后可以再次恢复到此状态。备忘录模式实现的方式需要保证被保存的对象状态不能被对象从外部访问,目的是为了保护被保存的这些对象状态的完整性以及内部实现不向外暴露,本篇博客,我们就来......
  • CSS:页面美化和布局控制和选择器
    CSS:页面美化和布局控制和选择器概念:CascadingStyleSheets层叠样式表层叠:多个样式可以作用在同一个html的元素上,同时生效好处:功能强大将内容展示和样式控制分离降低耦合度。解耦让分工协作更容易提高开发效率CSS的使用:CSS与html结合方式内联样式在标签内使用style属......
  • OneDelphi界面美化
    使用OneDelphi已经有一段时间了,中间件的功能很强大,主要特点:●oneDelphi由OneServer中间件,OneClient控件包组成,自由免费,全源码...●oneDelphi是一个MVC+传统DATASET双架构中间件...●oneFastClient是一个快速开发传统EXE的开发包。OneDelphi的官方QQ群:814696487主界面:优化UI......
  • [钻芒美化] 在线解析视频VIP播放器安装源码,集成最新全能视频接口引流必备
    本文转载自:[钻芒美化]在线解析视频VIP播放器安装源码,集成最新全能视频接口引流必备更多内容请访问钻芒博客:https://www.zuanmang.net声明源程序源自网络。版权非博主所有!钻芒二开美化版集成姬长信最新API接口。基于DASH优化的P2P流媒体视频播放,支持:腾讯,爱奇艺,优酷,乐视,......