Skip to content

Commit 3ea2a2f

Browse files
committed
chore: initial commit
0 parents  commit 3ea2a2f

20 files changed

+2988
-0
lines changed

.eslintrc.cjs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/recommended'
5+
],
6+
parser: '@typescript-eslint/parser',
7+
plugins: ['@typescript-eslint'],
8+
root: true,
9+
ignorePatterns: [
10+
"*.tmpl.ts",
11+
"postcss.config.js",
12+
"purgecss.config.js"
13+
]
14+
};

.github/FUNDING.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ko_fi: razonyang
2+
custom:
3+
- https://paypal.me/razonyang

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public/
2+
resources/
3+
.hugo_build.lock
4+
node_modules/

.mergify.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pull_request_rules:
2+
- name: Automatic merge for Renovate pull requests
3+
conditions:
4+
- author=renovate[bot]
5+
actions:
6+
merge:
7+
method: rebase
8+
9+
- name: Automatic merge on approval
10+
conditions:
11+
- "#approved-reviews-by>=1"
12+
actions:
13+
merge:
14+
method: rebase

.prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"bracketSameLine": true,
3+
"goTemplateBracketSpacing": true,
4+
"overrides": [
5+
{
6+
"files": [
7+
"*.html"
8+
],
9+
"options": {
10+
"parser": "go-template",
11+
"bracketSameLine": true
12+
}
13+
}
14+
]
15+
}

.stylelintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.tmpl.scss

.stylelintrc.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "stylelint-config-standard-scss",
3+
"rules": {
4+
"at-rule-no-unknown": null,
5+
"color-function-notation": null,
6+
"scss/at-rule-no-unknown": true,
7+
"scss/at-extend-no-missing-placeholder": null
8+
}
9+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 HB Framework Authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# HB Pagination Module
2+
3+
[![Used By](https://img.shields.io/badge/dynamic/json?color=success&label=used+by&query=repositories_humanize&logo=hugo&style=flat-square&url=https://api.razonyang.com/v1/github/dependents/hbstack/pagination)](https://github.com/hbstack/pagination/network/dependents)
4+
![Hugo Requirements](https://img.shields.io/badge/dynamic/json?color=important&label=requirements&query=requirements&logo=hugo&style=flat-square&url=https://api.razonyang.com/v1/hugo/modules/github.com/hbstack/pagination)
5+
[![License](https://img.shields.io/github/license/hbstack/pagination?style=flat-square)](https://github.com/hbstack/pagination/blob/main/LICENSE)
6+
[![Version](https://img.shields.io/github/v/tag/hbstack/pagination?label=version&style=flat-square)](https://github.com/hbstack/pagination/tags)

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/hbstack/pagination
2+
3+
go 1.19

hugo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# [module.hugoVersion]
2+
# min = "0.111.3"
3+
4+
[[module.imports]]
5+
path = "github.com/hbstack/hb"
6+
7+
[params.hb.pagination]
8+
alignment = "center" # center, start (left) or end (right).
9+
size = "" # sm (small) or lg (large), leave it empty to use the default size.
10+
siblings = 2 # The number of siblings to the left/right of the current page number.
11+
12+
# [params.hugopress.modules.hb-pagination.hooks.body-end]
13+
# cacheable = true

i18n/en.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pagination_next]
2+
other = "Next"
3+
4+
[pagination_prev]
5+
other = "Previous"

i18n/zh-hans.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pagination_next]
2+
other = "下一页"
3+
4+
[pagination_prev]
5+
other = "前一页"

i18n/zh-hant.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pagination_next]
2+
other = "下一頁"
3+
4+
[pagination_prev]
5+
other = "前一頁"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- $v := false }}
2+
{{- if eq .Number 1 }}
3+
{{- $v = true }}
4+
{{- else if eq .Number .Last }}
5+
{{- $v = true }}
6+
{{- else if eq .Number .Current }}
7+
{{- $v = true }}
8+
{{- else }}
9+
{{- $range := default 2 site.Params.hb.pagination.siblings }}
10+
{{- $dif := sub (math.Max .Current .Number) (math.Min .Current .Number) }}
11+
{{- $v = le $dif $range }}
12+
{{- end }}
13+
{{- return $v -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{- if or .HasPrev .HasNext }}
2+
{{- $paginator := . }}
3+
{{- $alignment := default "center" site.Params.hb.pagination.alignment }}
4+
{{- $size := default "" site.Params.hb.pagination.size }}
5+
<nav
6+
class="hb-blog-pagination hb-module"
7+
aria-label="Page navigation">
8+
<ul
9+
class="pagination flex-wrap justify-content-{{ $alignment }}{{ cond (ne $size ``) (printf ` pagination-%s` $size) `` }}">
10+
<li class="page-item{{ cond (not .Prev) ` disabled` `` }}">
11+
<a
12+
class="page-link"
13+
href="{{ with .Prev }}{{ .URL }}{{ end }}"
14+
aria-label="{{- i18n `pagination_prev` -}}">
15+
<span aria-hidden="true">&laquo;</span>
16+
</a>
17+
</li>
18+
{{- $separator := false }}
19+
{{- range .Pagers }}
20+
{{- $isNeighbor := partial "hb/modules/pagination/functions/is-sibling" (dict
21+
"Number" .PageNumber
22+
"Current" $paginator.PageNumber
23+
"Last" $paginator.TotalPages)
24+
}}
25+
{{- if $isNeighbor }}
26+
{{- $separator = false }}
27+
<li
28+
class="page-item{{ cond (eq .PageNumber $paginator.PageNumber) ` active` `` }}">
29+
<a class="page-link" href="{{ .URL }}">{{ .PageNumber }}</a>
30+
</li>
31+
{{- else if not $separator }}
32+
{{ partialCached "hb/modules/pagination/separator" . }}
33+
{{- $separator = true }}
34+
{{- end }}
35+
{{- end }}
36+
<li class="page-item{{ cond (not .Next) ` disabled` `` }}">
37+
<a
38+
class="page-link"
39+
href="{{ with .Next }}{{ .URL }}{{ end }}"
40+
aria-label="{{- i18n `pagination_next` -}}">
41+
<span aria-hidden="true">&raquo;</span>
42+
</a>
43+
</li>
44+
</ul>
45+
</nav>
46+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<li class="page-item disabled">
2+
<a class="page-link" href="#">...</a>
3+
</li>

0 commit comments

Comments
 (0)