Skip to content

Commit

Permalink
Feat: 在目录上面怎么自定义内容
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Dec 27, 2024
1 parent b4af1c5 commit 343f507
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 16 deletions.
57 changes: 57 additions & 0 deletions assets/css/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,63 @@
}
}

#toc-auto {
.follow-container {
display: flex;
align-items: center;
gap: 16px;
padding-bottom: 8px;
margin-bottom: 8px;
border-bottom: 1px solid $global-border-color;

[data-theme='dark'] & {
border-color: $global-border-color-dark;
}

.author-link {
display: flex;
align-items: center;
gap: 4px;
font-weight: 500;
color: $single-link-color;

[data-theme='dark'] & {
color: $single-link-color-dark;
}

&:active,
&:hover {
color: $single-link-hover-color;

[data-theme='dark'] & {
color: $single-link-hover-color-dark;
}
}

.author-avatar {
width: 34px;
border-radius: 50%;
border: 1px solid $global-border-color;

[data-theme='dark'] & {
border-color: $global-border-color-dark;
}
}
}
.follow-btn {
border: 1px solid #d1d9e0;
background-color: #f6f8fa;
border-radius: 6px;
padding: 4px 10px;

[data-theme='dark'] & {
border-color: #3d444d;
background-color: #2a313c;
}
}
}
}

[lang='en'] {
.collection-details .collection-summary .collection-name::before {
content: '';
Expand Down
6 changes: 6 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ disableThemeInject = false
"inject/cmpt-translate.html",
"inject/shortcode-caniuse.html",
]
postTocBefore = [
"custom/follow-me.html",
]
postTocAfter = []
postContentBefore = []
postContentAfter = []
postFooterBefore = []
postFooterAfter = []

Expand Down
4 changes: 4 additions & 0 deletions content/en/documentation/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ Next, taking the [component-projects] component as an example, we will introduce
assets = [
"inject/component-projects.html",
]
postTocBefore = []
postTocAfter = []
postContentBefore = []
postContentAfter = []
postFooterBefore = []
postFooterAfter = []
```
Expand Down
8 changes: 8 additions & 0 deletions content/en/references/blocks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ You can implement these blocks through `define`.
| `custom-footer` | Footer custom block | `layouts/partials/footer.html` |
| `custom-widgets` | Widgets custom block | `layouts/partials/widgets.html` |
| `custom-assets` | Assets custom block | `layouts/partials/assets.html` |
| `custom-post__toc:before` | Custom block before post toc | `layouts/posts/single.html` |
| `custom-post__toc:after` | Custom block after post toc | `layouts/posts/single.html` |
| `custom-post__content:before`| Custom block before post content| `layouts/posts/single.html` |
| `custom-post__content:after` | Custom block after post content | `layouts/posts/single.html` |
| `custom-post__footer:before` | Custom block before post footer | `layouts/posts/single.html` |
| `custom-post__footer:after` | Custom block after post footer | `layouts/posts/single.html` |

Expand All @@ -71,6 +75,10 @@ Custom partials must be stored in the `/layouts/partials/` directory.
footer = []
widgets = []
assets = []
postTocBefore = []
postTocAfter = []
postContentBefore = []
postContentAfter = []
postFooterBefore = []
postFooterAfter = []
```
Expand Down
4 changes: 4 additions & 0 deletions content/zh-cn/documentation/advanced/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ li[data-task='tip'] {
assets = [
"inject/component-projects.html",
]
postTocBefore = []
postTocAfter = []
postContentBefore = []
postContentAfter = []
postFooterBefore = []
postFooterAfter = []
```
Expand Down
34 changes: 21 additions & 13 deletions content/zh-cn/references/blocks/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ cp themes/FixIt/layouts/partials/custom.html layouts/partials/custom.html

你可以通过 `define` 来实现这些块。

| 块名称 | 描述 | 位置 |
| :--------------------------- | :----------------- | :------------------------------------- |
| `custom-head` | 头部自定义块 | `layouts/_default/baseof.html` |
| `custom-menu:desktop` | 桌面菜单自定义块 | `layouts/partials/header.html` |
| `custom-menu:mobile` | 移动菜单自定义块 | `layouts/partials/header.html` |
| `custom-profile` | 首页自定义块 | `layouts/partials/home/profile.html` |
| `custom-aside` | 侧栏自定义块 | `layouts/posts/single.html` |
| `custom-comment` | 评论系统自定义块 | `layouts/partials/single/comment.html` |
| `custom-footer` | 页脚自定义块 | `layouts/partials/footer.html` |
| `custom-widgets` | 小部件自定义块 | `layouts/partials/widgets.html` |
| `custom-assets` | 资源自定义块 | `layouts/partials/assets.html` |
| `custom-post__footer:before` | 文章页脚前自定义块 | `layouts/posts/single.html` |
| `custom-post__footer:after` | 文章页脚后自定义块 | `layouts/posts/single.html` |
| 块名称 | 描述 | 位置 |
| :---------------------------- | :------------------- | :------------------------------------- |
| `custom-head` | 头部自定义块 | `layouts/_default/baseof.html` |
| `custom-menu:desktop` | 桌面菜单自定义块 | `layouts/partials/header.html` |
| `custom-menu:mobile` | 移动菜单自定义块 | `layouts/partials/header.html` |
| `custom-profile` | 首页自定义块 | `layouts/partials/home/profile.html` |
| `custom-aside` | 侧栏自定义块 | `layouts/posts/single.html` |
| `custom-comment` | 评论系统自定义块 | `layouts/partials/single/comment.html` |
| `custom-footer` | 页脚自定义块 | `layouts/partials/footer.html` |
| `custom-widgets` | 小部件自定义块 | `layouts/partials/widgets.html` |
| `custom-assets` | 资源自定义块 | `layouts/partials/assets.html` |
| `custom-post__toc:before` | 文章页目录前自定义块 | `layouts/posts/single.html` |
| `custom-post__toc:after` | 文章页目录后自定义块 | `layouts/posts/single.html` |
| `custom-post__content:before` | 文章页内容前自定义块 | `layouts/posts/single.html` |
| `custom-post__content:after` | 文章页内容后自定义块 | `layouts/posts/single.html` |
| `custom-post__footer:before` | 文章页脚前自定义块 | `layouts/posts/single.html` |
| `custom-post__footer:after` | 文章页脚后自定义块 | `layouts/posts/single.html` |

## 主题配置

Expand All @@ -71,6 +75,10 @@ cp themes/FixIt/layouts/partials/custom.html layouts/partials/custom.html
footer = []
widgets = []
assets = []
postTocBefore = []
postTocAfter = []
postContentBefore = []
postContentAfter = []
postFooterBefore = []
postFooterAfter = []
```
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hugo-fixit/docs
go 1.20

require (
github.com/hugo-fixit/FixIt v0.3.17-0.20241226022407-21750077baed // indirect
github.com/hugo-fixit/FixIt v0.3.17-0.20241227073812-30a67c4b523b // indirect
github.com/hugo-fixit/cmpt-translate v1.5.0 // indirect
github.com/hugo-fixit/component-projects v1.5.3 // indirect
github.com/hugo-fixit/shortcode-caniuse v1.2.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/hugo-fixit/FixIt v0.3.17-0.20241226022407-21750077baed h1:5bKyBHPejXz66N6lI9fryNSlUdowvLMU2CeNTP/p5v4=
github.com/hugo-fixit/FixIt v0.3.17-0.20241226022407-21750077baed/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/FixIt v0.3.17-0.20241227073812-30a67c4b523b h1:MtJjdg27kAkFmcggkLKfmVEE5GgvwoxeiwwxPuP+VQo=
github.com/hugo-fixit/FixIt v0.3.17-0.20241227073812-30a67c4b523b/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/cmpt-translate v1.5.0 h1:UoJ+YzVvn13CzwhMzRcXxnaFh1gDSH/1K/WyUeTcwvY=
github.com/hugo-fixit/cmpt-translate v1.5.0/go.mod h1:JZ0STubquTlRgyyGhGPlt2s0KJ1gCa99+P8ltTwQRM4=
github.com/hugo-fixit/component-projects v1.5.3 h1:phKG//aW4sF9CSUn6kJry2ovBGSlJzxF5H7+ZSlemQw=
Expand Down
2 changes: 2 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ breadcrumbTitle = "Basics Syntax"
breadcrumbTitle = "Extended Syntax"
# === Translations for pages ===

[follow]
other = "Follow"
3 changes: 3 additions & 0 deletions i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ breadcrumbTitle = "扩展语法"
[admonition]
ban = "禁止"
# === shortcodes/admonition.html ===

[follow]
other = "关注"
16 changes: 16 additions & 0 deletions layouts/partials/custom/follow-me.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- $author := partial "function/get-author-map.html" .Params.author -}}
{{- $follows := slice
"Lruihao"
"hugo-fixit"
-}}

{{- if in $follows $author.name -}}
<div class="follow-container">
<a href="{{ $author.link }}" class="author-link" target="_blank">
<img src="{{ $author.avatar }}" alt="{{ $author.name }}" class="author-avatar"> {{ $author.name }}
</a>
<a href="https://github.com/{{ $author.name }}" class="follow-btn" target="_blank">
<i class="fa-brands fa-github fa-fw" aria-hidden="true"></i> {{ T "follow" }}
</a>
</div>
{{- end -}}

0 comments on commit 343f507

Please sign in to comment.