{"_id":"@adbl/unfinished-ssg","_rev":"4-1078de152807a3f0a323351f1de95ee1","name":"@adbl/unfinished-ssg","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"@adbl/unfinished-ssg","version":"0.0.1","_id":"@adbl/unfinished-ssg@0.0.1","maintainers":[{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"}],"dist":{"shasum":"3bce26fcf7dad401900b7b3ff4381c595bd35c9f","tarball":"https://registry.npmjs.org/@adbl/unfinished-ssg/-/unfinished-ssg-0.0.1.tgz","fileCount":15,"integrity":"sha512-dkf2wW++cbCHOinVrNagBqK/LEwL6GZ3fo88ydyihwAa2QrSIZL7VugoiLp8cVXHM60mvKg+lj6Fowr43VHSyA==","signatures":[{"sig":"MEUCIQDaNEb4pBDj/0NFWFrwxQZmcRi92NULfeJ+pY1ZMAQ/lgIgBIb+JDgPQO7gQEOwv8iJ7f4ZKpdpSdRmzPXLW3mhk4o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39557},"type":"module","exports":{"./types":{"types":"./dist/types.d.ts","import":"./dist/types.js"},"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./plugin":{"types":"./dist/plugin.d.ts","import":"./dist/plugin.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"gitHead":"8f7134bd975dec4f296bf33dc3c3d2d98fbd4072","private":false,"scripts":{"build":"node scripts/build.js"},"_npmUser":{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"},"_npmVersion":"10.9.0","description":"Static site generation for the unfinished UI framework.","directories":{},"_nodeVersion":"23.1.0","dependencies":{"domhandler":"^5.0.3","htmlparser2":"^10.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.4.14","typescript":"^5.8.2"},"peerDependencies":{"@adbl/unfinished":"0.0.15"},"_npmOperationalInternal":{"tmp":"tmp/unfinished-ssg_0.0.1_1741366879166_0.9792196618045919","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@adbl/unfinished-ssg","version":"0.0.2","_id":"@adbl/unfinished-ssg@0.0.2","maintainers":[{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"}],"dist":{"shasum":"5b7735ecd3566180a1f046ecbbd86249d1148b6e","tarball":"https://registry.npmjs.org/@adbl/unfinished-ssg/-/unfinished-ssg-0.0.2.tgz","fileCount":15,"integrity":"sha512-Xlnubejpc7PFlgRKDpTWJUxRp7RR1DUdHklqFA/L8RvMsmhZBLbyLvi7nVEfVDlJc2mPOCbPTzV/Rp7L8dillw==","signatures":[{"sig":"MEQCIG2CHqSpt+F8Hyh+J4IAN/XvGBXyn5DQ0KxzoKkX83i0AiAvTEFnDJn2TIaHCnN1wh/ObwJvYhpsXIGGNoP1ww0CIA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39557},"type":"module","exports":{"./types":{"types":"./dist/types.d.ts","import":"./dist/types.js"},"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./plugin":{"types":"./dist/plugin.d.ts","import":"./dist/plugin.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"gitHead":"2d77f446c5d49e5f3887d55692f8ed687ef6b3ee","private":false,"scripts":{"build":"node scripts/build.js"},"_npmUser":{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"},"_npmVersion":"10.9.0","description":"Static site generation for the unfinished UI framework.","directories":{},"_nodeVersion":"23.1.0","dependencies":{"domhandler":"^5.0.3","htmlparser2":"^10.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.4.14","typescript":"^5.8.2"},"peerDependencies":{"@adbl/unfinished":"0.0.16"},"_npmOperationalInternal":{"tmp":"tmp/unfinished-ssg_0.0.2_1741436680909_0.9883900319059349","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@adbl/unfinished-ssg","version":"0.0.3","_id":"@adbl/unfinished-ssg@0.0.3","maintainers":[{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"}],"dist":{"shasum":"799e97b8809aa6fbac65d78c27c1851faf204dd6","tarball":"https://registry.npmjs.org/@adbl/unfinished-ssg/-/unfinished-ssg-0.0.3.tgz","fileCount":15,"integrity":"sha512-HO8+athuDVDXNVr/C0yk4t/0FAh6PzVtN/iHqA/lNlLZOrShzJFMsOVVYFpMibIj4BCtzIR4WWa55QDU9YgO6g==","signatures":[{"sig":"MEYCIQDi4OaDipQZDIUv35+oi31Su2rQdDT6da7pgmGEhnzNlgIhAOIuslF83lAlbykEJZbvgHexs7eBlYKLPBRIn69Vtx6e","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39557},"type":"module","exports":{"./types":{"types":"./dist/types.d.ts","import":"./dist/types.js"},"./client":{"types":"./dist/client.d.ts","import":"./dist/client.js"},"./plugin":{"types":"./dist/plugin.d.ts","import":"./dist/plugin.js"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.js"}},"gitHead":"7ff8c1491647553a01f511d5a901ba7dbb893420","private":false,"scripts":{"build":"node scripts/build.js"},"_npmUser":{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"},"_npmVersion":"10.9.0","description":"Static site generation for the unfinished UI framework.","directories":{},"_nodeVersion":"23.1.0","dependencies":{"domhandler":"^5.0.3","htmlparser2":"^10.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^5.4.14","typescript":"^5.8.2"},"peerDependencies":{"@adbl/unfinished":"0.0.16"},"_npmOperationalInternal":{"tmp":"tmp/unfinished-ssg_0.0.3_1741438590634_0.5243308253395262","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@adbl/unfinished-ssg","version":"0.0.4","description":"Static site generation for the unfinished UI framework.","private":false,"type":"module","scripts":{"build":"node scripts/build.js"},"dependencies":{"domhandler":"^5.0.3","htmlparser2":"^10.0.0"},"exports":{"./server":{"import":"./dist/server.js","types":"./dist/server.d.ts"},"./client":{"import":"./dist/client.js","types":"./dist/client.d.ts"},"./plugin":{"import":"./dist/plugin.js","types":"./dist/plugin.d.ts"},"./types":{"import":"./dist/types.js","types":"./dist/types.d.ts"}},"devDependencies":{"typescript":"^5.8.2","vite":"^5.4.14"},"peerDependencies":{"@adbl/unfinished":"0.0.16"},"publishConfig":{"access":"public"},"_id":"@adbl/unfinished-ssg@0.0.4","gitHead":"7ff8c1491647553a01f511d5a901ba7dbb893420","_nodeVersion":"23.1.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-FqNK6hxZjR3XiLgdhqJy9OZfW8FDe/203mprSb8Of0ec6iwX77hkOyHZDUBOrnxiP1Lb8hhvmo25MGN7tzQ8UQ==","shasum":"5f9324dc8bbeb95fd21c4edbc157988f3592743d","tarball":"https://registry.npmjs.org/@adbl/unfinished-ssg/-/unfinished-ssg-0.0.4.tgz","fileCount":15,"unpackedSize":39767,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICibPglwapY5IpzWAJhYEaddHQtsGCCCliUZx/KN0cHMAiAGyMsC1oA77r65vXMBzHCX9p+fo7InY8mDGEflVRk81g=="}]},"_npmUser":{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"},"directories":{},"maintainers":[{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unfinished-ssg_0.0.4_1741438907263_0.197238930294116"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-07T17:01:19.093Z","modified":"2025-03-08T13:01:47.676Z","0.0.1":"2025-03-07T17:01:19.378Z","0.0.2":"2025-03-08T12:24:41.117Z","0.0.3":"2025-03-08T12:56:30.830Z","0.0.4":"2025-03-08T13:01:47.486Z"},"description":"Static site generation for the unfinished UI framework.","maintainers":[{"name":"adebolaxyz","email":"adebolaakomolafe@gmail.com"}],"readme":"# unfinished-ssg (experimental)\n\n`unfinished-ssg` is a Vite plugin that enables **static site generation (SSG)** for applications built with the `@adbl/unfinished` library. It generates static HTML files for specified routes during the Vite build process, making your application suitable for static hosting while preserving reactivity and routing capabilities.\n\nThis plugin is ideal for projects requiring fast initial load times, SEO optimization, and deployment to static hosting services like Netlify, Vercel, or GitHub Pages.\n\n> [!IMPORTANT]\n> This plugin is currently in an experimental stage and may undergo significant changes. Use with caution. APIs and functionality _will_ change without notice.\n\n## Installation\n\nTo get started with `unfinished-ssg`, install it as a development dependency in your Vite project:\n\n```bash\nnpm install --save-dev @adbl/unfinished-ssg\n```\n\n## Configuring the Plugin in Vite\n\nAdd the `unfinished-ssg` plugin to your Vite configuration file (`vite.config.js` or `vite.config.ts`) to enable static site generation. Below is a basic example:\n\n```javascript\nimport { defineConfig } from 'vite';\nimport unfinishedSSG from '@adbl/unfinished-ssg';\n\nexport default defineConfig({\n  plugins: [\n    unfinishedSSG({\n      pages: ['/', '/about', '/contact'],\n      routerModulePath: './src/router.js',\n    }),\n  ],\n});\n```\n\n### Configuration Options\n\n- **`pages`** (Required)\n\n  - Type: `string[]`\n  - Description: An array of routes to generate static HTML files for.\n  - Example: `['/', '/about', '/contact']`\n\n- **`routerModulePath`** (Required)\n\n  - Type: `string`\n  - Description: The file path to the module exporting your `createRouter` function, which defines your application's routing logic.\n  - Example: `'./src/router.js'`\n\n### Updating the Application Entry Point\n\nTo make your static HTML interactive, update your application’s entry point (e.g., `src/main.js`) to use the `hydrate` function from `@adbl/unfinished-ssg/client`. This step ensures your application becomes fully functional on the client side after the static content is loaded.\n\n### Example: Application Entry Point (`src/main.js`)\n\n```javascript\nimport { hydrate } from '@adbl/unfinished-ssg/client';\nimport { createRouter } from './router';\n\nhydrate(createRouter)\n  .then(() => {\n    console.log('Application successfully hydrated!');\n  })\n  .catch((error) => {\n    console.error('Hydration failed:', error);\n  });\n\n// Listen for the hydrationcompleted event to perform additional tasks\nwindow.addEventListener('hydrationcompleted', () => {\n  console.log('Hydration is complete, and the app is fully interactive.');\n  // Add post-hydration logic here, like initializing analytics or other scripts\n});\n```\n\nThe `hydrationcompleted` event fires when hydration finishes, allowing you to execute additional logic (e.g., loading third-party scripts or tracking analytics) once the app is fully interactive.\n\nAfter configuring the plugin, run the Vite build command to generate static HTML files in the output directory (typically `dist`):\n\n```bash\nvite build\n```\n\n## Example Setup\n\nHere’s a complete example to tie it all together.\n\n### Router Definition (`src/router.js`)\n\n```javascript\nimport { createWebRouter } from '@adbl/unfinished/router';\nimport Home from './Home';\nimport About from './About';\nimport Contact from './Contact';\n\nexport function createRouter() {\n  return createWebRouter({\n    routes: [\n      { path: '/', component: Home },\n      { path: '/about', component: About },\n      { path: '/contact', component: Contact },\n    ],\n  });\n}\n```\n\n### Vite Configuration (`vite.config.js`)\n\n```javascript\nimport { defineConfig } from 'vite';\nimport unfinishedSSG from '@adbl/unfinished-ssg';\n\nexport default defineConfig({\n  plugins: [\n    unfinishedSSG({\n      pages: ['/', '/about', '/contact'],\n      routerModulePath: './src/router.js',\n    }),\n  ],\n});\n```\n\nRunning `vite build` generates static HTML files (`index.html`, `about.html`, `contact.html`) in the `dist` directory, each pre-rendered with the content for its route.\n\n## Handling Redirects\n\nIf your router includes redirects (e.g., from `/old-path` to `/new-path`), the plugin generates additional HTML files with meta refresh tags. For example:\n\n- A redirect from `/old-path` to `/new-path` creates `old-path.html`, redirecting to `new-path.html`.\n\nThis ensures redirects work seamlessly in a static hosting environment.\n\n## Development vs. Production\n\n- **Development Mode**: When running `vite dev` (`import.meta.env.DEV` is `true`), the `hydrate` function switches to single-page application (SPA) mode, rendering the app client-side without server-side rendering for faster development.\n- **Production Mode**: After `vite build`, the `hydrate` function uses the pre-rendered HTML, enabling fast initial loads and better SEO.\n\n## Deployment\n\nOnce built, deploy the `dist` directory to any static hosting service, such as:\n\n- GitHub Pages\n- Netlify\n- Vercel\n\nFor static routes, no additional server setup is needed. For dynamic routes (e.g., `/post/:id`), list all possible paths in the `pages` array (e.g., `['/post/1', '/post/2']`).\n\n## Prerequisites\n\n- **Vite**: Required as the build tool.\n- **`@adbl/unfinished`**: The core library for your application.\n- **Router**: Must use `@adbl/unfinished/router`, exported from the module specified in `routerModulePath`.\n\n## Notes\n\n- Generated HTML files include scripts and styles as configured in your Vite build.\n- The plugin assumes your app uses `@adbl/unfinished` for routing and reactivity.\n\n## Documentation\n\nFor more on `@adbl/unfinished`, see the [main documentation](https://github.com/adebola-io/unfinished/blob/main/docs/README.md).\n\n## License\n\nLicensed under the MIT License. See the [LICENSE](https://github.com/adebola-io/unfinished/blob/main/LICENSE) file.\n\n## Contributing\n\nContributions are welcome! Check the [contributing guidelines](https://github.com/adebola-io/unfinished/blob/main/CONTRIBUTING.md) for details.\n","readmeFilename":"README.md"}