Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions pages/project/[id]/index.tsx

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I cant see neither og:image nor twitter:image. look in the head of the rendered html page or use online tools like https://socialsharepreview.com/ to verify what you are doing. It's a bit tricky this task and but it could help you to understand how images are handled in interfacer projects.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I noticed that no data was present in the head, and that was also true before the changes. I will check.

Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ const Project: NextPageWithLayout = () => {
const { project } = useProject();
const images = useMemo(() => findProjectImages(project), [project]);

// OG/Twitter crawlers require absolute HTTP URLs — base64 data URIs don't work,
// and the /api/image proxy path needs an origin prefix.
const ogImages = useMemo(() => {
const origin = typeof window !== "undefined" ? window.location.origin : "";
return images.map((url, i) => ({
url: url.startsWith("/") ? `${origin}${url}` : url,
width: 800,
height: 600,
alt: `${project?.name}${i > 0 ? " " + i : ""}`,
}));
}, [images]);

// (Temp) Redirect if project is LOSH owned
if (process.env.NEXT_PUBLIC_LOSH_ID == project?.primaryAccountable?.id) {
router.push(`/resource/${id}`);
Expand All @@ -64,13 +76,7 @@ const Project: NextPageWithLayout = () => {
url: window.location.origin + router.asPath,
title: project?.name,
description: project?.note || undefined,
images: images?.map((image, i) => ({
url: image,
width: 800,
height: 600,
alt: `${project?.name}${i > 0 ? " " + i : ""}`,
type: project?.images?.[i]?.mimeType || "image/jpeg",
})),
images: ogImages,
siteName: "Interfacer-gui",
}}
twitter={{
Expand Down
Loading