diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..a670d82d --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,42 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: ["main"] + workflow_dispatch: + +permissions: {} + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Setup mise + uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 + with: + cache: true + + - name: Build docs + env: + HUGO_BASEURL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/ + run: mise run build-docs + + - name: Push rendered site to gh-pages + uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/public + publish_branch: gh-pages + keep_files: true + user_name: "github-actions[bot]" + user_email: "41898282+github-actions[bot]@users.noreply.github.com" diff --git a/.gitignore b/.gitignore index 895cb5a7..2dcc0bf1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ .claude .gh-pages .idea +docs/.hugo_build.lock +docs/public/ .pmd .project .settings diff --git a/dev-bin/release.sh b/dev-bin/release.sh index 1052094b..b9328688 100755 --- a/dev-bin/release.sh +++ b/dev-bin/release.sh @@ -118,17 +118,6 @@ if [ "$should_continue" != "y" ]; then exit 1 fi -page=.gh-pages/index.md -cat <$page ---- -layout: default -title: MaxMind GeoIP2 Java API -language: java -version: $tag ---- - -EOF - mvn versions:set -DnewVersion="$version" perl -pi -e "s/(?<=)[^<]*/$version/" README.md @@ -137,8 +126,6 @@ perl -pi -e "s/(?<=com\.maxmind\.geoip2\:geoip2\:)\d+\.\d+\.\d+([\w\-]+)?/$versi # Update japicmp.baselineVersion for API compatibility checking perl -pi -e "s/()[^<]*(<\/japicmp\.baselineVersion>)/\${1}$version\${2}/" pom.xml -cat README.md >>$page - git diff read -r -n 1 -p "Commit changes? " should_commit diff --git a/docs/assets/css/main.css b/docs/assets/css/main.css new file mode 100644 index 00000000..0376328b --- /dev/null +++ b/docs/assets/css/main.css @@ -0,0 +1,189 @@ +:root { + --fg: #2d2d2d; + --bg: #faf9f7; + --accent: #1a6b50; + --accent-soft: rgba(26, 107, 80, 0.06); + --border: #d5d0c8; + --code-bg: #f0eeea; + --heading: #1a1a1a; + --muted: #70695f; +} + +::selection { + background: rgba(26, 107, 80, 0.15); +} + +*, +*::before, +*::after { + box-sizing: border-box; +} + +body { + font-family: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif; + font-size: 1.05rem; + line-height: 1.78; + color: var(--fg); + background: var(--bg); + max-width: 50rem; + margin: 0 auto; + padding: 3rem 1.5rem 5rem; +} + +h1, +h2, +h3, +h4 { + font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; + line-height: 1.35; +} + +h1 { + font-size: 1.75rem; + font-weight: 800; + color: var(--heading); + margin: 0 0 1.5rem; + padding-bottom: 0.75rem; + border-bottom: 3px solid var(--accent); +} + +h2 { + font-size: 1.3rem; + font-weight: 700; + color: var(--heading); + margin: 3rem 0 0.75rem; + padding-bottom: 0.4rem; + border-bottom: 1px solid var(--border); +} + +h3 { + font-size: 1.05rem; + font-weight: 700; + color: var(--accent); + margin: 2.5rem 0 0.5rem; + padding: 0.4rem 0.75rem; + border-left: 3px solid var(--accent); + background: linear-gradient(135deg, var(--accent-soft), transparent 80%); + border-radius: 0 3px 3px 0; +} + +h4 { + font-size: 0.92rem; + font-weight: 700; + color: var(--muted); + margin: 2rem 0 0.5rem; + padding-bottom: 0.2rem; + border-bottom: 1px dashed var(--border); +} + +p { + margin: 0.8rem 0; +} + +a { + color: var(--accent); + text-decoration-thickness: 1px; + text-underline-offset: 2px; + transition: text-decoration-thickness 0.15s; +} + +a:hover { + text-decoration-thickness: 2px; +} + +strong { + color: var(--heading); + font-weight: 700; +} + +ol, +ul { + padding-left: 1.75rem; +} + +li + li { + margin-top: 0.3rem; +} + +code { + font-family: "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace; + font-size: 0.88em; + background: var(--code-bg); + padding: 0.15em 0.4em; + border-radius: 3px; + border: 1px solid rgba(0, 0, 0, 0.06); +} + +pre { + background: var(--code-bg); + border: 1px solid var(--border); + border-radius: 5px; + padding: 1rem 1.25rem; + overflow-x: auto; + line-height: 1.55; +} + +pre code { + background: none; + padding: 0; + border: none; + font-size: 0.85em; +} + +img { + max-width: 100%; + height: auto; +} + +.heading-anchor { + opacity: 0; + margin-left: 0.3em; + font-weight: 400; + text-decoration: none; + transition: opacity 0.15s; +} + +h1:hover .heading-anchor, +h2:hover .heading-anchor, +h3:hover .heading-anchor, +h4:hover .heading-anchor, +.heading-anchor:focus { + opacity: 0.4; +} + +.heading-anchor:hover { + opacity: 1; +} + +.page-nav { + margin-bottom: 2.5rem; + display: flex; + gap: 0.5rem; + flex-wrap: wrap; +} + +.page-nav a { + font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; + font-size: 0.85rem; + font-weight: 600; + text-decoration: none; + color: var(--muted); + padding: 0.3rem 0.75rem; + border: 1px solid var(--border); + border-radius: 999px; + transition: + color 0.15s, + border-color 0.15s, + background 0.15s; +} + +.page-nav a:hover { + color: var(--accent); + border-color: var(--accent); +} + +.page-nav a.active { + color: var(--bg); + background: var(--accent); + border-color: var(--accent); +} diff --git a/docs/hugo.toml b/docs/hugo.toml new file mode 100644 index 00000000..0f2027fe --- /dev/null +++ b/docs/hugo.toml @@ -0,0 +1,13 @@ +title = "GeoIP2 Java API" +disableKinds = ["taxonomy", "term", "RSS"] + +[[cascade]] + layout = "default" + +[markup.highlight] + noClasses = true + style = "github" + +[[module.mounts]] + source = "../README.md" + target = "content/_index.md" diff --git a/docs/layouts/404.html b/docs/layouts/404.html new file mode 100644 index 00000000..d4cb6a33 --- /dev/null +++ b/docs/layouts/404.html @@ -0,0 +1,24 @@ + + + + + + Page not found | {{ .Site.Title }} + {{- $css := resources.Get "css/main.css" | fingerprint -}} + + + +
+

Page not found

+

+ The page you're looking for doesn't exist. Return to + {{ .Site.Title }}. +

+
+ + diff --git a/docs/layouts/_default/_markup/render-heading.html b/docs/layouts/_default/_markup/render-heading.html new file mode 100644 index 00000000..4f4fcc0a --- /dev/null +++ b/docs/layouts/_default/_markup/render-heading.html @@ -0,0 +1,4 @@ + + {{- .Text | safeHTML -}} + # + diff --git a/docs/layouts/_default/default.html b/docs/layouts/_default/default.html new file mode 100644 index 00000000..e52c4a45 --- /dev/null +++ b/docs/layouts/_default/default.html @@ -0,0 +1,25 @@ + + + + + + {{- $title := or .Title .File.BaseFileName -}} + {{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ $title }} | {{ .Site.Title }}{{ end }} + {{- $css := resources.Get "css/main.css" | fingerprint -}} + + + + +
+ {{ .Content }} +
+ + diff --git a/mise.lock b/mise.lock index 05c091e5..9b150a1f 100644 --- a/mise.lock +++ b/mise.lock @@ -1,5 +1,37 @@ # @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html +[[tools.hugo]] +version = "0.161.1" +backend = "aqua:gohugoio/hugo" + +[tools.hugo."platforms.linux-arm64"] +checksum = "sha256:382371ec3208236fb854ced51781f859b6c27a7d066b8fe90594eba14ba76d00" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_linux-arm64.tar.gz" + +[tools.hugo."platforms.linux-arm64-musl"] +checksum = "sha256:382371ec3208236fb854ced51781f859b6c27a7d066b8fe90594eba14ba76d00" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_linux-arm64.tar.gz" + +[tools.hugo."platforms.linux-x64"] +checksum = "sha256:fae28bf7909c1a42d1365b89d2e9e3d4194fbe5968ae0dd5504f562381018a1d" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_linux-amd64.tar.gz" + +[tools.hugo."platforms.linux-x64-musl"] +checksum = "sha256:fae28bf7909c1a42d1365b89d2e9e3d4194fbe5968ae0dd5504f562381018a1d" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_linux-amd64.tar.gz" + +[tools.hugo."platforms.macos-arm64"] +checksum = "sha256:b12e1cbebacf61f9cf67e0046c835142e70c829da7c16b05c1ec64a68885ee80" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_darwin-universal.pkg" + +[tools.hugo."platforms.macos-x64"] +checksum = "sha256:b12e1cbebacf61f9cf67e0046c835142e70c829da7c16b05c1ec64a68885ee80" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_darwin-universal.pkg" + +[tools.hugo."platforms.windows-x64"] +checksum = "sha256:7f8d030b37600c60bf2a782611257e6a768934fbe7724c1f3a1a501e6724cf0d" +url = "https://github.com/gohugoio/hugo/releases/download/v0.161.1/hugo_0.161.1_windows-amd64.zip" + [[tools.java]] version = "26.0.1" backend = "core:java" diff --git a/mise.toml b/mise.toml index c4027682..4a11f83e 100644 --- a/mise.toml +++ b/mise.toml @@ -7,9 +7,18 @@ disable_backends = [ ] [tools] +hugo = "latest" java = "latest" maven = "latest" +[tasks.build-docs] +description = "Build the docs site with Hugo" +run = "hugo --source docs --minify" + +[tasks.serve-docs] +description = "Serve the docs site locally with Hugo dev server" +run = "hugo server --source docs" + [hooks] enter = "mise install --quiet --locked"