mirror of
https://github.com/privacy-scaling-explorations/pse.dev.git
synced 2026-01-08 21:58:05 -05:00
fix: projects images
This commit is contained in:
@@ -31,9 +31,7 @@ export async function generateMetadata({
|
|||||||
|
|
||||||
const content = project?.content
|
const content = project?.content
|
||||||
const imageUrl =
|
const imageUrl =
|
||||||
(project?.image ?? "")?.length > 0
|
(project?.image ?? "")?.length > 0 ? project.image : "/share-image.png"
|
||||||
? `/project-banners/${project?.image}`
|
|
||||||
: "/share-image.png"
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: project?.name,
|
title: project?.name,
|
||||||
|
|||||||
@@ -73,9 +73,7 @@ export const WikiCard = ({ project, className = "" }: WikiCardProps) => {
|
|||||||
<Card className="bg-background" padding="none">
|
<Card className="bg-background" padding="none">
|
||||||
<div className="relative flex h-[140px] items-center justify-center overflow-hidden rounded-t-lg">
|
<div className="relative flex h-[140px] items-center justify-center overflow-hidden rounded-t-lg">
|
||||||
<Image
|
<Image
|
||||||
src={`/project-banners/${
|
src={project.image || "/project-banners/fallback.webp"}
|
||||||
project.image ? project.image : "fallback.webp"
|
|
||||||
}`}
|
|
||||||
alt={`${project.name} banner`}
|
alt={`${project.name} banner`}
|
||||||
fill
|
fill
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
@@ -132,7 +130,7 @@ export const WikiCard = ({ project, className = "" }: WikiCardProps) => {
|
|||||||
<Card padding="none">
|
<Card padding="none">
|
||||||
<div className="relative flex max-h-[140px] items-center justify-center overflow-hidden rounded-t-lg ">
|
<div className="relative flex max-h-[140px] items-center justify-center overflow-hidden rounded-t-lg ">
|
||||||
<Image
|
<Image
|
||||||
src={`/project-banners/${previousBrandImage}`}
|
src={previousBrandImage}
|
||||||
alt={`${project.name} banner`}
|
alt={`${project.name} banner`}
|
||||||
fill
|
fill
|
||||||
className="object-cover"
|
className="object-cover"
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default function ProjectCard({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
src={`/project-banners/${image ? image : "fallback.webp"}`}
|
src={image || "/project-banners/fallback.webp"}
|
||||||
alt="Project banner image"
|
alt="Project banner image"
|
||||||
width={1200}
|
width={1200}
|
||||||
height={630}
|
height={630}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ export default function ProjectCard({
|
|||||||
{showBanner && (
|
{showBanner && (
|
||||||
<div className="relative flex flex-col border-b border-black/10 cursor-pointer">
|
<div className="relative flex flex-col border-b border-black/10 cursor-pointer">
|
||||||
<Image
|
<Image
|
||||||
src={`/project-banners/${image ? image : "fallback.webp"}`}
|
src={image || "/project-banners/fallback.webp"}
|
||||||
alt={`${name} banner`}
|
alt={`${name} banner`}
|
||||||
width={1200}
|
width={1200}
|
||||||
height={630}
|
height={630}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import path from "path"
|
|||||||
|
|
||||||
const VALID_IMAGE_BASES = ["articles", "projects", "project", "project-banners"]
|
const VALID_IMAGE_BASES = ["articles", "projects", "project", "project-banners"]
|
||||||
|
|
||||||
|
const FLAT_STORAGE_BASES = ["project-banners"]
|
||||||
|
|
||||||
function normalizeImagePath(
|
function normalizeImagePath(
|
||||||
imagePath: string | undefined,
|
imagePath: string | undefined,
|
||||||
defaultBasePath: string = "articles",
|
defaultBasePath: string = "articles",
|
||||||
@@ -32,7 +34,9 @@ function normalizeImagePath(
|
|||||||
|
|
||||||
if (!hasValidBase) {
|
if (!hasValidBase) {
|
||||||
const isJustFilename = !normalized.includes("/")
|
const isJustFilename = !normalized.includes("/")
|
||||||
if (isJustFilename && slug) {
|
const isFlatStorage = FLAT_STORAGE_BASES.includes(defaultBasePath)
|
||||||
|
|
||||||
|
if (isJustFilename && slug && !isFlatStorage) {
|
||||||
normalized = `${defaultBasePath}/${slug}/${normalized}`
|
normalized = `${defaultBasePath}/${slug}/${normalized}`
|
||||||
} else {
|
} else {
|
||||||
normalized = `${defaultBasePath}/${normalized}`
|
normalized = `${defaultBasePath}/${normalized}`
|
||||||
@@ -243,7 +247,12 @@ export function getProjects(options?: {
|
|||||||
processContent: (data, content, id) => ({
|
processContent: (data, content, id) => ({
|
||||||
id,
|
id,
|
||||||
...data,
|
...data,
|
||||||
image: normalizeImagePath(data.image, "projects", id),
|
image: normalizeImagePath(data.image, "project-banners", id),
|
||||||
|
previousBrandImage: normalizeImagePath(
|
||||||
|
data.previousBrandImage,
|
||||||
|
"project-banners",
|
||||||
|
id
|
||||||
|
),
|
||||||
content: normalizeContentImagePaths(content, "projects", id),
|
content: normalizeContentImagePaths(content, "projects", id),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user