diff --git a/src/helper/ssg/ssg.test.tsx b/src/helper/ssg/ssg.test.tsx index 275f64754..3eb0cecd9 100644 --- a/src/helper/ssg/ssg.test.tsx +++ b/src/helper/ssg/ssg.test.tsx @@ -161,7 +161,18 @@ describe('toSSG function', () => { }) it('Should correctly generate files with the expected paths', async () => { - await toSSG(app, fsMock, { dir: './static' }) + app.get('/data', (c) => + c.text(JSON.stringify({ title: 'hono' }), 200, { + 'Content-Type': 'text/x-foo', + }) + ) + await toSSG(app, fsMock, { + dir: './static', + extensionMap: { + ...defaultExtensionMap, + 'text/x-foo': 'foo', + }, + }) expect(fsMock.writeFile).toHaveBeenCalledWith('static/index.html', expect.any(String)) expect(fsMock.writeFile).toHaveBeenCalledWith('static/about.html', expect.any(String)) @@ -173,6 +184,7 @@ describe('toSSG function', () => { expect(fsMock.writeFile).toHaveBeenCalledWith('static/about.html', expect.any(String)) expect(fsMock.writeFile).toHaveBeenCalledWith('static/bravo.html', expect.any(String)) expect(fsMock.writeFile).toHaveBeenCalledWith('static/Charlie.html', expect.any(String)) + expect(fsMock.writeFile).toHaveBeenCalledWith('static/data.foo', expect.any(String)) }) it('should modify the request if the hook is provided', async () => { diff --git a/src/helper/ssg/ssg.ts b/src/helper/ssg/ssg.ts index 3e3fd2836..5d9843ef0 100644 --- a/src/helper/ssg/ssg.ts +++ b/src/helper/ssg/ssg.ts @@ -360,7 +360,9 @@ export const toSSG: ToSSGInterface = async (app, fs, options) => { return } for (const content of getContentGen) { - savePromises.push(saveContentToFile(content, fs, outputDir).catch((e) => e)) + savePromises.push( + saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e) + ) } }) )