{"id":15635002,"url":"https://github.com/ije/html","last_synced_at":"2025-04-05T03:11:15.328Z","repository":{"id":40530369,"uuid":"496517202","full_name":"ije/html","owner":"ije","description":"Create `text/html` response with JSX.","archived":false,"fork":false,"pushed_at":"2025-03-03T01:18:32.000Z","size":71,"stargazers_count":146,"open_issues_count":4,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T02:07:56.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ije.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-26T07:06:19.000Z","updated_at":"2025-01-16T12:16:00.000Z","dependencies_parsed_at":"2025-01-31T08:10:41.351Z","dependency_job_id":"ad4b36e5-0bb4-4a11-b9de-efe59d89408c","html_url":"https://github.com/ije/html","commit_stats":{"total_commits":59,"total_committers":6,"mean_commits":9.833333333333334,"dds":"0.15254237288135597","last_synced_commit":"ec2556305f7d543139e1e557f0843647d054e6b2"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ije%2Fhtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ije%2Fhtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ije%2Fhtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ije%2Fhtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ije","download_url":"https://codeload.github.com/ije/html/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T10:59:54.158Z","updated_at":"2025-04-05T03:11:15.311Z","avatar_url":"https://github.com/ije.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Html\n\nCreate `text/html` response with JSX.\n\n## Usage\n\nTo use **Html**, create a `server.tsx` file like this:\n\n```tsx\n/** @jsx h */\nimport html, { h } from \"https://deno.land/x/htm@0.2.2/mod.ts\";\n\nDeno.serve((_req) =\u003e\n  html({\n    lang: \"en\",\n    title: \"Hello World!\",\n    meta: {\n      description: \"This is a description.\",\n    },\n    links: [\n      { rel: \"mask-icon\", href: \"/logo.svg\", color: \"#ffffff\" },\n    ],\n    styles: [\n      `div { display: flex; }`,\n    ],\n    scripts: [\n      `console.log(\"Hello World!\")`,\n    ],\n    body: (\n      \u003cdiv\u003e\n        \u003ch1\u003eHello World!\u003c/h1\u003e\n      \u003c/div\u003e\n    ),\n  })\n);\n```\n\n**Run the server**:\n\n```bash\ndeno run --allow-net server.tsx\n```\n\n**Try it online**:\n\nhttps://dash.deno.com/playground/hello-world-jsx\n\n## Using Plugin\n\n**Html** implements a simple plugin system that allows you to hook into the\nrendering process and modify the context.\n\n```ts\nimport html from \"https://deno.land/x/htm@0.2.2/mod.ts\";\n\n// add a script to the context\nhtml.use((ctx) =\u003e {\n  ctx.scripts.push(`console.log(\"Hello plugin!\")`);\n});\n```\n\nWe provide `Unocss` and `ColorScheme` plugins in the repository. For example,\nuse the **Unocss** plugin:\n\n```tsx\n/** @jsx h */\nimport html from \"https://deno.land/x/htm@0.2.2/mod.ts\";\nimport UnoCSS from \"https://deno.land/x/htm@0.2.2/plugins/unocss.ts\";\n\n// with default tailwind preset\nhtml.use(UnoCSS());\n\n// customize Unocss\nhtml.use(UnoCSS({\n  presets: [/* put your presets here. */],\n  // other unocss configurations check https://github.com/unocss/unocss#configurations\n}));\n\nhtml(\n  \u003cdiv class=\"text-5xl font-bold text-green-600\"\u003eHello World!\u003c/div\u003e,\n);\n```\n\nUse the **ColorScheme** plugin:\n\n```tsx\n/** @jsx h */\nimport html, { h } from \"https://deno.land/x/htm@0.2.2/mod.ts\";\nimport ColorScheme from \"https://deno.land/x/htm@0.2.2/plugins/color-scheme.ts\";\n\n// check the color scheme with system settings automatically\nhtml.use(ColorScheme(\"auto\"));\n\n// dark scheme\nhtml.use(ColorScheme(\"dark\"));\n```\n\nYou can call the `window.setColorScheme` helper function to set the color scheme\nin client when the `colorScheme` option is set to `auto`:\n\n```tsx\nhtml(\n  \u003cbutton class=\"dark:text-white\" onclick=\"setColorScheme('dark')\"\u003e\n    Dark Mode\n  \u003c/button\u003e,\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fije%2Fhtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fije%2Fhtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fije%2Fhtml/lists"}