From 26d2d91789c3b582fe17321722dbc2cffa8e6829 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Mon, 4 Nov 2024 17:25:16 +0000 Subject: [PATCH 1/5] refactor files, fix up types, move over to jsr where possible --- {testdata => content}/cat.png | Bin testdata/my_blog.ts => content/main.tsx | 2 +- {testdata => content}/posts/fifth.md | 0 {testdata => content}/posts/first.md | 0 {testdata => content}/posts/first/hello.png | Bin {testdata => content}/posts/fourth.md | 0 {testdata => content}/posts/second.md | 0 {testdata => content}/posts/second/hello2.png | Bin {testdata => content}/posts/seventh.md | 0 {testdata => content}/posts/sixth.md | 0 {testdata => content}/posts/third.md | 0 .../posts/\344\270\255\346\226\207.md" | 0 deno.json | 26 ++ deno.jsonc | 7 - deno.lock | 402 ++++++++++++++++++ deps.ts | 42 -- init.ts | 2 +- mod.test.ts | 20 + mod.ts | 5 + blog_test.ts => src/blog.test.ts | 20 +- blog.tsx => src/blog.tsx | 58 +-- components.tsx => src/components.tsx | 5 +- types.d.ts | 8 +- 23 files changed, 504 insertions(+), 93 deletions(-) rename {testdata => content}/cat.png (100%) rename testdata/my_blog.ts => content/main.tsx (91%) rename {testdata => content}/posts/fifth.md (100%) rename {testdata => content}/posts/first.md (100%) rename {testdata => content}/posts/first/hello.png (100%) rename {testdata => content}/posts/fourth.md (100%) rename {testdata => content}/posts/second.md (100%) rename {testdata => content}/posts/second/hello2.png (100%) rename {testdata => content}/posts/seventh.md (100%) rename {testdata => content}/posts/sixth.md (100%) rename {testdata => content}/posts/third.md (100%) rename "testdata/posts/\344\270\255\346\226\207.md" => "content/posts/\344\270\255\346\226\207.md" (100%) create mode 100644 deno.json delete mode 100644 deno.jsonc create mode 100644 deno.lock delete mode 100644 deps.ts create mode 100644 mod.test.ts create mode 100644 mod.ts rename blog_test.ts => src/blog.test.ts (95%) rename blog.tsx => src/blog.tsx (92%) rename components.tsx => src/components.tsx (99%) diff --git a/testdata/cat.png b/content/cat.png similarity index 100% rename from testdata/cat.png rename to content/cat.png diff --git a/testdata/my_blog.ts b/content/main.tsx similarity index 91% rename from testdata/my_blog.ts rename to content/main.tsx index 92c5cff..38016f5 100644 --- a/testdata/my_blog.ts +++ b/content/main.tsx @@ -1,4 +1,4 @@ -import blog from "../blog.tsx"; +import blog from "../src/blog.tsx"; blog({ author: "Dino", diff --git a/testdata/posts/fifth.md b/content/posts/fifth.md similarity index 100% rename from testdata/posts/fifth.md rename to content/posts/fifth.md diff --git a/testdata/posts/first.md b/content/posts/first.md similarity index 100% rename from testdata/posts/first.md rename to content/posts/first.md diff --git a/testdata/posts/first/hello.png b/content/posts/first/hello.png similarity index 100% rename from testdata/posts/first/hello.png rename to content/posts/first/hello.png diff --git a/testdata/posts/fourth.md b/content/posts/fourth.md similarity index 100% rename from testdata/posts/fourth.md rename to content/posts/fourth.md diff --git a/testdata/posts/second.md b/content/posts/second.md similarity index 100% rename from testdata/posts/second.md rename to content/posts/second.md diff --git a/testdata/posts/second/hello2.png b/content/posts/second/hello2.png similarity index 100% rename from testdata/posts/second/hello2.png rename to content/posts/second/hello2.png diff --git a/testdata/posts/seventh.md b/content/posts/seventh.md similarity index 100% rename from testdata/posts/seventh.md rename to content/posts/seventh.md diff --git a/testdata/posts/sixth.md b/content/posts/sixth.md similarity index 100% rename from testdata/posts/sixth.md rename to content/posts/sixth.md diff --git a/testdata/posts/third.md b/content/posts/third.md similarity index 100% rename from testdata/posts/third.md rename to content/posts/third.md diff --git "a/testdata/posts/\344\270\255\346\226\207.md" "b/content/posts/\344\270\255\346\226\207.md" similarity index 100% rename from "testdata/posts/\344\270\255\346\226\207.md" rename to "content/posts/\344\270\255\346\226\207.md" diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..28fae66 --- /dev/null +++ b/deno.json @@ -0,0 +1,26 @@ +{ + "tasks": { + "dev": "deno run --allow-net --allow-read --allow-env=NODE_DEBUG,NO_COLOR,FORCE_COLOR,TERM --watch --no-check ./content/main.tsx --dev", + "test": "deno test --allow-net --allow-read --allow-env=NODE_DEBUG,NO_COLOR,FORCE_COLOR,TERM --no-check=remote", + "serve": "deno run --allow-net --allow-read --allow-env --no-check ./content/main.tsx" + }, + "imports": { + "@deno/gfm": "jsr:@deno/gfm@^0.10.0", + "@std/testing": "jsr:@std/testing@^1.0.4", + "@std/assert": "jsr:@std/assert@^1.0.7", + "@std/async": "jsr:@std/async@^1.0.8", + "@std/front-matter": "jsr:@std/front-matter@^1.0.5", + "@std/fs": "jsr:@std/fs@^1.0.5", + "@std/http": "jsr:@std/http@^1.0.9", + "@std/path": "jsr:@std/path@^1.0.8", + "@denoland/htm": "https://deno.land/x/htm@0.1.3/mod.ts", + "@denoland/htm/plugins/color-scheme": "https://deno.land/x/htm@0.1.3/plugins/color-scheme.ts", + "@denoland/htm/plugins/unocss": "https://deno.land/x/htm@0.1.3/plugins/unocss.ts", + "@denoland/g_a": "https://deno.land/x/g_a@0.1.2/mod.ts", + "@githubcontent/kt3k/callsites": "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts", + "@esm/feed": "https://esm.sh/feed@4.2.2", + "@esm/remove-markdown": "https://esm.sh/remove-markdown@0.5.0", + "@esm/prism-c": "https://esm.sh/prismjs@1.29.0/components/prism-c?no-check", + "@outdated/std-http": "https://deno.land/std@0.193.0/http/mod.ts" + } +} diff --git a/deno.jsonc b/deno.jsonc deleted file mode 100644 index 97f2e81..0000000 --- a/deno.jsonc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "lock": false, - "tasks": { - "demo": "deno run --allow-net --allow-read --allow-env=NODE_DEBUG --watch --no-check testdata/my_blog.ts --dev", - "test": "deno test --no-check=remote --allow-read" - } -} diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..8fc28b9 --- /dev/null +++ b/deno.lock @@ -0,0 +1,402 @@ +{ + "version": "4", + "specifiers": { + "jsr:@deno/gfm@0.10": "0.10.0", + "jsr:@denosaurs/emoji@0.3": "0.3.1", + "jsr:@std/assert@^1.0.7": "1.0.7", + "jsr:@std/async@^1.0.8": "1.0.8", + "jsr:@std/cli@^1.0.6": "1.0.6", + "jsr:@std/collections@^1.0.5": "1.0.9", + "jsr:@std/data-structures@^1.0.4": "1.0.4", + "jsr:@std/encoding@^1.0.5": "1.0.5", + "jsr:@std/fmt@^1.0.3": "1.0.3", + "jsr:@std/front-matter@^1.0.5": "1.0.5", + "jsr:@std/fs@^1.0.5": "1.0.5", + "jsr:@std/http@^1.0.9": "1.0.9", + "jsr:@std/internal@^1.0.5": "1.0.5", + "jsr:@std/media-types@^1.0.3": "1.0.3", + "jsr:@std/net@^1.0.4": "1.0.4", + "jsr:@std/path@^1.0.7": "1.0.8", + "jsr:@std/path@^1.0.8": "1.0.8", + "jsr:@std/streams@^1.0.7": "1.0.8", + "jsr:@std/testing@^1.0.4": "1.0.4", + "jsr:@std/toml@^1.0.1": "1.0.1", + "jsr:@std/yaml@^1.0.5": "1.0.5", + "npm:@types/node@*": "22.5.4", + "npm:github-slugger@2": "2.0.0", + "npm:he@^1.2.0": "1.2.0", + "npm:katex@0.16": "0.16.11", + "npm:marked-alert@2": "2.1.2_marked@12.0.2", + "npm:marked-footnote@^1.2.0": "1.2.4_marked@12.0.2", + "npm:marked-gfm-heading-id@^3.1.0": "3.2.0_marked@12.0.2", + "npm:marked@12": "12.0.2", + "npm:prismjs@^1.29.0": "1.29.0", + "npm:sanitize-html@^2.13.0": "2.13.1" + }, + "jsr": { + "@deno/gfm@0.10.0": { + "integrity": "51708205e3559a4aeb6afb29d07c5bfafe7941f91bb360351ef6621de9a39527", + "dependencies": [ + "jsr:@denosaurs/emoji", + "npm:github-slugger", + "npm:he", + "npm:katex", + "npm:marked", + "npm:marked-alert", + "npm:marked-footnote", + "npm:marked-gfm-heading-id", + "npm:prismjs", + "npm:sanitize-html" + ] + }, + "@denosaurs/emoji@0.3.1": { + "integrity": "b0aed5f55dec99e83da7c9637fe0a36d1d6252b7c99deaaa3fc5dea3fcf3da8b" + }, + "@std/assert@1.0.7": { + "integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/async@1.0.8": { + "integrity": "c057c5211a0f1d12e7dcd111ab430091301b8d64b4250052a79d277383bc3ba7" + }, + "@std/cli@1.0.6": { + "integrity": "d22d8b38c66c666d7ad1f2a66c5b122da1704f985d3c47f01129f05abb6c5d3d" + }, + "@std/collections@1.0.9": { + "integrity": "4f58104ead08a04a2199374247f07befe50ba01d9cca8cbb23ab9a0419921e71" + }, + "@std/data-structures@1.0.4": { + "integrity": "fa0e20c11eb9ba673417450915c750a0001405a784e2a4e0c3725031681684a0" + }, + "@std/encoding@1.0.5": { + "integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04" + }, + "@std/fmt@1.0.3": { + "integrity": "97765c16aa32245ff4e2204ecf7d8562496a3cb8592340a80e7e554e0bb9149f" + }, + "@std/front-matter@1.0.5": { + "integrity": "abddc64030a33eb5bc524b8c73e7c417cea09177aaeb4abf75a56b540c4b6e60", + "dependencies": [ + "jsr:@std/toml", + "jsr:@std/yaml" + ] + }, + "@std/fs@1.0.5": { + "integrity": "41806ad6823d0b5f275f9849a2640d87e4ef67c51ee1b8fb02426f55e02fd44e", + "dependencies": [ + "jsr:@std/path@^1.0.7" + ] + }, + "@std/http@1.0.9": { + "integrity": "d409fc319a5e8d4a154e576c758752e9700282d74f31357a12fec6420f9ecb6c", + "dependencies": [ + "jsr:@std/cli", + "jsr:@std/encoding", + "jsr:@std/fmt", + "jsr:@std/media-types", + "jsr:@std/net", + "jsr:@std/path@^1.0.7", + "jsr:@std/streams" + ] + }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + }, + "@std/media-types@1.0.3": { + "integrity": "b12d30a7852f7578f4d210622df713bbfd1cbdd9b4ec2eaf5c1845ab70bab159" + }, + "@std/net@1.0.4": { + "integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852" + }, + "@std/path@1.0.8": { + "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" + }, + "@std/streams@1.0.8": { + "integrity": "b41332d93d2cf6a82fe4ac2153b930adf1a859392931e2a19d9fabfb6f154fb3" + }, + "@std/testing@1.0.4": { + "integrity": "ca1368d720b183f572d40c469bb9faf09643ddd77b54f8b44d36ae6b94940576", + "dependencies": [ + "jsr:@std/assert", + "jsr:@std/async", + "jsr:@std/data-structures", + "jsr:@std/fs", + "jsr:@std/internal", + "jsr:@std/path@^1.0.8" + ] + }, + "@std/toml@1.0.1": { + "integrity": "b55b407159930f338d384b1f8fd317c8e8a35e27ebb8946155f49e3a158d16c4", + "dependencies": [ + "jsr:@std/collections" + ] + }, + "@std/yaml@1.0.5": { + "integrity": "71ba3d334305ee2149391931508b2c293a8490f94a337eef3a09cade1a2a2742" + } + }, + "npm": { + "@types/node@22.5.4": { + "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", + "dependencies": [ + "undici-types" + ] + }, + "commander@8.3.0": { + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==" + }, + "deepmerge@4.3.1": { + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==" + }, + "dom-serializer@2.0.0": { + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dependencies": [ + "domelementtype", + "domhandler", + "entities" + ] + }, + "domelementtype@2.3.0": { + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==" + }, + "domhandler@5.0.3": { + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dependencies": [ + "domelementtype" + ] + }, + "domutils@3.1.0": { + "integrity": "sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA==", + "dependencies": [ + "dom-serializer", + "domelementtype", + "domhandler" + ] + }, + "entities@4.5.0": { + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==" + }, + "escape-string-regexp@4.0.0": { + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "github-slugger@2.0.0": { + "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==" + }, + "he@1.2.0": { + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==" + }, + "htmlparser2@8.0.2": { + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "dependencies": [ + "domelementtype", + "domhandler", + "domutils", + "entities" + ] + }, + "is-plain-object@5.0.0": { + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "katex@0.16.11": { + "integrity": "sha512-RQrI8rlHY92OLf3rho/Ts8i/XvjgguEjOkO1BEXcU3N8BqPpSzBNwV/G0Ukr+P/l3ivvJUE/Fa/CwbS6HesGNQ==", + "dependencies": [ + "commander" + ] + }, + "marked-alert@2.1.2_marked@12.0.2": { + "integrity": "sha512-EFNRZ08d8L/iEIPLTlQMDjvwIsj03gxWCczYTht6DCiHJIZhMk4NK5gtPY9UqAYb09eV5VGT+jD4lp396E0I+w==", + "dependencies": [ + "marked" + ] + }, + "marked-footnote@1.2.4_marked@12.0.2": { + "integrity": "sha512-DB2Kl+wFh6YwZd70qABMY6WUkG1UuyqoNTFoDfGyG79Pz24neYtLBkB+45a7o72V7gkfvbC3CGzIYFobxfMT1Q==", + "dependencies": [ + "marked" + ] + }, + "marked-gfm-heading-id@3.2.0_marked@12.0.2": { + "integrity": "sha512-Xfxpr5lXLDLY10XqzSCA9l2dDaiabQUgtYM9hw8yunyVsB/xYBRpiic6BOiY/EAJw1ik1eWr1ET1HKOAPZBhXg==", + "dependencies": [ + "github-slugger", + "marked" + ] + }, + "marked@12.0.2": { + "integrity": "sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==" + }, + "nanoid@3.3.7": { + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==" + }, + "parse-srcset@1.0.2": { + "integrity": "sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==" + }, + "picocolors@1.1.1": { + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, + "postcss@8.4.47": { + "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", + "dependencies": [ + "nanoid", + "picocolors", + "source-map-js" + ] + }, + "prismjs@1.29.0": { + "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" + }, + "sanitize-html@2.13.1": { + "integrity": "sha512-ZXtKq89oue4RP7abL9wp/9URJcqQNABB5GGJ2acW1sdO8JTVl92f4ygD7Yc9Ze09VAZhnt2zegeU0tbNsdcLYg==", + "dependencies": [ + "deepmerge", + "escape-string-regexp", + "htmlparser2", + "is-plain-object", + "parse-srcset", + "postcss" + ] + }, + "source-map-js@1.2.1": { + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==" + }, + "undici-types@6.19.8": { + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + } + }, + "redirects": { + "https://esm.sh/v135/@types/remove-markdown@~0/index.d.ts": "https://esm.sh/v135/@types/remove-markdown@0.3.4/index.d.ts" + }, + "remote": { + "https://deno.land/std@0.118.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58", + "https://deno.land/std@0.118.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac", + "https://deno.land/std@0.118.0/bytes/bytes_list.ts": "3bff6a09c72b2e0b1e92e29bd3b135053894196cca07a2bba842901073efe5cb", + "https://deno.land/std@0.118.0/bytes/equals.ts": "69f55fdbd45c71f920c1a621e6c0865dc780cd8ae34e0f5e55a9497b70c31c1b", + "https://deno.land/std@0.118.0/bytes/mod.ts": "fedb80b8da2e7ad8dd251148e65f92a04c73d6c5a430b7d197dc39588c8dda6f", + "https://deno.land/std@0.118.0/encoding/base64.ts": "0b58bd6477214838bf711eef43eac21e47ba9e5c81b2ce185fe25d9ecab3ebb3", + "https://deno.land/std@0.118.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621", + "https://deno.land/std@0.118.0/http/http_status.ts": "2ff185827bff21c7be2807fcb09a6a2166464ba57fcd94afe805abab8e09070a", + "https://deno.land/std@0.118.0/io/buffer.ts": "8f10342821b81990acf859cdccb4e4031c7c9187a0ffc3ed6b356ee29ecc6681", + "https://deno.land/std@0.118.0/io/files.ts": "8794bf6014e6f3183fc5433926dfef4a50eb8d3ec3b6736ebb4277e5f0ce3420", + "https://deno.land/std@0.118.0/io/readers.ts": "17403919724fef2f343c88555606368868a5c752a1099ad801f6a381c170f62d", + "https://deno.land/std@0.118.0/io/util.ts": "96409103aa87b0eb0ddc494666a3514a6e969a1a3e7f69e100115ab7a1f532fb", + "https://deno.land/std@0.118.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853", + "https://deno.land/std@0.118.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4", + "https://deno.land/std@0.118.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b", + "https://deno.land/std@0.118.0/path/common.ts": "f41a38a0719a1e85aa11c6ba3bea5e37c15dd009d705bd8873f94c833568cbc4", + "https://deno.land/std@0.118.0/path/glob.ts": "ea87985765b977cc284b92771003b2070c440e0807c90e1eb0ff3e095911a820", + "https://deno.land/std@0.118.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12", + "https://deno.land/std@0.118.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2", + "https://deno.land/std@0.118.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c", + "https://deno.land/std@0.118.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e", + "https://deno.land/std@0.118.0/streams/conversion.ts": "7ff9af42540063fa72003ab31a377ba9dde8532d43b16329b933c37a6d7aac5f", + "https://deno.land/std@0.118.0/testing/_diff.ts": "e6a10d2aca8d6c27a9c5b8a2dbbf64353874730af539707b5b39d4128140642d", + "https://deno.land/std@0.118.0/testing/asserts.ts": "e8bd3ff280731e2d2b48c67d6ed97ce2c0b717601ccb38816aff89edce71680d", + "https://deno.land/std@0.120.0/async/deadline.ts": "1d6ac7aeaee22f75eb86e4e105d6161118aad7b41ae2dd14f4cfd3bf97472b93", + "https://deno.land/std@0.120.0/async/debounce.ts": "b2f693e4baa16b62793fd618de6c003b63228db50ecfe3bd51fc5f6dc0bc264b", + "https://deno.land/std@0.120.0/async/deferred.ts": "ab60d46ba561abb3b13c0c8085d05797a384b9f182935f051dc67136817acdee", + "https://deno.land/std@0.120.0/async/delay.ts": "f2d8ccaa8ebc26594bd8b0989edfd8a96257a714c1dee2fb54d986e5bdd840ac", + "https://deno.land/std@0.120.0/async/mod.ts": "78425176fabea7bd1046ce3819fd69ce40da85c83e0f174d17e8e224a91f7d10", + "https://deno.land/std@0.120.0/async/mux_async_iterator.ts": "62abff3af9ff619e8f2adc96fc70d4ca020fa48a50c23c13f12d02ed2b760dbe", + "https://deno.land/std@0.120.0/async/pool.ts": "353ce4f91865da203a097aa6f33de8966340c91b6f4a055611c8c5d534afd12f", + "https://deno.land/std@0.120.0/async/tee.ts": "3e9f2ef6b36e55188de16a667c702ace4ad0cf84e3720379160e062bf27348ad", + "https://deno.land/std@0.120.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621", + "https://deno.land/std@0.120.0/http/http_status.ts": "2ff185827bff21c7be2807fcb09a6a2166464ba57fcd94afe805abab8e09070a", + "https://deno.land/std@0.193.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", + "https://deno.land/std@0.193.0/async/abortable.ts": "fd682fa46f3b7b16b4606a5ab52a7ce309434b76f820d3221bdfb862719a15d7", + "https://deno.land/std@0.193.0/async/deadline.ts": "58f72a3cc0fcb731b2cc055ba046f4b5be3349ff6bf98f2e793c3b969354aab2", + "https://deno.land/std@0.193.0/async/debounce.ts": "adab11d04ca38d699444ac8a9d9856b4155e8dda2afd07ce78276c01ea5a4332", + "https://deno.land/std@0.193.0/async/deferred.ts": "42790112f36a75a57db4a96d33974a936deb7b04d25c6084a9fa8a49f135def8", + "https://deno.land/std@0.193.0/async/delay.ts": "73aa04cec034c84fc748c7be49bb15cac3dd43a57174bfdb7a4aec22c248f0dd", + "https://deno.land/std@0.193.0/async/mod.ts": "f04344fa21738e5ad6bea37a6bfffd57c617c2d372bb9f9dcfd118a1b622e576", + "https://deno.land/std@0.193.0/async/mux_async_iterator.ts": "70c7f2ee4e9466161350473ad61cac0b9f115cff4c552eaa7ef9d50c4cbb4cc9", + "https://deno.land/std@0.193.0/async/pool.ts": "f1b8d3df4d7fd3c73f8cbc91cc2e8b8e950910f1eab94230b443944d7584c657", + "https://deno.land/std@0.193.0/async/retry.ts": "b1ccf653954a4e52b3d9731e57d18b864e689a7462e78fb20440b11be9905080", + "https://deno.land/std@0.193.0/async/tee.ts": "47e42d35f622650b02234d43803d0383a89eb4387e1b83b5a40106d18ae36757", + "https://deno.land/std@0.193.0/datetime/to_imf.ts": "8f9c0af8b167031ffe2e03da01a12a3b0672cc7562f89c61942a0ab0129771b2", + "https://deno.land/std@0.193.0/encoding/base64.ts": "144ae6234c1fbe5b68666c711dc15b1e9ee2aef6d42b3b4345bf9a6c91d70d0d", + "https://deno.land/std@0.193.0/http/_negotiation/common.ts": "14d1a52427ab258a4b7161cd80e1d8a207b7cc64b46e911780f57ead5f4323c6", + "https://deno.land/std@0.193.0/http/_negotiation/encoding.ts": "ff747d107277c88cb7a6a62a08eeb8d56dad91564cbcccb30694d5dc126dcc53", + "https://deno.land/std@0.193.0/http/_negotiation/language.ts": "7bcddd8db3330bdb7ce4fc00a213c5547c1968139864201efd67ef2d0d51887d", + "https://deno.land/std@0.193.0/http/_negotiation/media_type.ts": "58847517cd549384ad677c0fe89e0a4815be36fe7a303ea63cee5f6a1d7e1692", + "https://deno.land/std@0.193.0/http/cookie.ts": "934f92d871d50852dbd7a836d721df5a9527b14381db16001b40991d30174ee4", + "https://deno.land/std@0.193.0/http/cookie_map.ts": "d148a5eaf35f19905dd5104126fa47ac71105306dd42f129732365e43108b28a", + "https://deno.land/std@0.193.0/http/etag.ts": "6ad8abbbb1045aabf2307959a2c5565054a8bf01c9824ddee836b1ff22706a58", + "https://deno.land/std@0.193.0/http/http_errors.ts": "bbda34819060af86537cecc9dc8e045f877130808b7e7acde4197c5328e852d0", + "https://deno.land/std@0.193.0/http/http_status.ts": "8a7bcfe3ac025199ad804075385e57f63d055b2aed539d943ccc277616d6f932", + "https://deno.land/std@0.193.0/http/method.ts": "e66c2a015cb46c21ab0bb3589aa4fca43143a506cb324ffdfd42d2edef7bc0c4", + "https://deno.land/std@0.193.0/http/mod.ts": "525fb1b3b1e0d297facb08d8cf84c4908f8fadfc3f3f22809185510967279ef7", + "https://deno.land/std@0.193.0/http/negotiation.ts": "46e74a6bad4b857333a58dc5b50fe8e5a4d5267e97292293ea65f980bd918086", + "https://deno.land/std@0.193.0/http/server.ts": "1b23463b5b36e4eebc495417f6af47a6f7d52e3294827a1226d2a1aab23d9d20", + "https://deno.land/std@0.193.0/http/server_sent_event.ts": "1f3597d175e8935123306a24d7f4423a463667a70953d17b4115af1880459d55", + "https://deno.land/std@0.193.0/http/user_agent.ts": "6f4308670f261118cc6a1518bf37431a5b4f21322b4a4edf0963e182264ce404", + "https://deno.land/x/g_a@0.1.2/mod.ts": "6016891e4aa825a82e14782cf45be5705aa42f3ed5e8378200a6e0136239f572", + "https://deno.land/x/htm@0.1.3/html.tsx": "b1c1e8ff8af45dbdf4dd6d90dea37ff8e9c86c705f672f9b53911691ed12e6fd", + "https://deno.land/x/htm@0.1.3/mod.ts": "93485a06c930907a40f09eb8d9deadf27aaaa228c5037a24be7a08b82c8b4bee", + "https://deno.land/x/htm@0.1.3/plugins/color-scheme.ts": "e6aae324f7d28e2ad3a9c9dfa5665ba0e4cec2e05fabb04989dc124c0b5f6e36", + "https://deno.land/x/htm@0.1.3/plugins/unocss.ts": "dca4739d3f07a243b14d072cc470537a8711e0b7218b4968e661d62ceeee6416", + "https://deno.land/x/media_types@v2.11.1/db.ts": "1eac2b1b57195e41d7e40d7b236a3adeb93b4fa18084b4c9db49144fe685c78d", + "https://deno.land/x/media_types@v2.11.1/mod.ts": "1be09ec3626332f9fe52a8a9ede852bb76d2207f84bec1f1b16c10555478008f", + "https://deno.land/x/oak@v10.1.0/application.ts": "7ad567e390aebfbb96cf8745685cfea899b2b419838347a84e22898957e7648b", + "https://deno.land/x/oak@v10.1.0/body.ts": "884ae12f149059386cd68ebaab572822b20de8c69fee2f12c4c56ce84bd9c64e", + "https://deno.land/x/oak@v10.1.0/buf_reader.ts": "ee96cd6ead6caf0015b8395d7be3a77b0d8f082fd55121673e632924dc1eb6a5", + "https://deno.land/x/oak@v10.1.0/content_disposition.ts": "8b8c3cb2fba7138cd5b7f82fc3b5ea39b33db924a824b28261659db7e164621e", + "https://deno.land/x/oak@v10.1.0/context.ts": "221586ee15a85057db7f3fceaa845b18ff0489956f307aaa2fcd5f8382dd80ee", + "https://deno.land/x/oak@v10.1.0/cookies.ts": "ba0e632bc96b5228deee7c0b589be3cfbbbf48c44b606540f9c2e4f5428ee1f8", + "https://deno.land/x/oak@v10.1.0/deps.ts": "05dc85115133ab2d24684cbbed8e4679401dff9ed9aad76014cb3c848473c76d", + "https://deno.land/x/oak@v10.1.0/etag.ts": "ea6a767b9b7606d8c9c13d7edea468e93686a8303a62259d9a182f633acad646", + "https://deno.land/x/oak@v10.1.0/headers.ts": "50b809d5f311837f49344f6622bfbe24c57e64cd788bfb8d66ac826d304e6c3a", + "https://deno.land/x/oak@v10.1.0/httpError.ts": "3fd09d0392f194d825b0093a1a77df6ca9f92ab90ad42b6ca4fe5a4ae660e9a3", + "https://deno.land/x/oak@v10.1.0/http_server_native.ts": "c04529062a6aef9ccc88c6e2d3b3c5c1435b45296175cac919b6f03e27a47470", + "https://deno.land/x/oak@v10.1.0/isMediaType.ts": "e7457f8c14245a7bb9a3a48000d50e112bb6fcafeab8fd7bcff16363a0cd8687", + "https://deno.land/x/oak@v10.1.0/keyStack.ts": "bfa8f388dbfccf0e133f7f5682c0ff6ca517581f639c228b4a6ad4b14b3f6b79", + "https://deno.land/x/oak@v10.1.0/mediaTyper.ts": "042b853fc8e9c3f6c628dd389e03ef481552bf07242efc3f8a1af042102a6105", + "https://deno.land/x/oak@v10.1.0/middleware.ts": "073665130709d495e058c68d67dbf09161d2a4a0ce2a8b4614f13f96e21a22cd", + "https://deno.land/x/oak@v10.1.0/multipart.ts": "ae2751544e8eb93ab0308bb7f88aa073de8669903707c4d20d6403f1f27428aa", + "https://deno.land/x/oak@v10.1.0/negotiation/charset.ts": "b4c2e0c49dd5122f130f95bf29508448d983c424801b5bc304b00288b5ae3195", + "https://deno.land/x/oak@v10.1.0/negotiation/common.ts": "f54d599d37408005f8c565d0f6505de51fed31feaa3654a7758e2359c006b02c", + "https://deno.land/x/oak@v10.1.0/negotiation/encoding.ts": "60eb0fc3df57cc39eaa739e0e9e2cda6c20b3aa429d1a0108f503065f5709bbe", + "https://deno.land/x/oak@v10.1.0/negotiation/language.ts": "62ef13ea3146538dd52a4666611bd423ebb9a6438e7312398e17a4d16dbafb51", + "https://deno.land/x/oak@v10.1.0/negotiation/mediaType.ts": "7e25cc34600beea3bf0b0879ff1783c752260fcb517dffea2e122830c36e8451", + "https://deno.land/x/oak@v10.1.0/range.ts": "879df226712c174b01f9ce173fbb8cc290a9c89c54d65a8aa19c575c00a0ab3b", + "https://deno.land/x/oak@v10.1.0/request.ts": "80539f3d9a64da33b99949f86836a93eeadcf6c767a47f60a16dcaf9d4a7c256", + "https://deno.land/x/oak@v10.1.0/response.ts": "023ba90443ab66f794a70e5c1d3b764f337704bec085a0883d1fde28b41548a1", + "https://deno.land/x/oak@v10.1.0/router.ts": "75a79573168ee0037c8f03f9ad1f0ea0f879b014c1b95ab1b35decc23e32dd90", + "https://deno.land/x/oak@v10.1.0/send.ts": "6101420ff6d731f61b2eb837698f3ad406f594085311a6dd9c79dbb5bafae085", + "https://deno.land/x/oak@v10.1.0/server_sent_event.ts": "349bf3b317f4270b89839b554abe3f1dbd638d68c570d29f281062e54270e317", + "https://deno.land/x/oak@v10.1.0/structured_clone.ts": "f46f5d14cf929b3cbf7168700c8e28bbf4ee8e229b93ceae08f6d6b2b150c8ab", + "https://deno.land/x/oak@v10.1.0/tssCompare.ts": "e496924cb94de38bc035695926bd2f81e16bc3c8980ab1f34fe2f4865bb9aaeb", + "https://deno.land/x/oak@v10.1.0/util.ts": "0030f8e9d957533e2fe9c89927eadb6e90c7b28ded05a25f14fd1edd6eb67469", + "https://deno.land/x/path_to_regexp@v6.2.0/index.ts": "e94c04a44bbecac99ff2db2d831afe98b423e627b775cb57fc7935f848c64c51", + "https://esm.sh/@unocss/core@0.46.3": "9049ec4601a3d23ef867686a6318db0036070087ed0f042aa2fa078484b7e7a5", + "https://esm.sh/@unocss/preset-wind@0.46.3?bundle&no-check": "9bf95bcf4a8ef5528e505238763e37fb9300b3da5042b959c7c7d41f931b6629", + "https://esm.sh/feed@4.2.2": "1a5822737d59ad06c741504c67eba07c68b582799b6b4609f17824cd5a3dcfe0", + "https://esm.sh/preact-render-to-string@5.2.6?deps=preact@10.11.2": "d8ce3aa6687925c0213d5e5b31f2108effaf4b85c29addad4221c5ef6564a3af", + "https://esm.sh/preact@10.11.2": "aa8243ba86dad0496c28aa6c01fb49d18abcf245d492f2856d0e13a19e71af6a", + "https://esm.sh/prismjs@1.29.0/components/prism-c?no-check": "c06f2d48b15d82b9e994856f9380bb5a6192ce0230fe33fcb49b86980d660860", + "https://esm.sh/remove-markdown@0.5.0": "44b9de241db9fbb69f3e526773fd6d170a14b04860e543c3a48cfa7089905aa0", + "https://esm.sh/stable/preact@10.11.2/denonext/preact.mjs": "deeb0873c83971be55cddc2f90bf0099a4c86adb3797884300677a3daf1b70b7", + "https://esm.sh/v135/@unocss/core@0.46.3/denonext/core.mjs": "ed5fc799af48df70c566212dececb0af69e4ac2e490bf3486868c4650317fb9f", + "https://esm.sh/v135/@unocss/preset-wind@0.46.3/denonext/preset-wind.bundle.mjs": "4684306eb5efcc68054141cfce29286c33e255d03b17b47cd42c79a0858b1721", + "https://esm.sh/v135/feed@4.2.2/denonext/feed.mjs": "d6dc8357b3e9474bb21a6b339b9c1d311ce389c5971be2235945d267563a6dc3", + "https://esm.sh/v135/preact-render-to-string@5.2.6/X-ZC9wcmVhY3RAMTAuMTEuMg/denonext/preact-render-to-string.mjs": "baf544ca7c0dfc2ddb807e25fccc233bc12451c0ec212f5d5fd30100c5198def", + "https://esm.sh/v135/prismjs@1.29.0/denonext/components/prism-c.js": "a953feccc190607c9aa27e8efabd149aa3eaa1105808a99e08be3b4513ef0f20", + "https://esm.sh/v135/remove-markdown@0.5.0/denonext/remove-markdown.mjs": "abcc5cbc5f9dbee0bb06776b5a84f7c3bb65bc9b4454b3991f6964fbecd403c2", + "https://esm.sh/v135/sax@1.3.0/denonext/sax.mjs": "9bc4584a87fa83f1ce8bd60ddda5864b3bc7895ef6f751a818d2aa0f7a426505", + "https://esm.sh/v135/xml-js@1.6.11/denonext/xml-js.mjs": "9d1e9b85bc3e74ef2327bf96800e0d752bcd0f55b323a2a6a5ca969624390e8c", + "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts": "a5fdfa7916d03459fd4830ca526d493d5f4ce0ea91619905d524c9a3a5c3cd15" + }, + "workspace": { + "dependencies": [ + "jsr:@deno/gfm@0.10", + "jsr:@std/assert@^1.0.7", + "jsr:@std/async@^1.0.8", + "jsr:@std/front-matter@^1.0.5", + "jsr:@std/fs@^1.0.5", + "jsr:@std/http@^1.0.9", + "jsr:@std/path@^1.0.8", + "jsr:@std/testing@^1.0.4" + ] + } +} diff --git a/deps.ts b/deps.ts deleted file mode 100644 index e47d6fc..0000000 --- a/deps.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022 the Deno authors. All rights reserved. MIT license. - -export { serveDir } from "https://deno.land/std@0.193.0/http/file_server.ts"; -export { walk } from "https://deno.land/std@0.193.0/fs/walk.ts"; -export { - dirname, - fromFileUrl, - join, - relative, -} from "https://deno.land/std@0.193.0/path/mod.ts"; -export { - type ConnInfo, - serve, -} from "https://deno.land/std@0.193.0/http/mod.ts"; -export { extract as frontMatter } from "https://deno.land/std@0.193.0/front_matter/any.ts"; - -export * as gfm from "https://deno.land/x/gfm@0.2.5/mod.ts"; -export { Fragment, h } from "https://deno.land/x/htm@0.1.3/mod.ts"; -export { - default as html, - type HtmlOptions, - type VNode, -} from "https://deno.land/x/htm@0.1.3/html.tsx"; -import UnoCSS from "https://deno.land/x/htm@0.1.3/plugins/unocss.ts"; -import ColorScheme from "https://deno.land/x/htm@0.1.3/plugins/color-scheme.ts"; - -export { - createReporter, - type Reporter as GaReporter, -} from "https://deno.land/x/g_a@0.1.2/mod.ts"; -export { default as callsites } from "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts"; -export { Feed, type Item as FeedItem } from "https://esm.sh/feed@4.2.2"; -export { default as removeMarkdown } from "https://esm.sh/remove-markdown@0.5.0"; - -// Add syntax highlighting support for C by default -import "https://esm.sh/prismjs@1.29.0/components/prism-c?no-check"; - -export { ColorScheme, UnoCSS }; -export type UnoConfig = typeof UnoCSS extends ( - arg: infer P | undefined, -) => unknown ? P - : never; diff --git a/init.ts b/init.ts index 0cac885..bf7a3a9 100644 --- a/init.ts +++ b/init.ts @@ -1,6 +1,6 @@ // Copyright 2022 the Deno authors. All rights reserved. MIT license. -import { join, resolve } from "https://deno.land/std@0.193.0/path/mod.ts"; +import { join, resolve } from "@std/path"; const HELP = `deno_blog diff --git a/mod.test.ts b/mod.test.ts new file mode 100644 index 0000000..b807398 --- /dev/null +++ b/mod.test.ts @@ -0,0 +1,20 @@ +import { assert } from "@std/assert/assert"; +import * as module from "./mod.ts"; + +Deno.test("module exports expected dependencies", () => { + assert(module, "module is not defined"); + assert(module.types, "module.types is not defined"); + assert(module.blog, "module.blog is not defined"); + assert(module.blog.configureBlog, "module.blog.configureBlog is not defined"); + assert( + module.blog.createBlogHandler, + "module.blog.createBlogHandler is not defined", + ); + assert(module.blog.default, "module.blog.default is not defined"); + assert(module.components, "module.components is not defined"); + assert(module.components.Index, "module.components.Index is not defined"); + assert( + module.components.PostPage, + "module.components.PostPage is not defined", + ); +}); diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000..478064a --- /dev/null +++ b/mod.ts @@ -0,0 +1,5 @@ +import * as types from "./types.d.ts"; +import * as blog from "./src/blog.tsx"; +import * as components from "./src/components.tsx"; + +export { blog, components, types }; diff --git a/blog_test.ts b/src/blog.test.ts similarity index 95% rename from blog_test.ts rename to src/blog.test.ts index 71f0c00..b289815 100644 --- a/blog_test.ts +++ b/src/blog.test.ts @@ -1,15 +1,12 @@ // Copyright 2022 the Deno authors. All rights reserved. MIT license. import { configureBlog, createBlogHandler, redirects } from "./blog.tsx"; -import { - assert, - assertEquals, - assertStringIncludes, -} from "https://deno.land/std@0.193.0/testing/asserts.ts"; -import { fromFileUrl, join } from "https://deno.land/std@0.193.0/path/mod.ts"; +import { assert, assertEquals, assertStringIncludes } from "@std/assert"; +import { fromFileUrl, join } from "@std/path"; -const BLOG_URL = new URL("./testdata/main.js", import.meta.url).href; -const TESTDATA_PATH = fromFileUrl(new URL("./testdata/", import.meta.url)); +const BLOG_URL = new URL("../content/main.js", import.meta.url).href; +const TESTDATA_PATH = fromFileUrl(new URL("../testdata/", import.meta.url)); +const CONTENT_PATH = fromFileUrl(new URL("../content/", import.meta.url)); const BLOG_SETTINGS = await configureBlog(BLOG_URL, false, { author: "The author", title: "Test blog", @@ -25,6 +22,7 @@ const BLOG_SETTINGS = await configureBlog(BLOG_URL, false, { ], readtime: true, }); + const CONN_INFO = { localAddr: { transport: "tcp" as const, @@ -268,7 +266,7 @@ Deno.test("static files in posts/ directory", async () => { const bytes = new Uint8Array(await resp.arrayBuffer()); assertEquals( bytes, - await Deno.readFile(join(TESTDATA_PATH, "./posts/first/hello.png")), + await Deno.readFile(join(CONTENT_PATH, "./posts/first/hello.png")), ); } { @@ -281,7 +279,7 @@ Deno.test("static files in posts/ directory", async () => { const bytes = new Uint8Array(await resp.arrayBuffer()); assertEquals( bytes, - await Deno.readFile(join(TESTDATA_PATH, "./posts/second/hello2.png")), + await Deno.readFile(join(CONTENT_PATH, "./posts/second/hello2.png")), ); } }); @@ -292,7 +290,7 @@ Deno.test("static files in root directory", async () => { assertEquals(resp.status, 200); assertEquals(resp.headers.get("content-type"), "image/png"); const bytes = new Uint8Array(await resp.arrayBuffer()); - assertEquals(bytes, await Deno.readFile(join(TESTDATA_PATH, "./cat.png"))); + assertEquals(bytes, await Deno.readFile(join(CONTENT_PATH, "./cat.png"))); }); Deno.test("RSS feed", async () => { diff --git a/blog.tsx b/src/blog.tsx similarity index 92% rename from blog.tsx rename to src/blog.tsx index 08ed81a..c14055a 100644 --- a/blog.tsx +++ b/src/blog.tsx @@ -6,38 +6,37 @@ /// /// -import { - callsites, - ColorScheme, - createReporter, - dirname, - Feed, - Fragment, - fromFileUrl, - frontMatter, - gfm, - h, - html, - HtmlOptions, - join, - relative, - removeMarkdown, - serve, - serveDir, - UnoCSS, - walk, -} from "./deps.ts"; -import { pooledMap } from "https://deno.land/std@0.187.0/async/pool.ts"; +import { serveDir } from "@std/http/file-server"; +import { walk } from "@std/fs"; +import { dirname, fromFileUrl, join, relative } from "@std/path"; +import { type ConnInfo, serve } from "@outdated/std-http"; +import { extract as frontMatter } from "@std/front-matter/any"; + +import * as gfm from "@deno/gfm"; +import { Fragment, h } from "@denoland/htm"; +import { default as html, type HtmlOptions } from "@denoland/htm"; + +import { createReporter } from "@denoland/g_a"; +import { default as callsites } from "@githubcontent/kt3k/callsites"; +import { Feed, type Item as FeedItem } from "@esm/feed"; +import { default as removeMarkdown } from "@esm/remove-markdown"; + +import UnoCSS from "@denoland/htm/plugins/unocss"; +import ColorScheme from "@denoland/htm/plugins/color-scheme"; + +import { pooledMap } from "@std/async"; import { Index, PostPage } from "./components.tsx"; -import type { ConnInfo, FeedItem } from "./deps.ts"; import type { BlogContext, BlogMiddleware, BlogSettings, BlogState, Post, -} from "./types.d.ts"; -import { WalkEntry } from "https://deno.land/std@0.176.0/fs/walk.ts"; +} from "../types.d.ts"; +import { WalkEntry } from "@std/fs"; + +// Add syntax highlighting support for C by default +import "@esm/prism-c"; export { Fragment, h }; @@ -231,7 +230,8 @@ async function watchForChanges(postsDirectory: string) { HMR_SOCKETS.forEach((socket) => { socket.send("refresh"); }); - } catch (err) { + // deno-lint-ignore no-explicit-any + } catch (err: any) { console.error(`loadPost ${path} error:`, err.message); } } @@ -433,7 +433,8 @@ export async function handler( try { await Deno.lstat(join(blogState.directory, "./posts", pathname)); fsRoot = join(blogState.directory, "./posts"); - } catch (e) { + // deno-lint-ignore no-explicit-any + } catch (e: any) { if (!(e instanceof Deno.errors.NotFound)) { console.error(e); return new Response(e.message, { status: 500 }); @@ -551,7 +552,8 @@ export function redirects(redirectMap: Record): BlogMiddleware { } try { return await ctx.next(); - } catch (e) { + // deno-lint-ignore no-explicit-any + } catch (e: any) { console.error(e); return new Response(`Internal server error: ${e.message}`, { status: 500, diff --git a/components.tsx b/src/components.tsx similarity index 99% rename from components.tsx rename to src/components.tsx index d2c02ed..3b73cab 100644 --- a/components.tsx +++ b/src/components.tsx @@ -7,8 +7,9 @@ /// /// -import { Fragment, gfm, h } from "./deps.ts"; -import type { BlogState, DateFormat, Post } from "./types.d.ts"; +import * as gfm from "@deno/gfm"; +import { h } from "@denoland/htm"; +import type { BlogState, DateFormat, Post } from "../types.d.ts"; const socialAppIcons = new Map([ ["github.com", IconGithub], diff --git a/types.d.ts b/types.d.ts index 694be92..910d3e9 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,6 +1,12 @@ // Copyright 2022 the Deno authors. All rights reserved. MIT license. +import UnoCSS from "@denoland/htm/plugins/unocss"; +import { VNode } from "@denoland/htm"; +import type { ConnInfo } from "@outdated/std-http"; -import type { ConnInfo, UnoConfig, VNode } from "./deps.ts"; +type UnoConfig = typeof UnoCSS extends ( + arg: infer P | undefined, +) => unknown ? P + : never; export interface BlogContext { state: BlogState; From 61efe6ca3541062f2427750bb9882a7f355c98b1 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Mon, 4 Nov 2024 17:29:31 +0000 Subject: [PATCH 2/5] update readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e29f966..63ff75f 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ blog(); To initialize your own blog you can run following script: -```shellsession -$ deno run -r --allow-read --allow-write https://deno.land/x/blog/init.ts ./directory/for/blog/ +```sh +deno run -r --allow-read --allow-write https://deno.land/x/blog/init.ts ./directory/for/blog/ ``` _This command will setup a blog with a "Hello world" post so you can start @@ -22,8 +22,8 @@ writing right away._ Start local server with live reload: -```shellsession -$ deno task dev +```sh +deno task dev ``` To ensure the best development experience, make sure to follow @@ -106,6 +106,6 @@ To deploy the project to the live internet, you can use You can also self-host the blog, in such case run: -```shellsession +```sh $ deno task serve ``` From b77e013bef5a9c8fdc7e9940d956445d5c5e08d2 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Mon, 4 Nov 2024 17:30:00 +0000 Subject: [PATCH 3/5] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63ff75f..221573f 100644 --- a/README.md +++ b/README.md @@ -107,5 +107,5 @@ To deploy the project to the live internet, you can use You can also self-host the blog, in such case run: ```sh -$ deno task serve +deno task serve ``` From 5fe3912d8d0b18f8c6a63f9ef070e7c2df681fc2 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Tue, 5 Nov 2024 10:00:51 +0000 Subject: [PATCH 4/5] bump action to v2 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c1f08d..1e0d022 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: uses: actions/checkout@v2 - name: Install Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 - name: Check formatting run: deno fmt --check From 9376ea79f182079c4f808c922acb273fee885659 Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Tue, 5 Nov 2024 14:40:16 +0000 Subject: [PATCH 5/5] remove deps and esm imports, swap over to npm --- deno.json | 8 ++++---- deno.lock | 25 ++++++++++++++++++++++++- deps.ts | 42 ------------------------------------------ src/blog.tsx | 6 +++--- 4 files changed, 31 insertions(+), 50 deletions(-) delete mode 100644 deps.ts diff --git a/deno.json b/deno.json index 28fae66..af83c68 100644 --- a/deno.json +++ b/deno.json @@ -18,9 +18,9 @@ "@denoland/htm/plugins/unocss": "https://deno.land/x/htm@0.1.3/plugins/unocss.ts", "@denoland/g_a": "https://deno.land/x/g_a@0.1.2/mod.ts", "@githubcontent/kt3k/callsites": "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts", - "@esm/feed": "https://esm.sh/feed@4.2.2", - "@esm/remove-markdown": "https://esm.sh/remove-markdown@0.5.0", - "@esm/prism-c": "https://esm.sh/prismjs@1.29.0/components/prism-c?no-check", - "@outdated/std-http": "https://deno.land/std@0.193.0/http/mod.ts" + "@outdated/std-http": "https://deno.land/std@0.193.0/http/mod.ts", + "feed": "npm:feed@^4.2.2", + "prismjs": "npm:prismjs@^1.29.0", + "remove-markdown": "npm:remove-markdown@^0.5.5" } } diff --git a/deno.lock b/deno.lock index 8fc28b9..b6b3e2c 100644 --- a/deno.lock +++ b/deno.lock @@ -23,6 +23,7 @@ "jsr:@std/toml@^1.0.1": "1.0.1", "jsr:@std/yaml@^1.0.5": "1.0.5", "npm:@types/node@*": "22.5.4", + "npm:feed@^4.2.2": "4.2.2", "npm:github-slugger@2": "2.0.0", "npm:he@^1.2.0": "1.2.0", "npm:katex@0.16": "0.16.11", @@ -31,6 +32,7 @@ "npm:marked-gfm-heading-id@^3.1.0": "3.2.0_marked@12.0.2", "npm:marked@12": "12.0.2", "npm:prismjs@^1.29.0": "1.29.0", + "npm:remove-markdown@~0.5.5": "0.5.5", "npm:sanitize-html@^2.13.0": "2.13.1" }, "jsr": { @@ -181,6 +183,12 @@ "escape-string-regexp@4.0.0": { "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" }, + "feed@4.2.2": { + "integrity": "sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ==", + "dependencies": [ + "xml-js" + ] + }, "github-slugger@2.0.0": { "integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==" }, @@ -247,6 +255,9 @@ "prismjs@1.29.0": { "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" }, + "remove-markdown@0.5.5": { + "integrity": "sha512-lMR8tOtDqazFT6W2bZidoXwkptMdF3pCxpri0AEokHg0sZlC2GdoLqnoaxsEj1o7/BtXV1MKtT3YviA1t7rW7g==" + }, "sanitize-html@2.13.1": { "integrity": "sha512-ZXtKq89oue4RP7abL9wp/9URJcqQNABB5GGJ2acW1sdO8JTVl92f4ygD7Yc9Ze09VAZhnt2zegeU0tbNsdcLYg==", "dependencies": [ @@ -258,11 +269,20 @@ "postcss" ] }, + "sax@1.4.1": { + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==" + }, "source-map-js@1.2.1": { "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==" }, "undici-types@6.19.8": { "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, + "xml-js@1.6.11": { + "integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==", + "dependencies": [ + "sax" + ] } }, "redirects": { @@ -396,7 +416,10 @@ "jsr:@std/fs@^1.0.5", "jsr:@std/http@^1.0.9", "jsr:@std/path@^1.0.8", - "jsr:@std/testing@^1.0.4" + "jsr:@std/testing@^1.0.4", + "npm:feed@^4.2.2", + "npm:prismjs@^1.29.0", + "npm:remove-markdown@~0.5.5" ] } } diff --git a/deps.ts b/deps.ts deleted file mode 100644 index d10e46c..0000000 --- a/deps.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2022 the Deno authors. All rights reserved. MIT license. - -export { serveDir } from "https://deno.land/std@0.193.0/http/file_server.ts"; -export { walk } from "https://deno.land/std@0.193.0/fs/walk.ts"; -export { - dirname, - fromFileUrl, - join, - relative, -} from "https://deno.land/std@0.193.0/path/mod.ts"; -export { - type ConnInfo, - serve, -} from "https://deno.land/std@0.193.0/http/mod.ts"; -export { extract as frontMatter } from "https://deno.land/std@0.193.0/front_matter/any.ts"; - -export * as gfm from "jsr:@deno/gfm@0.10.0"; -export { Fragment, h } from "https://deno.land/x/htm@0.1.3/mod.ts"; -export { - default as html, - type HtmlOptions, - type VNode, -} from "https://deno.land/x/htm@0.1.3/html.tsx"; -import UnoCSS from "https://deno.land/x/htm@0.1.3/plugins/unocss.ts"; -import ColorScheme from "https://deno.land/x/htm@0.1.3/plugins/color-scheme.ts"; - -export { - createReporter, - type Reporter as GaReporter, -} from "https://deno.land/x/g_a@0.1.2/mod.ts"; -export { default as callsites } from "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts"; -export { Feed, type Item as FeedItem } from "https://esm.sh/feed@4.2.2"; -export { default as removeMarkdown } from "https://esm.sh/remove-markdown@0.5.0"; - -// Add syntax highlighting support for C by default -import "https://esm.sh/prismjs@1.29.0/components/prism-c?no-check"; - -export { ColorScheme, UnoCSS }; -export type UnoConfig = typeof UnoCSS extends ( - arg: infer P | undefined, -) => unknown ? P - : never; diff --git a/src/blog.tsx b/src/blog.tsx index c14055a..332bf1c 100644 --- a/src/blog.tsx +++ b/src/blog.tsx @@ -18,8 +18,8 @@ import { default as html, type HtmlOptions } from "@denoland/htm"; import { createReporter } from "@denoland/g_a"; import { default as callsites } from "@githubcontent/kt3k/callsites"; -import { Feed, type Item as FeedItem } from "@esm/feed"; -import { default as removeMarkdown } from "@esm/remove-markdown"; +import { Feed, type Item as FeedItem } from "feed"; +import { default as removeMarkdown } from "remove-markdown"; import UnoCSS from "@denoland/htm/plugins/unocss"; import ColorScheme from "@denoland/htm/plugins/color-scheme"; @@ -36,7 +36,7 @@ import type { import { WalkEntry } from "@std/fs"; // Add syntax highlighting support for C by default -import "@esm/prism-c"; +import "prismjs"; export { Fragment, h };