-
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
e305103
commit 23d96a9
Showing
11 changed files
with
140 additions
and
17 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,57 @@ | ||
/** @jsx jsx */ | ||
/** @jsxFrag Fragment */ | ||
|
||
import { toSSG } from '../../deno_dist/middleware.ts' | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import { jsx } from '../../deno_dist/middleware.ts' | ||
import { Hono } from '../../deno_dist/mod.ts' | ||
import { assertEquals } from '../deno/deps.ts' | ||
|
||
Deno.test('toSSG function', async () => { | ||
const app = new Hono() | ||
app.get('/', (c) => c.text('Hello, World!')) | ||
app.get('/about', (c) => c.text('About Page')) | ||
app.get('/about/some', (c) => c.text('About Page 2tier')) | ||
app.post('/about/some/thing', (c) => c.text('About Page 3tier')) | ||
app.get('/bravo', (c) => c.html('Bravo Page')) | ||
app.get('/Charlie', async (c, next) => { | ||
c.setRenderer((content) => { | ||
return c.html( | ||
<html> | ||
<body> | ||
<p>{content}</p> | ||
</body> | ||
</html> | ||
) | ||
}) | ||
await next() | ||
}) | ||
app.get('/Charlie', (c) => { | ||
return c.render('Hello!') | ||
}) | ||
|
||
const result = await toSSG(app, { dir: './ssg-static' }) | ||
assertEquals(result.success, true) | ||
assertEquals(result.error, undefined) | ||
assertEquals(result.files !== undefined, true) | ||
|
||
await deleteDirectory('./ssg-static') | ||
}) | ||
|
||
async function deleteDirectory(dirPath: string): Promise<void> { | ||
try { | ||
const stat = await Deno.stat(dirPath) | ||
|
||
if (stat.isDirectory) { | ||
for await (const dirEntry of Deno.readDir(dirPath)) { | ||
const entryPath = `${dirPath}/${dirEntry.name}` | ||
await deleteDirectory(entryPath) | ||
} | ||
await Deno.remove(dirPath) | ||
} else { | ||
await Deno.remove(dirPath) | ||
} | ||
} catch (error) { | ||
console.error(`Error deleting directory: ${error}`) | ||
} | ||
} |
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
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
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
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