Skip to content

Commit 9ebd93a

Browse files
fix(docs): Skip empty folders in pagination & reduce PR comment noise (#2853)
## Description This PR addresses two UX and CI/CD improvements: - Pagination (pager.html): Injects a "fast-forward/rewind" filter to automatically skip empty structural wrappers (like database roots, tools/, and samples/ folders) in the integrations directory. This ensures seamless sequential navigation without trapping users in empty folders - Preview Workflow: Updates the Cloudflare deployment action to check for an existing preview link via a hidden HTML marker. It now posts the URL only once per PR, eliminating comment spam on subsequent pushes. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) - [x] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 5b25ce0 commit 9ebd93a

File tree

3 files changed

+119
-17
lines changed

3 files changed

+119
-17
lines changed

.github/workflows/docs_preview_deploy_cf.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,34 @@ jobs:
7777
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
7878
command: pages deploy downloaded-artifact/public --project-name toolbox-docs --branch pr-${{ steps.get_pr.outputs.pr_number }}
7979

80-
- name: Comment
80+
- name: Post Preview URL Comment
8181
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
8282
with:
8383
script: |
8484
const prNumber = parseInt('${{ steps.get_pr.outputs.pr_number }}', 10);
8585
const deployUrl = '${{ steps.cf_deploy.outputs.pages-deployment-alias-url }}';
86+
const marker = '<!-- cf-preview-comment-marker -->';
8687
87-
await github.rest.issues.createComment({
88+
// Fetch all comments on the PR
89+
const { data: comments } = await github.rest.issues.listComments({
90+
owner: context.repo.owner,
91+
repo: context.repo.repo,
8892
issue_number: prNumber,
93+
});
94+
95+
// Look for the invisible HTML marker
96+
const existingComment = comments.find(c => c.body.includes(marker));
97+
98+
// Exit early if we've already posted a comment for this PR to avoid duplicates
99+
if (existingComment) {
100+
console.log("Preview link already posted on this PR. Skipping.");
101+
return;
102+
}
103+
104+
// Create the comment since it's the first deployment for this PR
105+
await github.rest.issues.createComment({
89106
owner: context.repo.owner,
90107
repo: context.repo.repo,
91-
body: `🚀 **Cloudflare Preview Ready!**\n\n🔎 View Preview: ${deployUrl}\n\n*(Note: It may take a minute or two for Cloudflare to finish deploying the branch)*`
108+
issue_number: prNumber,
109+
body: `${marker}\n🚀 **Cloudflare Preview Ready!**\n\n🔎 View Preview: ${deployUrl}\n\n*(Note: Subsequent pushes to this PR will automatically update the preview at this same URL)*`
92110
});

.hugo/layouts/partials/pager.html

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
{{ $next := "" }}
33
{{ $prev := "" }}
44

5-
{{/* 1. Calculate PREVIOUS */}}
5+
{{ $max_skip_attempts := 5 }}
6+
7+
{{/* 1. Calculate Previous Page */}}
68
{{ if .Parent }}
79
{{ $siblings := .Parent.Pages.ByWeight }}
810
{{ $currIndex := -1 }}
@@ -14,23 +16,18 @@
1416
{{ end }}
1517

1618
{{ if gt $currIndex 0 }}
17-
{{/* Preceding sibling (if it's a folder, this naturally points to its _index.md!) */}}
1819
{{ $prev = index $siblings (sub $currIndex 1) }}
1920
{{ else }}
20-
{{/* First child, so Previous points up to the Parent folder */}}
2121
{{ if ne .Parent.Type "home" }}
2222
{{ $prev = .Parent }}
2323
{{ end }}
2424
{{ end }}
2525
{{ end }}
2626

27-
28-
{{/* 2. Calculate NEXT */}}
27+
{{/* 2. Calculate Next Page */}}
2928
{{ if and .IsNode (gt (len .Pages) 0) }}
30-
{{/* If it's a folder with children, Next dives into the first child */}}
3129
{{ $next = index .Pages.ByWeight 0 }}
3230
{{ else }}
33-
{{/* Leaf page, or empty folder */}}
3431
{{ if .Parent }}
3532
{{ $siblings := .Parent.Pages.ByWeight }}
3633
{{ $currIndex := -1 }}
@@ -42,19 +39,17 @@
4239
{{ end }}
4340

4441
{{ if lt $currIndex (sub (len $siblings) 1) }}
45-
{{/* Next sibling in the same folder */}}
4642
{{ $next = index $siblings (add $currIndex 1) }}
4743
{{ else }}
48-
{{/* Last item in folder, step out and find the Parent's next sibling */}}
4944
{{ $p := .Parent }}
5045
{{ $foundNext := false }}
5146

52-
{{/* Check up to 3 directory levels up to find the next section */}}
5347
{{ range seq 3 }}
5448
{{ if and (not $foundNext) $p }}
5549
{{ if $p.Parent }}
5650
{{ $pSiblings := $p.Parent.Pages.ByWeight }}
5751
{{ $pIndex := -1 }}
52+
5853
{{ range $index, $page := $pSiblings }}
5954
{{ if eq $page.RelPermalink $p.RelPermalink }}
6055
{{ $pIndex = $index }}
@@ -72,15 +67,105 @@
7267
{{ end }}
7368
{{ end }}
7469
{{ end }}
70+
{{ end }}
71+
{{ end }}
72+
{{ end }}
73+
74+
{{/* 3. Apply Integration Directory Filters */}}
75+
{{ range seq $max_skip_attempts }}
76+
{{ if $prev }}
77+
{{ $isLockedPrev := false }}
78+
{{ if and $prev.IsNode (in $prev.RelPermalink "/integrations/") }}
79+
{{ if or (strings.HasSuffix $prev.RelPermalink "/tools/") (strings.HasSuffix $prev.RelPermalink "/samples/") (and $prev.Parent (strings.HasSuffix $prev.Parent.RelPermalink "/integrations/")) }}
80+
{{ $isLockedPrev = true }}
81+
{{ end }}
82+
{{ end }}
83+
84+
{{ if $isLockedPrev }}
85+
{{ $steppingOut := strings.HasPrefix $curr.RelPermalink $prev.RelPermalink }}
86+
87+
{{ if and (not $steppingOut) (gt (len $prev.Pages) 0) }}
88+
{{ $prev = index $prev.Pages.ByWeight (sub (len $prev.Pages) 1) }}
89+
{{ else }}
90+
{{ if $prev.Parent }}
91+
{{ if eq $prev.Parent.RelPermalink "/integrations/" }}
92+
{{ $prev = $prev.Parent }}
93+
{{ else }}
94+
{{ $sibs := $prev.Parent.Pages.ByWeight }}
95+
{{ $idx := -1 }}
96+
{{ range $i, $p := $sibs }}{{ if eq $p.RelPermalink $prev.RelPermalink }}{{ $idx = $i }}{{ end }}{{ end }}
97+
98+
{{ if gt $idx 0 }}
99+
{{ $prev = index $sibs (sub $idx 1) }}
100+
{{ else }}
101+
{{ $prev = $prev.Parent }}
102+
{{ end }}
103+
{{ end }}
104+
{{ else }}
105+
{{ $prev = "" }}
106+
{{ end }}
107+
{{ end }}
108+
{{ else }}
109+
{{ break }}
110+
{{ end }}
111+
{{ end }}
112+
{{ end }}
113+
114+
{{ range seq $max_skip_attempts }}
115+
{{ if $next }}
116+
{{ $isLockedNext := false }}
117+
{{ if and $next.IsNode (in $next.RelPermalink "/integrations/") }}
118+
{{ if or (strings.HasSuffix $next.RelPermalink "/tools/") (strings.HasSuffix $next.RelPermalink "/samples/") (and $next.Parent (strings.HasSuffix $next.Parent.RelPermalink "/integrations/")) }}
119+
{{ $isLockedNext = true }}
120+
{{ end }}
121+
{{ end }}
122+
123+
{{ if $isLockedNext }}
124+
{{ if gt (len $next.Pages) 0 }}
125+
{{ $next = index $next.Pages.ByWeight 0 }}
126+
{{ else }}
127+
{{ $sibs := $next.Parent.Pages.ByWeight }}
128+
{{ $idx := -1 }}
129+
{{ range $i, $p := $sibs }}{{ if eq $p.RelPermalink $next.RelPermalink }}{{ $idx = $i }}{{ end }}{{ end }}
130+
131+
{{ if lt $idx (sub (len $sibs) 1) }}
132+
{{ $next = index $sibs (add $idx 1) }}
133+
{{ else }}
134+
{{ $p := $next.Parent }}
135+
{{ $foundNextSibling := false }}
136+
137+
{{ range seq 3 }}
138+
{{ if and (not $foundNextSibling) $p }}
139+
{{ if $p.Parent }}
140+
{{ $pSibs := $p.Parent.Pages.ByWeight }}
141+
{{ $pIdx := -1 }}
142+
143+
{{ range $index, $page := $pSibs }}{{ if eq $page.RelPermalink $p.RelPermalink }}{{ $pIdx = $index }}{{ end }}{{ end }}
75144

145+
{{ if and (ge $pIdx 0) (lt $pIdx (sub (len $pSibs) 1)) }}
146+
{{ $next = index $pSibs (add $pIdx 1) }}
147+
{{ $foundNextSibling = true }}
148+
{{ else }}
149+
{{ $p = $p.Parent }}
150+
{{ end }}
151+
{{ else }}
152+
{{ $p = false }}
153+
{{ end }}
154+
{{ end }}
155+
{{ end }}
156+
157+
{{ if not $foundNextSibling }}{{ $next = "" }}{{ end }}
158+
{{ end }}
159+
{{ end }}
160+
{{ else }}
161+
{{ break }}
76162
{{ end }}
77163
{{ end }}
78164
{{ end }}
79165

80-
<!-- 3. Render the Buttons -->
166+
{{/* 4. Render Navigation */}}
81167
{{ if or $prev $next }}
82168
<nav class="mt-5 pt-4 border-top d-flex justify-content-between" aria-label="Page navigation">
83-
84169
<div>
85170
{{ with $prev }}
86171
<a href="{{ .RelPermalink }}" class="text-decoration-none">
@@ -98,6 +183,5 @@
98183
</a>
99184
{{ end }}
100185
</div>
101-
102186
</nav>
103187
{{ end }}

docs/en/integrations/alloydb-admin/source.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "AlloyDB Admin"
2+
title: "AlloyDB Admin Source"
33
linkTitle: "Source"
44
type: docs
55
weight: 1

0 commit comments

Comments
 (0)