Skip to content

Commit

Permalink
feat: add the beian parameters for websites hosted in China (#1109)
Browse files Browse the repository at this point in the history
Closes #1108
  • Loading branch information
razonyang authored Feb 15, 2025
1 parent 84f4de9 commit e52c6cf
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 1 deletion.
20 changes: 20 additions & 0 deletions assets/main/scss/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@
text-overflow: ellipsis;
}
}

.beian {
font-size: .8rem;

a {
margin-right: .125rem;

&:not(:last-child) {
&::after {
content: '·';
margin-left: .25rem;
opacity: .5;
}
}
}
}

.beian-psb-icon {
height: 16px;
}
6 changes: 6 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,9 @@ location = "Earth"
patreon = "razonyang"
paypal = "razonyang"
# rss = "" # Disable RSS link

# 备案 in pinyin, for websites hosted in China.
# [beian]
# icpNumber = "京ICP证123456号-1" # ICP number.
# psbNumber = "京公网安备12345678901234号" # Public Security Bureau number.
# moeNumber = "萌ICP备12345678号" # See https://icp.gov.moe/.
4 changes: 4 additions & 0 deletions exampleSite/content/docs/configuration/site-params/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,9 @@ The site parameters are located in `config/_default/params.toml` by default.
| `repo` | Object | - | See [Repository widget]({{< ref "docs/widgets/repository" >}}).
| `docs.nav` | Object | - | Docs layout navigation.
| `docs.nav.reduceFontSize` | Boolean | `true` | When `false`, don't reduce the font size of children navigation.
| `beian` | Object | - | 备案 in pinyin, for websites hosted in China.
| `beian.icpNumber` | string | - | ICP filing number.
| `beian.psbNumber` | string | - | PSB filing number.
| `beian.moeNumber` | string | - | Moe filing number.

> Except the Google webmaster tool, the other webmaster tools cannot work with `hugo --minify`, because they cannot recognize the minified meta tag.
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,9 @@ authors = ["RazonYang"]
| `repo` | Object | - | See [Repository widget]({{< ref "docs/widgets/repository" >}}).
| `docs.nav` | Object | - | 文档布局导航。
| `docs.nav.reduceFontSize` | Boolean | `true` | 为 `false` 时,不缩小子导航菜单的字体大小。
| `beian` | Object | - | 中国国内网站备案信息。
| `beian.icpNumber` | string | - | ICP 备案号。
| `beian.psbNumber` | string | - | 公安备案号。
| `beian.moeNumber` | string | - | 萌 ICP 备案号。

> 除了 Google 站长工具外,其他搜索引擎站长工具无法与 `hugo --minify` 同时使用,这是因为它们无法识别优化后的元标签。
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,9 @@ authors = ["RazonYang"]
| `repo` | Object | - | See [Repository widget]({{< ref "docs/widgets/repository" >}}).
| `docs.nav` | Object | - | 文檔佈局導航。
| `docs.nav.reduceFontSize` | Boolean | `true` | 為 `false` 時,不縮小子導航菜單的字體大小。
| `beian` | Object | - | 中國國內網站備案資訊。
| `beian.icpNumber` | string | - | ICP 備案號。
| `beian.psbNumber` | string | - | 公安備案號。
| `beian.moeNumber` | string | - | 萌 ICP 備案號。

> 除了 Google 站長工具外,其他搜索引擎站長工具無法與 `hugo --minify` 同時使用,這是因為它們無法識別優化後的元標簽。
2 changes: 1 addition & 1 deletion exampleSite/layouts/partials/hooks/footer-end.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- You can remove it from your site. -->
<div class="sponsors">
<div class="sponsors mt-3">
<a class="me-3" href="https://www.digitalocean.com/?utm_medium=opensource&utm_source=hugo-theme-bootstrap" target="_blank" rel="noopener noreferrer">
<img class="bg-white px-2 border border-primary rounded" src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/PoweredByDO/DO_Powered_by_Badge_blue.svg" alt="Powered by Digital Ocean" width="114" height="51" loading="lazy" />
</a>
Expand Down
29 changes: 29 additions & 0 deletions layouts/partials/footer/beian.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ with site.Params.beian }}
<div class="beian d-flex flex-wrap text-secondary justify-content-center gap-1">
{{ with .psbNumber }}
<a
class="d-inline-flex align-items-center"
target="_blank"
href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode={{ index (findRE `\d+` .) 0 }}">
<img class="beian-psb-icon w-auto me-1" src="{{ `/images/beian-psb-icon.png` | absURL }}" alt="公安备案" width="20" height="20" />
{{- . -}}
</a>
{{ end }}
{{ with.icpNumber }}
<a
class="d-inline-flex align-items-center"
target="_blank"
href="https://beian.miit.gov.cn/">
{{- . -}}
</a>
{{ end }}
{{ with.moeNumber }}
<a
class="d-inline-flex align-items-center"
target="_blank"
href="https://icp.gov.moe/?keyword={{ index (findRE `\d+` .) 0 }}">
{{- . -}}
</a>
{{ end }}
</div>
{{ end }}
1 change: 1 addition & 0 deletions layouts/partials/footer/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<div class="col-12 col-lg-8 offset-0 offset-lg-1">
{{- partialCached "footer/menu" . -}}
</div>
{{- partialCached "footer/beian" . -}}
</div>
Binary file added static/images/beian-psb-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e52c6cf

Please sign in to comment.