2022-11-09 21:38:05 -05:00
|
|
|
// a nextjs api handerl
|
|
|
|
|
|
|
|
import config from "@lib/config"
|
2022-11-12 19:06:23 -05:00
|
|
|
import { getHtmlFromMarkdown } from "@lib/remark-plugins"
|
|
|
|
import { getHtmlFromFile } from "@lib/server/get-html-from-drift-file"
|
|
|
|
import markdown from "@wcj/markdown-to-html"
|
|
|
|
|
2022-11-09 21:38:05 -05:00
|
|
|
import { NextApiRequest, NextApiResponse } from "next"
|
|
|
|
|
|
|
|
export const getWelcomeContent = async () => {
|
|
|
|
const introContent = config.welcome_content
|
|
|
|
const introTitle = config.welcome_title
|
2022-11-12 19:06:23 -05:00
|
|
|
|
2022-11-09 21:38:05 -05:00
|
|
|
return {
|
|
|
|
title: introTitle,
|
|
|
|
content: introContent,
|
2022-11-12 19:06:23 -05:00
|
|
|
rendered: await getHtmlFromFile({
|
|
|
|
title: `intro.md`,
|
|
|
|
content: introContent
|
|
|
|
})
|
2022-11-09 21:38:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-12 19:06:23 -05:00
|
|
|
export default async function handler(_: NextApiRequest, res: NextApiResponse) {
|
2022-11-09 21:38:05 -05:00
|
|
|
const welcomeContent = await getWelcomeContent()
|
|
|
|
if (!welcomeContent) {
|
|
|
|
return res.status(500).json({ error: "Missing welcome content" })
|
|
|
|
}
|
|
|
|
|
|
|
|
return res.json(welcomeContent)
|
|
|
|
}
|