-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31e7499
commit f01f06f
Showing
5 changed files
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Hi | ||
|
||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Hi | ||
|
||
index.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
import { resolve, join } from "path"; | ||
import { readFileSync } from "fs"; | ||
|
||
type Data = { | ||
content: string; | ||
}; | ||
|
||
type Error = { | ||
error: string; | ||
}; | ||
|
||
export default function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse<Data | Error> | ||
) { | ||
if (req.method === "GET") { | ||
const { slugs } = req.query; | ||
const slug = typeof slugs === "string" ? slugs : slugs[0]; | ||
|
||
const templateDirectory = resolve(process.cwd(), "extensions"); | ||
const emailTemplate = readFileSync( | ||
join(templateDirectory, slug, "index.md"), | ||
"utf8" | ||
); | ||
return res.status(200).json({ | ||
content: emailTemplate, | ||
}); | ||
} else { | ||
return res.status(404).json({ | ||
error: "Not Support Method", | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters