Skip to content

Commit 36fb8a7

Browse files
authored
Merge pull request #669 from danactive/isr
Admin > Walk: Show score + Improve perf
2 parents 1cc16cd + 1c76283 commit 36fb8a7

File tree

19 files changed

+720
-444
lines changed

19 files changed

+720
-444
lines changed

__tests__/view/[gallery]/all.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test.describe('All album', () => {
1919

2020
test.describe('Admin > Walk', () => {
2121
test('Filesystem list', async ({ page }) => {
22-
await page.goto('/admin/walk?path=/galleries/demo/media')
22+
await page.goto('/admin/walk/galleries/demo/media')
2323
await expect(page.locator('li').filter({ hasText: 'photos' })).toBeVisible()
2424
await expect(page.locator('li').filter({ hasText: 'thumbs' })).toBeVisible()
2525
await expect(page.locator('li').filter({ hasText: 'videos' })).toBeVisible()

app/[gallery]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import type { Metadata } from 'next'
12
import { Suspense } from 'react'
23

3-
import type { Metadata } from 'next'
44
import GalleryPageComponent from '../../src/components/GalleryPage'
55
import getAlbums from '../../src/lib/albums'
66
import getGalleries from '../../src/lib/galleries'

app/admin/walk/[...path]/page.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { Metadata } from 'next'
2+
3+
import WalkClient from '../../../../src/components/Walk/WalkClient'
4+
import getFilesystems from '../../../../src/lib/filesystems'
5+
6+
export const metadata: Metadata = {
7+
title: 'Admin > Walk - History App',
8+
}
9+
10+
export const dynamicParams = false
11+
12+
export async function generateStaticParams() {
13+
const allPaths = await getAllFolderPaths()
14+
return allPaths.map(path => ({
15+
path: path.split('/').filter(Boolean), // split into array, remove empty for catch-all segments
16+
}))
17+
}
18+
19+
async function getAllFolderPaths(path = '/') {
20+
const { files } = await getFilesystems(path)
21+
let paths: string[] = []
22+
for (const file of files) {
23+
if (file.mediumType === 'folder') {
24+
const folderPath = path === '/' ? file.name : `${path}/${file.name}`
25+
paths.push(folderPath)
26+
// Recursively collect subfolders
27+
const subPaths = await getAllFolderPaths(folderPath)
28+
paths = paths.concat(subPaths)
29+
}
30+
}
31+
return paths
32+
}
33+
34+
export default async function Page({
35+
params,
36+
}: {
37+
params: Promise<{ path?: string[] }>
38+
}) {
39+
const { path: nextRoutePath = [] } = await params
40+
const path = nextRoutePath.join('/')
41+
const fsPath = path ? `/${path}` : '/'
42+
const { files } = await getFilesystems(fsPath)
43+
44+
return <WalkClient files={files} />
45+
}

app/admin/walk/page.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { Suspense } from 'react'
21
import type { Metadata } from 'next'
32

43
import WalkClient from '../../../src/components/Walk/WalkClient'
4+
import getFilesystems from '../../../src/lib/filesystems'
55

66
export const metadata: Metadata = {
77
title: 'Admin > Walk - History App',
88
}
99

10-
export default function WalkServer() {
11-
return (
12-
<Suspense fallback={<div>Loading...</div>}>
13-
<WalkClient />
14-
</Suspense>
15-
)
10+
export default async function Page() {
11+
const { files } = await getFilesystems('/')
12+
return <WalkClient files={files} />
1613
}

0 commit comments

Comments
 (0)