2024-01-11 22:04:49 +01:00
|
|
|
import { toSSG as baseToSSG } from '../../helper/ssg/index.ts'
|
|
|
|
import type { FileSystemModule, ToSSGAdaptorInterface } from '../../helper/ssg/index.ts'
|
|
|
|
|
2024-01-13 19:55:04 +01:00
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
* `denoFileSystemModule` is an experimental feature.
|
|
|
|
* The API might be changed.
|
|
|
|
*/
|
2024-01-11 22:04:49 +01:00
|
|
|
export const denoFileSystemModule: FileSystemModule = {
|
|
|
|
writeFile: async (path, data) => {
|
2024-01-19 03:38:09 +01:00
|
|
|
const uint8Data =
|
|
|
|
typeof data === 'string' ? new TextEncoder().encode(data) : new Uint8Array(data)
|
2024-01-11 22:04:49 +01:00
|
|
|
await Deno.writeFile(path, uint8Data)
|
|
|
|
},
|
|
|
|
mkdir: async (path, options) => {
|
|
|
|
return Deno.mkdir(path, { recursive: options?.recursive ?? false })
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-13 19:55:04 +01:00
|
|
|
/**
|
|
|
|
* @experimental
|
|
|
|
* `toSSG` is an experimental feature.
|
|
|
|
* The API might be changed.
|
|
|
|
*/
|
2024-01-11 22:04:49 +01:00
|
|
|
export const toSSG: ToSSGAdaptorInterface = async (app, options) => {
|
|
|
|
return baseToSSG(app, denoFileSystemModule, options)
|
|
|
|
}
|