-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor files, fix up types, move over to jsr where possible
- Loading branch information
1 parent
d251507
commit 26d2d91
Showing
23 changed files
with
504 additions
and
93 deletions.
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import blog from "../blog.tsx"; | ||
import blog from "../src/blog.tsx"; | ||
|
||
blog({ | ||
author: "Dino", | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected]/mod.ts", | ||
"@denoland/htm/plugins/color-scheme": "https://deno.land/x/[email protected]/plugins/color-scheme.ts", | ||
"@denoland/htm/plugins/unocss": "https://deno.land/x/[email protected]/plugins/unocss.ts", | ||
"@denoland/g_a": "https://deno.land/x/[email protected]/mod.ts", | ||
"@githubcontent/kt3k/callsites": "https://raw.githubusercontent.com/kt3k/callsites/v1.0.0/mod.ts", | ||
"@esm/feed": "https://esm.sh/[email protected]", | ||
"@esm/remove-markdown": "https://esm.sh/[email protected]", | ||
"@esm/prism-c": "https://esm.sh/[email protected]/components/prism-c?no-check", | ||
"@outdated/std-http": "https://deno.land/[email protected]/http/mod.ts" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2022 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { join, resolve } from "https://deno.land/[email protected]/path/mod.ts"; | ||
import { join, resolve } from "@std/path"; | ||
|
||
const HELP = `deno_blog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected]/testing/asserts.ts"; | ||
import { fromFileUrl, join } from "https://deno.land/[email protected]/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 () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,38 +6,37 @@ | |
/// <reference lib="dom.asynciterable" /> | ||
/// <reference lib="deno.ns" /> | ||
|
||
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/[email protected]/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/[email protected]/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<string, string>): 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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters