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
··· 1 - import { getSeries } from "@fujocoded/ao3.js" 2 - import sanitizeData from "@/lib/sanitizeData.js" 3 - import OGImage from "@/lib/ogimage.js" 4 - import baseFonts from "@/lib/baseFonts.js" 5 - import titleFonts from "@/lib/titleFonts.js" 6 - 7 - export const size = { 8 - width: 1600, 9 - height: 900, 10 - } 11 - 12 - export const contentType = 'image/webp' 13 - 14 - export async function GET(req, ctx) { 15 - const { seriesId } = await ctx.params 16 - const props = await req.nextUrl.searchParams 17 - const addr = `series/${seriesId}` 18 - const data = await getSeries({seriesId: seriesId}) 19 - const imageParams = await sanitizeData({type: 'series', data: data, props: props}) 20 - const theme = imageParams.theme 21 - const baseFont = baseFonts[imageParams.baseFont].displayName 22 - const titleFont = titleFonts[imageParams.titleFont].displayName 23 - const opts = imageParams.opts 24 - return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts}) 25 - }
-25
src/app/works/[workId]/chapters/[chapterId]/preview/route.js
··· 1 - import { getWork } from "@fujocoded/ao3.js" 2 - import sanitizeData from "@/lib/sanitizeData.js" 3 - import OGImage from "@/lib/ogimage.js" 4 - import baseFonts from "@/lib/baseFonts.js" 5 - import titleFonts from "@/lib/titleFonts.js" 6 - 7 - export const size = { 8 - width: 1600, 9 - height: 900, 10 - } 11 - 12 - export const contentType = 'image/webp' 13 - 14 - export async function GET(req, ctx) { 15 - const { workId, chapterId } = await ctx.params 16 - const props = await req.nextUrl.searchParams 17 - const addr = `works/${workId}/chapters/${chapterId}` 18 - const data = await getWork({workId: workId, chapterId: chapterId}) 19 - const imageParams = await sanitizeData({type: 'work', data: data, props: props}) 20 - const theme = imageParams.theme 21 - const baseFont = baseFonts[imageParams.baseFont].displayName 22 - const titleFont = titleFonts[imageParams.titleFont].displayName 23 - const opts = imageParams.opts 24 - return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts}) 25 - }
-25
src/app/works/[workId]/preview/route.js
··· 1 - import { getWork } from "@fujocoded/ao3.js" 2 - import sanitizeData from "@/lib/sanitizeData.js" 3 - import OGImage from "@/lib/ogimage.js" 4 - import baseFonts from "@/lib/baseFonts.js" 5 - import titleFonts from "@/lib/titleFonts.js" 6 - 7 - export const size = { 8 - width: 1600, 9 - height: 900, 10 - } 11 - 12 - export const contentType = 'image/webp' 13 - 14 - export async function GET(req, ctx) { 15 - const { workId } = await ctx.params 16 - const props = await req.nextUrl.searchParams 17 - const addr = `works/${workId}` 18 - const data = await getWork({workId: workId}) 19 - const imageParams = await sanitizeData({type: 'work', data: data, props: props}) 20 - const theme = imageParams.theme 21 - const baseFont = baseFonts[imageParams.baseFont].displayName 22 - const titleFont = titleFonts[imageParams.titleFont].displayName 23 - const opts = imageParams.opts 24 - return OGImage({theme: theme, baseFont: baseFont, titleFont: titleFont, image: imageParams, addr: addr, opts: opts}) 25 - }