hono icon indicating copy to clipboard operation
hono copied to clipboard

Proposal for SSGResultDetails

Open watany-dev opened this issue 1 year ago • 3 comments

What is the feature you are proposing?

When debugging files created by toSSG, it is not practical to check all the routes registered in app. I believe we should provide a way to know which routes have succeeded, failed, or skipped.

interface SSGResultPaths {
  successfulPaths: string[];
  failedPaths: { path: string; error: Error }[];
  excludedPaths: string[];
}

interface ToSSGResult {
  success: boolean;
  files: string[];
  error?: Error;
  paths: SSGResultPaths;
}

If you agree with this I will create it.

watany-dev avatar Jan 24 '24 04:01 watany-dev

There may be a cooler way to do this, but you could also make a hybridapp like this.

const dir = './static'
const result = toSSG(app, fs, { dir });
export const successfulPaths = result.paths?.successfulPaths || [];

import { successfulPath } from ′./build′

const hybridApp = new Hono()
successfulPaths.forEach(path => {
  hybridApp.get(`${path}`, serveStatic({ root: dir }))
})

watany-dev avatar Jan 24 '24 07:01 watany-dev

It may be a bit wasteful in its usage with respect to this purpose. Since it is necessary to create a wrapper function for fetchRouteContent, such as scanSSGRoute, to skip file writing or to reduce waste, we should separate the story again and only consider whether the first debugging usage is necessary.

watany-dev avatar Jan 24 '24 14:01 watany-dev

Hi @watany-dev

I think SSGResultPaths is not bad, and I can imagine the use case of a "hybrid app." Also, I don't think the implementation will be that complicated.

yusukebe avatar Jan 25 '24 21:01 yusukebe