Add hostname details to env, for opengraph

This commit is contained in:
2026-01-04 13:37:14 +00:00
parent 31522acd04
commit cabd0567f7
2 changed files with 4 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import Link from 'next/link';
import RegisterDetail from '@/app/registers/RegisterDetail'; import RegisterDetail from '@/app/registers/RegisterDetail';
import {Container, Row} from "react-bootstrap"; import {Container, Row} from "react-bootstrap";
import { getRegisters } from '@/services/register.service'; import { getRegisters } from '@/services/register.service';
import {env} from "@/env";
const buildRegisterSummary = (register: { description: string; text: string; modes: { text: string }[] }) => { const buildRegisterSummary = (register: { description: string; text: string; modes: { text: string }[] }) => {
const trimLine = (line: string) => line.trim(); const trimLine = (line: string) => line.trim();
@@ -41,7 +42,7 @@ export async function generateMetadata({ params }: { params: Promise<{ hex: stri
const summary = buildRegisterSummary(register); const summary = buildRegisterSummary(register);
const title = `${register.hex_address} ${register.name} | Spectrum Next Explorer`; const title = `${register.hex_address} ${register.name} | Spectrum Next Explorer`;
const imageUrl = `/registers/${register.hex_address}/opengraph-image`; const imageUrl = `${env.PROTO}://${env.HOSTNAME}/registers/${register.hex_address}/opengraph-image`;
return { return {
title, title,
@@ -50,7 +51,7 @@ export async function generateMetadata({ params }: { params: Promise<{ hex: stri
title, title,
description: summary, description: summary,
type: 'article', type: 'article',
url: `/registers/${register.hex_address}`, url: `${env.PROTO}://${env.HOSTNAME}/registers/${register.hex_address}`,
images: [ images: [
{ {
url: imageUrl, url: imageUrl,

View File

@@ -25,6 +25,7 @@ const serverSchema = z.object({
// System hostname for permalinks (mandatory) // System hostname for permalinks (mandatory)
HOSTNAME: z.string().min(1), HOSTNAME: z.string().min(1),
PROTO: z.string().startsWith("http"),
}); });
function formatErrors(errors: z.ZodFormattedError<Map<string, string>, string>) { function formatErrors(errors: z.ZodFormattedError<Map<string, string>, string>) {