0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00
hono/deno_dist/adapter/deno/ssg.ts
watany 23d96a9b08
refactor(ssg): Removal of Libraries Dependent on Node.js (#2012)
* remove Buffer

* fix

* fix

* type Bun

* test import

* fix & rename

* move a ssg test for deno

* import jsx

* console.log

* update CI

* revert toAbcSSG name

* rename

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2024-01-19 11:38:09 +09:00

28 lines
846 B
TypeScript

import { toSSG as baseToSSG } from '../../helper/ssg/index.ts'
import type { FileSystemModule, ToSSGAdaptorInterface } from '../../helper/ssg/index.ts'
/**
* @experimental
* `denoFileSystemModule` is an experimental feature.
* The API might be changed.
*/
export const denoFileSystemModule: FileSystemModule = {
writeFile: async (path, data) => {
const uint8Data =
typeof data === 'string' ? new TextEncoder().encode(data) : new Uint8Array(data)
await Deno.writeFile(path, uint8Data)
},
mkdir: async (path, options) => {
return Deno.mkdir(path, { recursive: options?.recursive ?? false })
},
}
/**
* @experimental
* `toSSG` is an experimental feature.
* The API might be changed.
*/
export const toSSG: ToSSGAdaptorInterface = async (app, options) => {
return baseToSSG(app, denoFileSystemModule, options)
}