redirecter for ao3 that adds opengraph metadata

better handling of locked works

Changed files
+17 -4
src
app
series
[seriesId]
works
[workId]
chapters
[chapterId]
+1 -1
next.config.mjs
···
const nextConfig = {
/* config options here */
turbopack: {
-
root: './'
+
root: '/var/www/fixao3'
}
};
-1
src/app/series/[seriesId]/opengraph-image.jsx
···
if (data.locked) return OGImageLocked({theme: theme})
const imageParams = await sanitizeData({type: 'series', data: data, props: defaults})
const theme = imageParams.theme
-
console.log(theme)
const baseFont = baseFonts[imageParams.baseFont].displayName
const titleFont = titleFonts[imageParams.titleFont].displayName
const opts = imageParams.opts
+7
src/app/works/[workId]/chapters/[chapterId]/page.js
···
// read route params
const { workId, chapterId } = await params
const work = await getWork({workId: workId, chapterId: chapterId})
+
if (work.locked) {
+
return {
+
title: 'Locked Work',
+
description: 'This but this work is locked to the public. Log in to see it!',
+
metadataBase: new URL('https://'+process.env.DOMAIN)
+
}
+
}
const parentWork = await getWork({workId: workId})
const authors = work.authors.map((a) => {
if (a.anonymous) {
+9 -2
src/app/works/[workId]/page.js
···
// read route params
const { workId, chapterId } = await params
const work = await getWork({workId: workId, chapterId: chapterId})
+
if (work.locked) {
+
return {
+
title: 'Locked Work',
+
description: 'This but this work is locked to the public. Log in to see it!',
+
metadataBase: new URL('https://'+process.env.DOMAIN)
+
}
+
}
const authors = work.authors.map((a) => {
if (a.anonymous) {
return "Anonymous"
···
const addr = `works/${workId}`
return {
-
title: title,
-
description: description,
+
title: title ? title : 'Locked Work',
+
description: description ? description : 'This but this work is locked to the public. Log in to see it!',
metadataBase: new URL('https://'+process.env.DOMAIN)
}
}