redirecter for ao3 that adds opengraph metadata

fix issue with metadata collation from other archives

Changed files
+4 -3
src
app
works
[workId]
preview
lib
+1
src/app/works/[workId]/preview/route.js
···
const work = await fetch(`http://${process.env.DOMAIN}/api/works/${workId}${domainParam}`)
const data = await work.json()
const imageParams = await sanitizeData({type: 'work', data: data, props: props})
+
console.log(imageParams)
const theme = imageParams.theme
const baseFont = baseFonts[imageParams.baseFont].displayName
const titleFont = titleFonts[imageParams.titleFont].displayName
+3 -3
src/lib/sanitizeData.js
···
const getHighestWarning = async (works, archive = null) => {
const warnings = await Promise.all(works.map(async (w) => {
-
const work = await getWork(w.id)
+
const work = await getWork(w.id, archive)
return work.tags.warnings
}))
const warningsUnique = warnings.reduce((a, b) => { return a.concat(b) }).filter((w, i) => { return i === warnings.indexOf(w) })
···
const getCategory = async (works, archive = null) => {
const categories = await Promise.all(works.map(async (w) => {
-
const work = await getWork(w.id)
+
const work = await getWork(w.id, archive)
return work.category
}))
const categoriesJoined = categories.reduce((a, b) => { return a.concat(b) })
···
const titleFont = propsParsed.titleFont ? propsParsed.titleFont : process.env.DEFAULT_TITLE_FONT
const titleFontData = titleFonts[titleFont]
const themeData = propsParsed.theme ? themes[propsParsed.theme] : themes[process.env.DEFAULT_THEME]
-
const parentWork = type === 'work' && data.chapterInfo ? await getWork(data.id) : null
+
const parentWork = type === 'work' && data.chapterInfo ? await getWork(data.id, archive) : null
const bfs = await Promise.all(baseFontData.defs.map(async (bf) => {
return {
name: baseFontData.displayName,