Skip to content

Commit 5d5c9fa

Browse files
committed
Fix pagination
1 parent 22562c3 commit 5d5c9fa

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
uses: chetan/invalidate-cloudfront-action@v2
128128
env:
129129
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
130-
PATHS: '/index.html /page/* /feed.rss'
130+
PATHS: '/ /index.html /page/* /posts/* /feed.rss /bytesized-cafe-app/* /css/* /images/* /fonts/*'
131131
AWS_REGION: 'us-east-1'
132132
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
133133
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

SPEC.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ The implementation is considered complete when:
236236
- Inline shell in the deployment and validation workflows is minimized in favor of reusable repo-root `just` recipes so the same deployment task entry points can be reused locally and in CI.
237237
- The site deploy job installs Swift 6.2.3 with `swift-actions/setup-swift@v3`, which resolves toolchains through Swiftly, installs the matching SwiftWasm SDK via `swiftwasm/setup-swiftwasm@v2.1` for `wasm32-unknown-wasip1`, and passes the resulting `swift-sdk-id` into `just wasm` so the deploy does not depend on the runner image's preinstalled Swift toolchain or SDK ordering.
238238
- The site deploy job continues to sync `Output/` to S3 using a fixed `BYTESIZED_CAFE_API_URL`.
239-
- After the S3 sync completes, the site deploy job invalidates the production CloudFront distribution with `CLOUDFRONT_DISTRIBUTION_ID` for `/index.html`, `/page/*`, and `/feed.rss`.
239+
- Paginated archive links use the literal deployed object paths under `/page/<n>/index.html` because the production S3 and CloudFront setup does not rewrite clean directory URLs to nested `index.html` objects.
240+
- After the S3 sync completes, the site deploy job invalidates the production CloudFront distribution with `CLOUDFRONT_DISTRIBUTION_ID` for `/`, `/index.html`, `/page/*`, `/posts/*`, `/feed.rss`, `/bytesized-cafe-app/*`, `/css/*`, `/images/*`, and `/fonts/*`.
240241
- The site deploy sync no longer owns generated images, because they live in a separate generated-images bucket from the static site bucket.
241242

242243
## 11. Local Development

Sources/bytesized/Theme+Bytesized.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ extension PublishingContext {
130130
sections.flatMap { $0.items }
131131
}
132132

133+
func archivePagePath(for page: Int) -> String {
134+
page == 0 ? "/" : "/page/\(page)/index.html"
135+
}
136+
133137
func pageContent<T: Website>(for page: Int, items: [Item<T>]) -> Content {
134138
let body = HTML(
135139
.body(
@@ -140,7 +144,7 @@ extension PublishingContext {
140144
.class("pure-u-1-1 pure-u-md-5-6 pure-u-lg-1-2"),
141145
.header(
142146
for: self,
143-
pagePath: "/page/\(page)",
147+
pagePath: archivePagePath(for: page),
144148
pageType: .archive
145149
),
146150
.itemList(for: items),
@@ -224,8 +228,8 @@ extension Node where Context == HTML.BodyContext {
224228

225229
let nextPage = currentPage + 1
226230
let previousPage = currentPage - 1
227-
let previousLink = previousPage == 0 ? "/" : "/page/\(previousPage)"
228-
let nextLink = "/page/\(nextPage)"
231+
let previousLink = context.archivePagePath(for: previousPage)
232+
let nextLink = context.archivePagePath(for: nextPage)
229233
let isNext = context.allItems.count > nextPage * 5
230234
let isPrevious = currentPage != 0
231235

0 commit comments

Comments
 (0)