@kaathewise/ssg 0.4.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,23 +1,29 @@
1
1
  {
2
2
  "name": "@kaathewise/ssg",
3
3
  "description": "Bun & JSX static site generator",
4
- "version": "0.4.1",
4
+ "version": "0.5.2",
5
5
  "license": "MPL-2.0",
6
6
  "author": "Andrej Kolčin",
7
7
  "type": "module",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kaathewisegit/ssg.git"
11
+ },
8
12
  "scripts": {
9
13
  "check": "biome check && tsc --noEmit"
10
14
  },
11
15
  "main": "src/index.ts",
12
- "bin": "./src/run.ts",
16
+ "bin": {
17
+ "ssg": "src/run.ts"
18
+ },
19
+ "files": [
20
+ "src"
21
+ ],
13
22
  "devDependencies": {
14
23
  "@biomejs/biome": "^2.2.3",
15
24
  "@types/bun": "^1.2.21",
16
25
  "@types/node": "^24.3.1",
17
26
  "typescript": "^5.9.2",
18
27
  "typescript-language-server": "^4.4.0"
19
- },
20
- "dependencies": {
21
- "postcss": "^8.5.6"
22
28
  }
23
29
  }
package/src/build.ts CHANGED
@@ -26,7 +26,7 @@ export async function build(config: Config) {
26
26
  })
27
27
  }
28
28
  const file = Bun.file(destPath)
29
- await write(file, page.html)
29
+ await write(file, page.src)
30
30
  }
31
31
 
32
32
  if (config.assetDir) {
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export { build } from "./build"
2
2
  export { type Config, defineConfig } from "./config"
3
- export { postcssPlugin } from "./css"
4
3
  export { serve } from "./server"
package/src/render.ts CHANGED
@@ -6,7 +6,7 @@ interface Params {
6
6
 
7
7
  export type Page = {
8
8
  path: string
9
- html: string
9
+ src: string
10
10
  contentType: string | null
11
11
  }
12
12
 
@@ -22,7 +22,22 @@ export async function render(
22
22
  contentType = module.getContentType()
23
23
  }
24
24
 
25
- const html = await module.default(params)
25
+ const def = module.default
26
+
27
+ let src: string
28
+ switch (typeof def) {
29
+ case "string": {
30
+ src = def
31
+ break
32
+ }
33
+ case "function": {
34
+ src = await def(params)
35
+ break
36
+ }
37
+ default: {
38
+ throw "Not implemented"
39
+ }
40
+ }
26
41
 
27
42
  let pagePath = path.relative(pagesDir, modulePath)
28
43
  pagePath = substituteParams(pagePath, params)
@@ -31,7 +46,7 @@ export async function render(
31
46
  pagePath += ".html"
32
47
  }
33
48
 
34
- return { path: pagePath, html, contentType }
49
+ return { path: pagePath, src, contentType }
35
50
  }
36
51
 
37
52
  export async function renderAll(
package/src/server.ts CHANGED
@@ -127,7 +127,7 @@ async function createHtml(
127
127
  ): Promise<Response> {
128
128
  const page = await render(route.filePath, pagesDir, route.params)
129
129
 
130
- const response = new Response(page.html, {
130
+ const response = new Response(page.src, {
131
131
  headers: {
132
132
  "Content-Type": page.contentType ?? "text/html",
133
133
  },
package/biome.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "files": {
3
- "includes": ["*.json", "src/**/*.ts"]
4
- },
5
- "javascript": {
6
- "formatter": {
7
- "enabled": true,
8
- "indentWidth": 8,
9
- "lineWidth": 80,
10
- "semicolons": "asNeeded",
11
- "arrowParentheses": "asNeeded"
12
- }
13
- },
14
- "json": {
15
- "formatter": {
16
- "enabled": true,
17
- "indentWidth": 8,
18
- "indentStyle": "tab"
19
- }
20
- }
21
- }
package/src/css.ts DELETED
@@ -1,32 +0,0 @@
1
- import type { BunPlugin, OnLoadArgs, OnLoadResult } from "bun"
2
- import postcss from "postcss"
3
-
4
- export function postcssPlugin(config: {
5
- plugins?: postcss.Plugin[]
6
- }): BunPlugin {
7
- return {
8
- name: "bun-postcss",
9
-
10
- async setup(build) {
11
- const processor = postcss(config?.plugins ?? [])
12
-
13
- async function apply(
14
- args: OnLoadArgs,
15
- ): Promise<OnLoadResult> {
16
- const raw = await Bun.file(args.path).text()
17
-
18
- const result = await processor.process(raw, {
19
- from: args.path,
20
- })
21
- const css = result.css
22
-
23
- return {
24
- exports: { default: css },
25
- loader: "object",
26
- }
27
- }
28
-
29
- build.onLoad({ filter: /\.css$/ }, apply)
30
- },
31
- }
32
- }
package/tsconfig.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": ["ESNext"],
5
- "target": "ESNext",
6
- "module": "Preserve",
7
- "moduleDetection": "force",
8
- "allowJs": true,
9
-
10
- // Bundler mode
11
- "moduleResolution": "bundler",
12
- "allowImportingTsExtensions": true,
13
- "verbatimModuleSyntax": true,
14
- "noEmit": true,
15
-
16
- // Best practices
17
- "strict": true,
18
- "skipLibCheck": true,
19
- "noFallthroughCasesInSwitch": true,
20
- "noUncheckedIndexedAccess": true,
21
- "noImplicitOverride": true,
22
-
23
- // Some stricter flags (disabled by default)
24
- "noUnusedLocals": false,
25
- "noUnusedParameters": false,
26
- "noPropertyAccessFromIndexSignature": false
27
- }
28
- }