format code + change env

This commit is contained in:
Thomas Camlong
2025-10-01 19:01:31 +02:00
parent 0a4a4a78f4
commit 49aab75953
19 changed files with 1282 additions and 1468 deletions

View File

@@ -12,18 +12,16 @@ import type { IconWithName } from "@/types/icons"
* Note: Do not use the client-side pb instance (with auth store) on the server
*/
function createServerPB() {
return new PocketBase(process.env.POCKETBASE_URL || "http://127.0.0.1:8090")
return new PocketBase(process.env.NEXT_PUBLIC_POCKETBASE_URL || "http://127.0.0.1:8090")
}
/**
* Transform a CommunityGallery item to IconWithName format for use with IconSearch
*/
function transformGalleryToIcon(item: CommunityGallery): any {
const pbUrl = process.env.POCKETBASE_URL || "http://127.0.0.1:8090"
const fileUrl = item.assets?.[0]
? `${pbUrl}/api/files/community_gallery/${item.id}/${item.assets[0]}`
: ""
const pbUrl = process.env.NEXT_PUBLIC_POCKETBASE_URL || "http://127.0.0.1:8090"
const fileUrl = item.assets?.[0] ? `${pbUrl}/api/files/community_gallery/${item.id}/${item.assets[0]}` : ""
const transformed = {
name: item.name,
@@ -43,7 +41,7 @@ function transformGalleryToIcon(item: CommunityGallery): any {
wordmark: item.extras?.wordmark,
},
}
return transformed
}
@@ -62,9 +60,7 @@ export async function fetchCommunitySubmissions(): Promise<IconWithName[]> {
sort: "-created",
})
return records
.filter(item => item.assets && item.assets.length > 0)
.map(transformGalleryToIcon)
return records.filter((item) => item.assets && item.assets.length > 0).map(transformGalleryToIcon)
} catch (error) {
console.error("Error fetching community submissions:", error)
return []
@@ -80,4 +76,3 @@ export const getCommunitySubmissions = unstable_cache(fetchCommunitySubmissions,
revalidate: 600,
tags: ["community-gallery"],
})