Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata and opengraph tags #32

Merged
merged 36 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
db8bcb1
wip...
funkydunc Jan 10, 2025
a12abbf
draft meta title and description on exhibition, collection, publicati…
funkydunc Jan 13, 2025
40676a0
Draft meta description tag for all pages
funkydunc Jan 13, 2025
e06ff52
en/nl title for homepage
funkydunc Jan 13, 2025
44e92ce
use locale lang by default
funkydunc Jan 13, 2025
eee0b11
opengraph
funkydunc Jan 13, 2025
d9206dd
helpers for metadata. Tidy up. Make consistent.
funkydunc Jan 14, 2025
1f9339c
Merge branch 'main' into bug/DEL-108-title-and-description
funkydunc Jan 14, 2025
f0b212f
Exhibition, Object use meta and thumbnail. Publication use its image.
funkydunc Jan 15, 2025
22348a7
revert collection page to use collection.json and tidy up
funkydunc Jan 16, 2025
8cd2723
tidy up metadata
funkydunc Jan 16, 2025
990147e
remove description from publication
funkydunc Jan 16, 2025
1acbddc
remove static prerendering of exhibitions
funkydunc Jan 16, 2025
d3b10aa
updated translations
sammeltassen Jan 17, 2025
c08bb3b
reverting main title for now due to length
sammeltassen Jan 17, 2025
fadafb4
ability to link to specific canvas of object manifest
funkydunc Jan 17, 2025
5d264b4
Merge branch 'bug/DEL-108-title-and-description' of https://github.co…
funkydunc Jan 17, 2025
d916336
Default image, Date Format, Publication mdx description.
funkydunc Jan 17, 2025
3621143
mdx for non manifest page metadata
funkydunc Jan 20, 2025
32abc8e
undo test custom publication meta
funkydunc Jan 20, 2025
5116aaf
use baseURL. Default image fix.
funkydunc Jan 20, 2025
72b9a8c
fix MISSING_MESSAGE "Summary"
funkydunc Jan 20, 2025
f8a63fb
local tweaked file to extract thumbnail
funkydunc Jan 21, 2025
4e2001a
fix currently unused loadCollectionMeta
funkydunc Jan 22, 2025
6643b6d
home meta as fallback
funkydunc Jan 23, 2025
459f7bf
Merge branch 'enh/DEL-108-static-page-mdx' into enh/DEL-117-use-large…
funkydunc Jan 23, 2025
fcbdecd
home title as breadcrumb
funkydunc Jan 23, 2025
e293fd8
Merge branch 'enh/DEL-108-static-page-mdx' into enh/DEL-117-use-large…
funkydunc Jan 23, 2025
257f03b
try to solve base url issue on deploy preview
funkydunc Jan 23, 2025
1f6a729
try SITE_BASE_URL first
funkydunc Jan 23, 2025
99b78a5
default image dimensions
funkydunc Jan 23, 2025
55389d7
use prod base url
funkydunc Jan 23, 2025
db7ae88
Merge branch 'enh/DEL-108-static-page-mdx' into enh/DEL-117-use-large…
funkydunc Jan 23, 2025
68eae0f
Merge pull request #35 from digirati-co-uk/enh/DEL-117-use-largest-th…
funkydunc Jan 24, 2025
13f0952
Merge pull request #34 from digirati-co-uk/enh/DEL-108-static-page-mdx
funkydunc Jan 24, 2025
92e2ea9
fix incorrect height attributes
funkydunc Jan 24, 2025
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
7 changes: 6 additions & 1 deletion apps/iiif/.iiifrc-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ run:
- extract-slug-source
- delft-extract-labels
- extract-part-of-collection
- extract-thumbnail
- extract-thumbnail-local
- manifest-sqlite
- metadata-analysis
- site-collections
- delft-image-source
- typesense-manifests

config:
extract-thumbnail-local:
width: 1080
height: 1080

stores:
collective-access:
type: iiif-json
Expand Down
3 changes: 3 additions & 0 deletions apps/iiif/scripts/delft-label-extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ extract(
if (!resource) return false;

const label = resource.label;
const summary = resource.summary;

return {
meta: {
label: getValue(label),
intlLabel: label,
intlSummary: summary
},
};
}
Expand Down
56 changes: 56 additions & 0 deletions apps/iiif/scripts/extract-thumbnail-local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { createThumbnailHelper } from "@iiif/helpers";
import { extract } from "iiif-hss";

extract({
id: "extract-thumbnail-local",
name: "Extract Thumbnail",
types: ["Manifest"],
invalidate: async (resource, api, config) => {
const cache = await api.caches.value;
return !cache.extractThumbnail && cache.extractThumbnail !== false;
}},
async (resource, api, config) => {
const vault = resource.vault;
const helper = createThumbnailHelper(vault);
const thumbnail = await helper.getBestThumbnailAtSize(
api.resource,
config.width
? {
width: config.width,
height: config.height || config.width,
}
: {
width: 256,
height: 256,
},
config.dereference || false
);

if (thumbnail?.best) {
return {
meta: { thumbnail: thumbnail.best },
caches: { extractThumbnail: true },
};
}
else {
const thumbnail = await helper.getBestThumbnailAtSize(
api.resource, {
width: 256,
height: 256,
},
config.dereference || false
);

if (thumbnail?.best) {
return {
meta: { thumbnail: thumbnail.best },
caches: { extractThumbnail: true },
};
}
}

return {
caches: { extractThumbnail: false },
};
},
)
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/en/collections-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Collections
path: "/collections"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/en/exhibitions-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Exhibitions
path: "/exhibitions"
---
8 changes: 8 additions & 0 deletions apps/static-site/content/pages/en/home.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Academic Heritage, History and Art
description: Explore the history of Delft University of Technology and the Special Collections of TU Delft Library
image: "https://dlc.services/thumbs/7/13/00a1a6c3-25cb-4873-b570-2a77205852c9/full/683,1024/0/default.jpg"
imageWidth: 683
imageHeight: 1024
path: "/"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/en/publications-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Publications
path: "/publications"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/en/search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Search
path: "/search"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/nl/collections-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Collecties
path: "/collections"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/nl/exhibitions-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Tentoonstellingen
path: "/exhibitions"
---
8 changes: 8 additions & 0 deletions apps/static-site/content/pages/nl/home.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: Academisch Erfgoed, Geschiedenis en Kunst
description: Verken de geschiedenis van de TU Delft en de bijzondere collecties van de TU Delft Library
image: "https://dlc.services/thumbs/7/13/00a1a6c3-25cb-4873-b570-2a77205852c9/full/683,1024/0/default.jpg"
path: "/"
imageWidth: 683
imageHeight: 1024
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/nl/publications-listing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Publicaties
path: "/publications"
---
4 changes: 4 additions & 0 deletions apps/static-site/content/pages/nl/search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: Zoek
path: "/search"
---
10 changes: 8 additions & 2 deletions apps/static-site/contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ const Pages = defineDocumentType(() => ({
title: { type: "string", required: true },
path: { type: "string", required: true },
description: { type: "string", required: false },
image: { type: "string", required: false },
imageWidth: { type: "number", required: false },
imageHeight: { type: "number", required: false },
},
computedFields: {
lang: {
type: "string",
resolve: (publication) => {
return publication._id.split("/")[1];
resolve: (page) => {
return page._id.split("/")[1];
},
},
},
Expand All @@ -28,9 +31,12 @@ const Publication = defineDocumentType(() => ({
contentType: "mdx",
fields: {
title: { type: "string", required: true },
description: { type: "string", required: false },
date: { type: "string", required: false },
author: { type: "string", required: false },
image: { type: "string", required: false },
imageWidth: { type: "number", required: false },
imageHeight: { type: "number", required: false },
hero: { type: "string", required: false },
toc: { type: "boolean", default: false },
depth: { type: "number", default: 3 },
Expand Down
Binary file added apps/static-site/public/metadata/default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 27 additions & 8 deletions apps/static-site/src/app/[locale]/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
import { allPages } from ".contentlayer/generated";
import { Slot } from "@/blocks/slot";
import { SlotContext } from "@/blocks/slot-context";
import { Page } from "@/components/Page";
import { Illustration } from "@/components/blocks/Illustration";
import { useMDXComponent } from "next-contentlayer/hooks";
import { Metadata } from "next";
import { getTranslations } from "next-intl/server";
import { getBasicMetadata, makeTitle, getMdx, getDefaultMetaMdx } from "@/helpers/metadata";

export default async function AboutPage({ params }: { params: { locale: string } }) {
const aboutPages = allPages.filter((page) => page.path === "/about");
const aboutPage = aboutPages.find((page) => page.lang === params.locale) || aboutPages[0];

if (!aboutPage) throw new Error(`No about page found for locale ${params.locale}`);
export async function generateMetadata({ params }: { params: { locale: string } }): Promise<Metadata> {
const t = await getTranslations();
const path = "/about";
const defaultMeta = getDefaultMetaMdx({ params: { locale: params.locale } });
const page = getMdx({ params: { pageName: "About", path: path, locale: params.locale } });
const title = makeTitle([page.title, defaultMeta.title]);
const description = page.description ?? defaultMeta.description;
return getBasicMetadata({
locale: params.locale,
siteName: defaultMeta.title,
title: title,
description: description,
image: {
url: page.image ?? defaultMeta.image,
width: page.image ? page.imageWidth : defaultMeta.imageWidth,
height: page.image ? page.imageHeight : defaultMeta.imageHeight,
},
path: path,
});
}

const MDXContent = useMDXComponent(aboutPage.body.code);
export default async function AboutPage({ params }: { params: { locale: string } }) {
const page = getMdx({ params: { pageName: "About", path: "/about", locale: params.locale } });
const MDXContent = useMDXComponent(page.body.code);
const CustomSlot = (inner: any) => {
return <Slot context={{ page: "about", locale: params.locale }} {...inner} />;
};

return (
<Page>
<h1 className="text-4xl font-medium">{aboutPage.title}</h1>
<h1 className="text-4xl font-medium">{page.title}</h1>
<div className="mb-32 mt-8 h-full lg:col-span-2">
<article className="prose md:prose-xl prose-lg max-w-full leading-snug md:leading-snug">
<SlotContext name="page" value={"about"}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,48 @@
import { CollectionPage } from "@/components/pages/CollectionPage";
import { loadCollection } from "@/iiif";
import { Page } from "@/components/Page";
import { unstable_setRequestLocale } from "next-intl/server";
import { getTranslations, unstable_setRequestLocale } from "next-intl/server";
// import siteMap from "@repo/iiif/build/meta/sitemap.json";
import { Metadata } from "next";
import { getValue } from "@iiif/helpers";
import { baseURL, makeTitle, getDefaultMetaMdx } from "@/helpers/metadata";

export async function generateMetadata({
params,
}: {
params: { collection: string; locale: string };
}): Promise<Metadata> {
const t = await getTranslations();
const slug = `collections/${params.collection}`;
const { collection } = await loadCollection(slug);
const defaultMeta = getDefaultMetaMdx({ params: { locale: params.locale } });
const collTitle = getValue(collection.label, { language: params.locale, fallbackLanguages: ["nl", "en"] });
const description =
getValue(collection.summary, { language: params.locale, fallbackLanguages: ["nl", "en"] }) ??
defaultMeta.description;
const title = makeTitle([collTitle, defaultMeta.title]);
const url = `/collections/${params.collection}`;
// this page currently uses the default meta image as a 'collection image' is not available.
return {
metadataBase: new URL(baseURL),
description: description,
title: title,
openGraph: {
locale: params.locale,
siteName: defaultMeta.title,
title: title,
type: "website",
url: url,
images: [
{
url: defaultMeta.image ?? "",
width: defaultMeta.imageWidth,
height: defaultMeta.imageHeight,
},
],
},
};
}

export default async function Collection({ params }: { params: { collection: string; locale: string } }) {
unstable_setRequestLocale(params.locale);
Expand Down
24 changes: 23 additions & 1 deletion apps/static-site/src/app/[locale]/collections/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,36 @@ import { Page } from "@/components/Page";
import { Slot } from "@/blocks/slot";
import { getTranslations, unstable_setRequestLocale } from "next-intl/server";
import { CollectionListing } from "@/components/pages/CollectionListing";
import { getBasicMetadata, makeTitle, getMdx, getDefaultMetaMdx } from "@/helpers/metadata";
import { Metadata } from "next";

export async function generateMetadata({ params }: { params: { locale: string } }): Promise<Metadata> {
const t = await getTranslations();
const path = "/collections";
const defaultMeta = getDefaultMetaMdx({ params: { locale: params.locale } });
const page = getMdx({ params: { pageName: "Collections", path: path, locale: params.locale } });
const title = makeTitle([page.title, defaultMeta.title]);
const description = page.description ?? defaultMeta.description;
return getBasicMetadata({
locale: params.locale,
siteName: defaultMeta.title,
title: title,
description: description,
image: {
url: page.image ?? defaultMeta.image,
width: page.image ? page.imageWidth : defaultMeta.imageWidth,
height: page.image ? page.imageHeight : defaultMeta.imageHeight,
},
path: path,
});
}

export default async function Collections(props: { params: { locale: string } }) {
unstable_setRequestLocale(props.params.locale);
const t = await getTranslations();
// List of collections.
return (
<Page>

<Slot name="main-collections" context={{ locale: props.params.locale }} />

{/* <CollectionListing /> */}
Expand Down
Loading
Loading