redirecter for ao3 that adds opengraph metadata

move stuff to opengraph-image.jsx cards

Changed files
-75
src
app
series
[seriesId]
preview
works
[workId]
chapters
[chapterId]
preview
preview
-25
src/app/series/[seriesId]/preview/route.js
···
-
import { getSeries } from "@fujocoded/ao3.js"
-
import sanitizeData from "@/lib/sanitizeData.js"
-
import OGImage from "@/lib/ogimage.js"
-
import baseFonts from "@/lib/baseFonts.js"
-
import titleFonts from "@/lib/titleFonts.js"
-
-
export const size = {
-
width: 1600,
-
height: 900,
-
}
-
-
export const contentType = 'image/webp'
-
-
export async function GET(req, ctx) {
-
const { seriesId } = await ctx.params
-
const props = await req.nextUrl.searchParams
-
const addr = `series/${seriesId}`
-
const data = await getSeries({seriesId: seriesId})
-
const imageParams = await sanitizeData({type: 'series', data: data, props: props})
-
const theme = imageParams.theme
-
const baseFont = baseFonts[imageParams.baseFont].displayName
-
const titleFont = titleFonts[imageParams.titleFont].displayName
-
const opts = imageParams.opts
-
return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts})
-
}
-25
src/app/works/[workId]/chapters/[chapterId]/preview/route.js
···
-
import { getWork } from "@fujocoded/ao3.js"
-
import sanitizeData from "@/lib/sanitizeData.js"
-
import OGImage from "@/lib/ogimage.js"
-
import baseFonts from "@/lib/baseFonts.js"
-
import titleFonts from "@/lib/titleFonts.js"
-
-
export const size = {
-
width: 1600,
-
height: 900,
-
}
-
-
export const contentType = 'image/webp'
-
-
export async function GET(req, ctx) {
-
const { workId, chapterId } = await ctx.params
-
const props = await req.nextUrl.searchParams
-
const addr = `works/${workId}/chapters/${chapterId}`
-
const data = await getWork({workId: workId, chapterId: chapterId})
-
const imageParams = await sanitizeData({type: 'work', data: data, props: props})
-
const theme = imageParams.theme
-
const baseFont = baseFonts[imageParams.baseFont].displayName
-
const titleFont = titleFonts[imageParams.titleFont].displayName
-
const opts = imageParams.opts
-
return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts})
-
}
-25
src/app/works/[workId]/preview/route.js
···
-
import { getWork } from "@fujocoded/ao3.js"
-
import sanitizeData from "@/lib/sanitizeData.js"
-
import OGImage from "@/lib/ogimage.js"
-
import baseFonts from "@/lib/baseFonts.js"
-
import titleFonts from "@/lib/titleFonts.js"
-
-
export const size = {
-
width: 1600,
-
height: 900,
-
}
-
-
export const contentType = 'image/webp'
-
-
export async function GET(req, ctx) {
-
const { workId } = await ctx.params
-
const props = await req.nextUrl.searchParams
-
const addr = `works/${workId}`
-
const data = await getWork({workId: workId})
-
const imageParams = await sanitizeData({type: 'work', data: data, props: props})
-
const theme = imageParams.theme
-
const baseFont = baseFonts[imageParams.baseFont].displayName
-
const titleFont = titleFonts[imageParams.titleFont].displayName
-
const opts = imageParams.opts
-
return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts})
-
}