Merge pull request #2495 from ZhenShuo2021/fix/page-widget

🐛 Fix: page widget
This commit is contained in:
Nuno C.
2025-09-23 15:55:25 +01:00
committed by GitHub
12 changed files with 77 additions and 47 deletions
+23 -19
View File
@@ -497,6 +497,9 @@ body.zen-mode-enable {
.start-\[calc\(max\(-50vw\,-800px\)\+50\%\)\] { .start-\[calc\(max\(-50vw\,-800px\)\+50\%\)\] {
inset-inline-start: calc(max(-50vw, -800px) + 50%); inset-inline-start: calc(max(-50vw, -800px) + 50%);
} }
.end-6 {
inset-inline-end: calc(var(--spacing) * 6);
}
.top-0 { .top-0 {
top: calc(var(--spacing) * 0); top: calc(var(--spacing) * 0);
} }
@@ -506,18 +509,18 @@ body.zen-mode-enable {
.top-20 { .top-20 {
top: calc(var(--spacing) * 20); top: calc(var(--spacing) * 20);
} }
.top-\[110vh\] {
top: 110vh;
}
.top-\[calc\(100vh-5\.5rem\)\] {
top: calc(100vh - 5.5rem);
}
.right-0 { .right-0 {
right: calc(var(--spacing) * 0); right: calc(var(--spacing) * 0);
} }
.bottom-0 { .bottom-0 {
bottom: calc(var(--spacing) * 0); bottom: calc(var(--spacing) * 0);
} }
.bottom-6 {
bottom: calc(var(--spacing) * 6);
}
.bottom-24 {
bottom: calc(var(--spacing) * 24);
}
.left-0 { .left-0 {
left: calc(var(--spacing) * 0); left: calc(var(--spacing) * 0);
} }
@@ -536,6 +539,9 @@ body.zen-mode-enable {
.z-30 { .z-30 {
z-index: 30; z-index: 30;
} }
.z-50 {
z-index: 50;
}
.z-80 { .z-80 {
z-index: 80; z-index: 80;
} }
@@ -1204,9 +1210,6 @@ body.zen-mode-enable {
.mb-12 { .mb-12 {
margin-bottom: calc(var(--spacing) * 12); margin-bottom: calc(var(--spacing) * 12);
} }
.mb-16 {
margin-bottom: calc(var(--spacing) * 16);
}
.mb-20 { .mb-20 {
margin-bottom: calc(var(--spacing) * 20); margin-bottom: calc(var(--spacing) * 20);
} }
@@ -1538,6 +1541,14 @@ body.zen-mode-enable {
--tw-translate-y: calc(var(--spacing) * -8); --tw-translate-y: calc(var(--spacing) * -8);
translate: var(--tw-translate-x) var(--tw-translate-y); translate: var(--tw-translate-x) var(--tw-translate-y);
} }
.translate-y-0 {
--tw-translate-y: calc(var(--spacing) * 0);
translate: var(--tw-translate-x) var(--tw-translate-y);
}
.translate-y-4 {
--tw-translate-y: calc(var(--spacing) * 4);
translate: var(--tw-translate-x) var(--tw-translate-y);
}
.scale-0 { .scale-0 {
--tw-scale-x: 0%; --tw-scale-x: 0%;
--tw-scale-y: 0%; --tw-scale-y: 0%;
@@ -3213,11 +3224,6 @@ body.zen-mode-enable {
grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-columns: repeat(5, minmax(0, 1fr));
} }
} }
.ltr\:right-0 {
&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
right: calc(var(--spacing) * 0);
}
}
.ltr\:mr-4 { .ltr\:mr-4 {
&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) { &:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *) {
margin-right: calc(var(--spacing) * 4); margin-right: calc(var(--spacing) * 4);
@@ -3243,11 +3249,6 @@ body.zen-mode-enable {
display: inline; display: inline;
} }
} }
.rtl\:left-0 {
&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
left: calc(var(--spacing) * 0);
}
}
.rtl\:-mr-\[79px\] { .rtl\:-mr-\[79px\] {
&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) { &:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
margin-right: calc(79px * -1); margin-right: calc(79px * -1);
@@ -3807,6 +3808,9 @@ pre {
[id^="fn"], [id^="fnref"] { [id^="fn"], [id^="fnref"] {
scroll-margin-top: 145px; scroll-margin-top: 145px;
} }
#main-content {
scroll-margin-top: -125px;
}
@media (width >= 640px) { @media (width >= 640px) {
.article { .article {
flex-wrap: wrap; flex-wrap: wrap;
+5
View File
@@ -215,6 +215,11 @@ pre {
scroll-margin-top: 145px; scroll-margin-top: 145px;
} }
/* patch for skip to main content */
#main-content {
scroll-margin-top: -125px;
}
@variant sm { @variant sm {
.article { .article {
flex-wrap: wrap; flex-wrap: wrap;
+13
View File
@@ -0,0 +1,13 @@
function scrollToTop() {
const scrollToTop = document.getElementById("scroll-to-top");
if (window.scrollY > window.innerHeight * 0.5) {
scrollToTop.classList.remove("translate-y-4", "opacity-0");
scrollToTop.classList.add("translate-y-0", "opacity-100");
} else {
scrollToTop.classList.remove("translate-y-0", "opacity-100");
scrollToTop.classList.add("translate-y-4", "opacity-0");
}
}
window.addEventListener("scroll", scrollToTop);
window.addEventListener("load", scrollToTop);
+1 -1
View File
@@ -160,7 +160,7 @@ forgejoDefaultServer = "https://v11.next.forgejo.org"
# globalWidget = true # globalWidget = true
# globalWidgetMessage = "Hello" # globalWidgetMessage = "Hello"
# globalWidgetColor = "#FFDD00" # globalWidgetColor = "#FFDD00"
# globalWidgetPosition = "Right" # globalWidgetPosition = "right"
[verification] [verification]
# google = "" # google = ""
+1 -1
View File
@@ -159,7 +159,7 @@ fingerprintAlgorithm = "sha512" # Valid values are "sha512" (default), "sha384",
globalWidget = true globalWidget = true
globalWidgetMessage = "" globalWidgetMessage = ""
globalWidgetColor = "#FFDD00" globalWidgetColor = "#FFDD00"
globalWidgetPosition = "Right" globalWidgetPosition = "right"
[verification] [verification]
# google = "" # google = ""
@@ -353,8 +353,8 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `buymeacoffee.identifier` | _Not set_ | The identifier to the target buymeacoffee account. | | `buymeacoffee.identifier` | _Not set_ | The identifier to the target buymeacoffee account. |
| `buymeacoffee.globalWidget` | _Not set_ | Activate the global buymeacoffee widget. | | `buymeacoffee.globalWidget` | _Not set_ | Activate the global buymeacoffee widget. |
| `buymeacoffee.globalWidgetMessage` | _Not set_ | Message what will be displayed the first time a new user lands on the site. | | `buymeacoffee.globalWidgetMessage` | _Not set_ | Message what will be displayed the first time a new user lands on the site. |
| `buymeacoffee.globalWidgetColor` | _Not set_ | Widget color in hex format. | | `buymeacoffee.globalWidgetColor` | `#FFDD00` | Widget color in hex format. |
| `buymeacoffee.globalWidgetPosition` | _Not set_ | Position of the widget, i.e. "Left" or "Right" | | `buymeacoffee.globalWidgetPosition` | _Not set_ | Position of the widget, i.e. "left" or "right" |
### Verifications ### Verifications
@@ -353,8 +353,8 @@ Blowfish は、テーマの機能を制御する多数の設定パラメータ
| `buymeacoffee.identifier` | _未設定_ | ターゲットの buymeacoffee アカウントの識別子。 | | `buymeacoffee.identifier` | _未設定_ | ターゲットの buymeacoffee アカウントの識別子。 |
| `buymeacoffee.globalWidget` | _未設定_ | グローバル buymeacoffee ウィジェットを有効にします。 | | `buymeacoffee.globalWidget` | _未設定_ | グローバル buymeacoffee ウィジェットを有効にします。 |
| `buymeacoffee.globalWidgetMessage` | _未設定_ | 新しいユーザーが初めてサイトにアクセスしたときに表示されるメッセージ。 | | `buymeacoffee.globalWidgetMessage` | _未設定_ | 新しいユーザーが初めてサイトにアクセスしたときに表示されるメッセージ。 |
| `buymeacoffee.globalWidgetColor` | _未設定_ | ウィジェットの色(16進数形式)。 | | `buymeacoffee.globalWidgetColor` | `#FFDD00` | ウィジェットの色(16進数形式)。 |
| `buymeacoffee.globalWidgetPosition` | _未設定_ | ウィジェットの位置。例えば "Left" または "Right" | | `buymeacoffee.globalWidgetPosition` | _未設定_ | ウィジェットの位置。例えば "left" または "right" |
### verification ### verification
@@ -360,8 +360,8 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `buymeacoffee.identifier` | _Not set_ | The identifier to the target buymeacoffee account. | | `buymeacoffee.identifier` | _Not set_ | The identifier to the target buymeacoffee account. |
| `buymeacoffee.globalWidget` | _Not set_ | Activate the global buymeacoffee widget. | | `buymeacoffee.globalWidget` | _Not set_ | Activate the global buymeacoffee widget. |
| `buymeacoffee.globalWidgetMessage` | _Not set_ | Message what will be displayed the first time a new user lands on the site. | | `buymeacoffee.globalWidgetMessage` | _Not set_ | Message what will be displayed the first time a new user lands on the site. |
| `buymeacoffee.globalWidgetColor` | _Not set_ | Widget color in hex format. | | `buymeacoffee.globalWidgetColor` | `#FFDD00` | Widget color in hex format. |
| `buymeacoffee.globalWidgetPosition` | _Not set_ | Position of the widget, i.e. "Left" or "Right" | | `buymeacoffee.globalWidgetPosition` | _Not set_ | Position of the widget, i.e. "left" or "right" |
### Verifications ### Verifications
@@ -352,13 +352,13 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中
### BuyMeACoffee(赞助平台) ### BuyMeACoffee(赞助平台)
| 名称 | 默认值 | 描述 | | 名称 | 默认值 | 描述 |
| ----------------------------------- | ------ | ---------------------------------- | | ----------------------------------- | --------- | ---------------------------------- |
| `buymeacoffee.identifier` | 无 | buymeacoffee 账号的用户名。 | | `buymeacoffee.identifier` | 无 | buymeacoffee 账号的用户名。 |
| `buymeacoffee.globalWidget` | 无 | 激活位于全局的 buymeacoffee 组件。 | | `buymeacoffee.globalWidget` | 无 | 激活位于全局的 buymeacoffee 组件。 |
| `buymeacoffee.globalWidgetMessage` | 无 | 新用户首次访问网站时显示的消息。 | | `buymeacoffee.globalWidgetMessage` | 无 | 新用户首次访问网站时显示的消息。 |
| `buymeacoffee.globalWidgetColor` | | 组件颜色,使用 HEX 格式。 | | `buymeacoffee.globalWidgetColor` | `#FFDD00` | 组件颜色,使用 HEX 格式。 |
| `buymeacoffee.globalWidgetPosition` | 无 | 组件位置,例如 "Left" 或 "Right"。 | | `buymeacoffee.globalWidgetPosition` | 无 | 组件位置,例如 "left" 或 "right"。 |
### 验证 ### 验证
+7 -11
View File
@@ -1,14 +1,10 @@
<!doctype html> <!doctype html>
<html <html
lang="{{ with site.Params.isoCode | default (site.LanguageCode | default " en") }}{{- . -}}{{ end }}" lang="{{ with site.Params.isoCode | default (site.LanguageCode | default `en`) }}{{- . -}}{{ end }}"
dir="{{ if site.Params.rtl | default false -}} dir="{{ cond (site.Params.rtl | default false) `rtl` `ltr` }}"
rtl
{{- else -}}
ltr
{{- end }}"
class="scroll-smooth" class="scroll-smooth"
data-default-appearance="{{ site.Params.defaultAppearance | default " light" }}" data-default-appearance="{{ site.Params.defaultAppearance | default `light` }}"
data-auto-appearance="{{ site.Params.autoSwitchAppearance | default " true" }}"> data-auto-appearance="{{ site.Params.autoSwitchAppearance | default `true` }}">
{{- partial "head.html" . -}} {{- partial "head.html" . -}}
@@ -48,9 +44,9 @@
src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js" src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js"
data-id="{{ site.Params.buymeacoffee.identifier }}" data-id="{{ site.Params.buymeacoffee.identifier }}"
data-description="Support me on Buy me a coffee!" data-description="Support me on Buy me a coffee!"
data-message="{{ site.Params.buymeacoffee.globalWidgetMessage | default "" }}" {{ with site.Params.buymeacoffee.globalWidgetMessage }}data-message="{{ . }}"{{ end }}
data-color="{{ site.Params.buymeacoffee.globalWidgetColor | default "#FFDD00" }}" {{ with site.Params.buymeacoffee.globalWidgetColor | default `#FFDD00` }}data-color="{{ . }}"{{ end }}
data-position="{{ site.Params.buymeacoffee.globalWidgetPosition | default "Left" }}" {{ with site.Params.buymeacoffee.globalWidgetPosition }}data-position="{{ . }}"{{ end }}
data-x_margin="18" data-x_margin="18"
data-y_margin="18"></script> data-y_margin="18"></script>
{{ end }} {{ end }}
+8
View File
@@ -69,6 +69,10 @@
type="text/javascript" type="text/javascript"
src="{{ $jsAppearance.RelPermalink }}" src="{{ $jsAppearance.RelPermalink }}"
integrity="{{ $jsAppearance.Data.Integrity }}"></script> integrity="{{ $jsAppearance.Data.Integrity }}"></script>
{{ if site.Params.footer.showScrollToTop | default true }}
{{ $jsToTop := resources.Get "js/scroll-to-top.js" }}
{{ $assets.Add "js" (slice $jsToTop) }}
{{ end }}
{{ if .Site.Params.enableA11y | default false }} {{ if .Site.Params.enableA11y | default false }}
{{ $jsA11y := resources.Get "js/a11y.js" }} {{ $jsA11y := resources.Get "js/a11y.js" }}
{{ $jsA11y = $jsA11y | resources.Minify | resources.Fingerprint (site.Params.fingerprintAlgorithm | default "sha512") }} {{ $jsA11y = $jsA11y | resources.Minify | resources.Fingerprint (site.Params.fingerprintAlgorithm | default "sha512") }}
@@ -83,6 +87,10 @@
src="{{ $jsZenMode.RelPermalink }}" src="{{ $jsZenMode.RelPermalink }}"
integrity="{{ $jsZenMode.Data.Integrity }}"></script> integrity="{{ $jsZenMode.Data.Integrity }}"></script>
{{ end }} {{ end }}
{{ if site.Params.footer.showScrollToTop | default true }}
{{ $jsToTop := resources.Get "js/scroll-to-top.js" }}
{{ $assets.Add "js" (slice $jsToTop) }}
{{ end }}
{{ if .Site.Params.enableSearch | default false }} {{ if .Site.Params.enableSearch | default false }}
{{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }} {{ $jsFuse := resources.Get "lib/fuse/fuse.min.js" }}
{{ $jsSearch := resources.Get "js/search.js" }} {{ $jsSearch := resources.Get "js/search.js" }}
+6 -2
View File
@@ -1,7 +1,11 @@
<div id="top-scroller" class="pointer-events-none absolute top-[110vh] bottom-0 w-12 ltr:right-0 rtl:left-0 z-10"> {{ $coffeeIsRight := and site.Params.buymeacoffee.globalWidget (eq (lower site.Params.buymeacoffee.globalWidgetPosition) "right") }}
{{ $toTopYOffset := cond $coffeeIsRight "bottom-24" "bottom-6" }}
<div
id="scroll-to-top"
class="fixed {{ $toTopYOffset }} end-6 z-50 transform translate-y-4 opacity-0 duration-200">
<a <a
href="#the-top" href="#the-top"
class="pointer-events-auto sticky top-[calc(100vh-5.5rem)] flex h-12 w-12 mb-16 items-center justify-center rounded-full bg-neutral/50 text-xl text-neutral-700 hover:text-primary-600 dark:bg-neutral-800/50 dark:text-neutral dark:hover:text-primary-400" class="pointer-events-auto flex h-12 w-12 items-center justify-center rounded-full bg-neutral/50 text-xl text-neutral-700 hover:text-primary-600 dark:bg-neutral-800/50 dark:text-neutral dark:hover:text-primary-400"
aria-label="{{ i18n "nav.scroll_to_top_title" }}" aria-label="{{ i18n "nav.scroll_to_top_title" }}"
title="{{ i18n "nav.scroll_to_top_title" }}"> title="{{ i18n "nav.scroll_to_top_title" }}">
&uarr; &uarr;