diff --git a/__tests__/Footer.test.tsx b/__tests__/Footer.test.tsx
index e8bd761..09a62b0 100644
--- a/__tests__/Footer.test.tsx
+++ b/__tests__/Footer.test.tsx
@@ -1,16 +1,14 @@
-import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
-import { assertExists } from "@std/testing/asserts";
import { cleanup, render, setup } from "$fresh-testing-library/components.ts";
import { Footer } from "@/components/Footer.tsx";
+import { assertExists } from "@std/testing/asserts";
+import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
describe("Footer", () => {
beforeAll(setup);
afterEach(cleanup);
it("should exists.", () => {
- const { container } = render(
- ,
- );
+ const { container } = render();
assertExists(container);
});
diff --git a/__tests__/Header.test.tsx b/__tests__/Header.test.tsx
index a84d171..b2b77ea 100644
--- a/__tests__/Header.test.tsx
+++ b/__tests__/Header.test.tsx
@@ -1,16 +1,14 @@
-import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
-import { assertExists } from "@std/testing/asserts";
import { cleanup, render, setup } from "$fresh-testing-library/components.ts";
import { Header } from "@/components/Header.tsx";
+import { assertExists } from "@std/testing/asserts";
+import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
describe("Header", () => {
beforeAll(setup);
afterEach(cleanup);
it("should exists.", () => {
- const { container } = render(
- ,
- );
+ const { container } = render();
assertExists(container);
});
diff --git a/__tests__/SEO.test.tsx b/__tests__/SEO.test.tsx
index a50c440..d418bd0 100644
--- a/__tests__/SEO.test.tsx
+++ b/__tests__/SEO.test.tsx
@@ -1,7 +1,7 @@
-import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
-import { assertExists } from "@std/testing/asserts";
import { cleanup, render, setup } from "$fresh-testing-library/components.ts";
import { SEO } from "@/components/SEO.tsx";
+import { assertExists } from "@std/testing/asserts";
+import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
describe("Footer", () => {
beforeAll(setup);
diff --git a/__tests__/index.test.tsx b/__tests__/index.test.tsx
index 2352124..de4e50c 100644
--- a/__tests__/index.test.tsx
+++ b/__tests__/index.test.tsx
@@ -1,7 +1,7 @@
-import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
-import { assertExists } from "@std/testing/asserts";
import { cleanup, render, setup } from "$fresh-testing-library/components.ts";
import { PostCard } from "@/routes/index.tsx";
+import { assertExists } from "@std/testing/asserts";
+import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
describe("PostCard", () => {
beforeAll(setup);
diff --git a/__tests__/islands/SearchButton.test.tsx b/__tests__/islands/SearchButton.test.tsx
index 625b337..84603a2 100644
--- a/__tests__/islands/SearchButton.test.tsx
+++ b/__tests__/islands/SearchButton.test.tsx
@@ -1,9 +1,9 @@
-import { assert } from "@std/testing/asserts";
+import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
import { cleanup, render, setup } from "$fresh-testing-library/components.ts";
import { fn } from "$fresh-testing-library/expect.ts";
+import { assert } from "@std/testing/asserts";
import { afterEach, beforeAll, describe, it } from "@std/testing/bdd";
import SearchButton from "../../islands/SearchButton.tsx";
-import docsearch from "https://esm.sh/@docsearch/js@3?target=es2020";
describe("islands/SearchButton.tsx", () => {
beforeAll(setup);
@@ -12,12 +12,14 @@ describe("islands/SearchButton.tsx", () => {
it("should contain class applied in props", () => {
// create mock implementation of docsearch
// @ts-ignore mock impl
- const dsearch = fn(docsearch).mockImplementation((
- _applId: string,
- _apiKey: string,
- _indexName: string,
- _container: HTMLElement | string,
- ) => {});
+ const dsearch = fn(docsearch).mockImplementation(
+ (
+ _applId: string,
+ _apiKey: string,
+ _indexName: string,
+ _container: HTMLElement | string,
+ ) => {},
+ );
const { getByTitle } = render(
,
);
diff --git a/components/Bio.tsx b/components/Bio.tsx
index 2dcf2de..b46e880 100644
--- a/components/Bio.tsx
+++ b/components/Bio.tsx
@@ -1,11 +1,14 @@
export const Bio = ({ author }: { author: string }) => (
-
+
Written by {author}{" "}
- who lives and works in Japan building useful things.
- {` `}
-
+ who lives and works in Japan building useful things.{" "}
+
You should follow him on Bluesky
diff --git a/components/Footer.tsx b/components/Footer.tsx
index 5ccdac2..1fd5458 100644
--- a/components/Footer.tsx
+++ b/components/Footer.tsx
@@ -1,5 +1,5 @@
-import Campfire from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/campfire.tsx";
import BrandGithub from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/brand-github.tsx";
+import Campfire from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/campfire.tsx";
import { author } from "@/utils/website.ts";
export function Footer() {
@@ -17,13 +17,9 @@ export function Footer() {
-
- Lazy builder
+
{author}
+
Lazy builder
{menus.map((item) => (
@@ -32,10 +28,7 @@ export function Footer() {
{item.children.map((child) => (
-
-
+
{child.name}
@@ -46,7 +39,8 @@ export function Footer() {
- Copyright © {new Date().getFullYear()} github.com/9renpoto
+ Copyright © {new Date().getFullYear()} github.com/9renpoto
+
All right reserved.
diff --git a/components/Header.tsx b/components/Header.tsx
index 97fe54d..90d70a8 100644
--- a/components/Header.tsx
+++ b/components/Header.tsx
@@ -1,6 +1,6 @@
+import IconActivity from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/activity.tsx";
import Campfire from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/campfire.tsx";
import IconRss from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/rss.tsx";
-import IconActivity from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/activity.tsx";
export function Header({ title }: { title: string }) {
const menus = [
@@ -13,9 +13,7 @@ export function Header({ title }: { title: string }) {
diff --git a/components/SEO.tsx b/components/SEO.tsx
index 577722b..e62c6b5 100644
--- a/components/SEO.tsx
+++ b/components/SEO.tsx
@@ -1,6 +1,11 @@
import { author } from "@/utils/website.ts";
-export const SEO = ({ title, description, ogImage, keywords }: {
+export const SEO = ({
+ title,
+ description,
+ ogImage,
+ keywords,
+}: {
title: string;
description: string;
ogImage: string;
diff --git a/deno.json b/deno.json
index f1795be..955ae4d 100644
--- a/deno.json
+++ b/deno.json
@@ -29,14 +29,8 @@
},
"lint": {
"rules": {
- "tags": [
- "fresh",
- "recommended"
- ]
+ "tags": ["fresh", "recommended"]
}
},
- "exclude": [
- "**/_fresh/*",
- "cache"
- ]
+ "exclude": ["**/_fresh/*", "cache"]
}
diff --git a/fresh.config.ts b/fresh.config.ts
index 20af78d..1b3971e 100644
--- a/fresh.config.ts
+++ b/fresh.config.ts
@@ -1,5 +1,5 @@
-import { defineConfig } from "$fresh/server.ts";
import tailwind from "$fresh/plugins/tailwind.ts";
+import { defineConfig } from "$fresh/server.ts";
import { freshSEOPlugin } from "$fresh_seo";
import manifest from "./fresh.gen.ts";
import { getPosts } from "./utils/posts.ts";
diff --git a/fresh.gen.ts b/fresh.gen.ts
index 9d0bd6f..c750d8a 100644
--- a/fresh.gen.ts
+++ b/fresh.gen.ts
@@ -2,6 +2,8 @@
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
+import type { Manifest } from "$fresh/server.ts";
+import * as $SearchButton from "./islands/SearchButton.tsx";
import * as $_404 from "./routes/_404.tsx";
import * as $_app from "./routes/_app.tsx";
import * as $_middleware from "./routes/_middleware.ts";
@@ -10,8 +12,6 @@ import * as $entry_all_ from "./routes/entry/[...all].tsx";
import * as $healthz from "./routes/healthz.tsx";
import * as $index from "./routes/index.tsx";
import * as $rss_xml from "./routes/rss.xml.ts";
-import * as $SearchButton from "./islands/SearchButton.tsx";
-import { type Manifest } from "$fresh/server.ts";
const manifest = {
routes: {
diff --git a/islands/SearchButton.tsx b/islands/SearchButton.tsx
index e15cc4f..745bcbc 100644
--- a/islands/SearchButton.tsx
+++ b/islands/SearchButton.tsx
@@ -1,6 +1,6 @@
+import docsearch from "https://esm.sh/@docsearch/js@3.5.2?target=es2020";
import { Head } from "$fresh/runtime.ts";
import { useEffect, useRef } from "preact/hooks";
-import docsearch from "https://esm.sh/@docsearch/js@3.5.2?target=es2020";
// Copied from algolia source code
type DocSearchProps = {
@@ -10,27 +10,26 @@ type DocSearchProps = {
container: HTMLElement | string;
};
-export default function SearchButton(
- props: { docsearch?: (args: DocSearchProps) => void; class?: string },
-) {
+export default function SearchButton(props: {
+ docsearch?: (args: DocSearchProps) => void;
+ class?: string;
+}) {
const ref = useRef(null);
useEffect(() => {
if (ref.current) {
- props.docsearch || docsearch({
- appId: "SV4Q5O4SYJ",
- apiKey: "73f700bbeef663cb76e7c4d3ca2f0fc4",
- indexName: "9renpoto.win",
- container: ref.current,
- });
+ props.docsearch ||
+ docsearch({
+ appId: "SV4Q5O4SYJ",
+ apiKey: "73f700bbeef663cb76e7c4d3ca2f0fc4",
+ indexName: "9renpoto.win",
+ container: ref.current,
+ });
}
}, [ref.current]);
return (
<>
-
+
import { start } from "$fresh/server.ts";
-import manifest from "./fresh.gen.ts";
import config from "./fresh.config.ts";
+import manifest from "./fresh.gen.ts";
await start(manifest, config);
diff --git a/routes/_404.tsx b/routes/_404.tsx
index dec4457..a1e897b 100644
--- a/routes/_404.tsx
+++ b/routes/_404.tsx
@@ -1,6 +1,6 @@
-import { UnknownPageProps } from "$fresh/server.ts";
+import type { PageProps } from "$fresh/server.ts";
-export default function NotFoundPage({ url }: UnknownPageProps) {
+export default function NotFoundPage({ url }: PageProps) {
return (
404 not found {url}
);
diff --git a/routes/_app.tsx b/routes/_app.tsx
index 0d0bf49..89c7a1b 100644
--- a/routes/_app.tsx
+++ b/routes/_app.tsx
@@ -1,4 +1,4 @@
-import { PageProps } from "$fresh/server.ts";
+import type { PageProps } from "$fresh/server.ts";
import { Footer } from "@/components/Footer.tsx";
import { Header } from "@/components/Header.tsx";
import { title } from "@/utils/website.ts";
diff --git a/routes/_middleware.ts b/routes/_middleware.ts
index f677454..f61a074 100644
--- a/routes/_middleware.ts
+++ b/routes/_middleware.ts
@@ -1,4 +1,4 @@
-import { FreshContext } from "$fresh/server.ts";
+import type { FreshContext } from "$fresh/server.ts";
import type { Event, PrimaryEvent } from "$ga4";
import { GA4Report, isDocument, isServerError } from "$ga4";
@@ -22,74 +22,81 @@ function ga4(
}
return;
}
- Promise.resolve().then(async () => {
- // We're tracking page views and file downloads. These are the only two
- // HTTP methods that _might_ be used.
- if (!/^(GET|POST)$/.test(request.method)) {
- return;
- }
+ Promise.resolve()
+ .then(async () => {
+ // We're tracking page views and file downloads. These are the only two
+ // HTTP methods that _might_ be used.
+ if (!/^(GET|POST)$/.test(request.method)) {
+ return;
+ }
- // If the visitor is using a web browser, only create events when we serve
- // a top level documents or download; skip assets like css, images, fonts.
- if (!isDocument(request, response) && error == null) {
- return;
- }
+ // If the visitor is using a web browser, only create events when we serve
+ // a top level documents or download; skip assets like css, images, fonts.
+ if (!isDocument(request, response) && error == null) {
+ return;
+ }
- let event: Event | null = null;
- const contentType = response.headers.get("content-type");
- if (contentType && /text\/html/.test(contentType)) {
- event = { name: "page_view", params: {} }; // Probably an old browser.
- }
+ let event: Event | null = null;
+ const contentType = response.headers.get("content-type");
+ if (contentType && /text\/html/.test(contentType)) {
+ event = { name: "page_view", params: {} }; // Probably an old browser.
+ }
- if (event == null && error == null) {
- return;
- }
+ if (event == null && error == null) {
+ return;
+ }
- // If an exception was thrown, build a separate event to report it.
- let exceptionEvent: PrimaryEvent | null;
- if (error != null) {
- exceptionEvent = {
- name: "exception",
- params: {
- description: String(error),
- fatal: isServerError(response),
- },
- };
- } else {
- exceptionEvent = null;
- }
- const userAgents: Array = ["textlint-rule-no-dead-link/1.0"];
- if (userAgents.includes(request.headers.get("user-agent"))) {
- return;
- }
- if (conn.url.pathname === "/healthz") {
- return;
- }
+ // If an exception was thrown, build a separate event to report it.
+ let exceptionEvent: PrimaryEvent | null;
+ if (error != null) {
+ exceptionEvent = {
+ name: "exception",
+ params: {
+ description: String(error),
+ fatal: isServerError(response),
+ },
+ };
+ } else {
+ exceptionEvent = null;
+ }
+ const userAgents: Array = [
+ "textlint-rule-no-dead-link/1.0",
+ ];
+ if (userAgents.includes(request.headers.get("user-agent"))) {
+ return;
+ }
+ if (conn.url.pathname === "/healthz") {
+ return;
+ }
+ if (response.status === 404) {
+ return;
+ }
- // Create basic report.
- const measurementId = GA4_MEASUREMENT_ID;
- const report = new GA4Report({
- measurementId,
- request,
- response,
- conn: {
- localAddr: conn.localAddr as Deno.Addr,
- remoteAddr: conn.remoteAddr,
- },
- });
+ // Create basic report.
+ const measurementId = GA4_MEASUREMENT_ID;
+ const report = new GA4Report({
+ measurementId,
+ request,
+ response,
+ conn: {
+ localAddr: conn.localAddr as Deno.Addr,
+ remoteAddr: conn.remoteAddr,
+ },
+ });
- // Override the default (page_view) event.
- report.event = event;
+ // Override the default (page_view) event.
+ report.event = event;
- // Add the exception event, if any.
- if (exceptionEvent != null) {
- report.events.push(exceptionEvent);
- }
+ // Add the exception event, if any.
+ if (exceptionEvent != null) {
+ report.events.push(exceptionEvent);
+ }
- await report.send();
- }).catch((err) => {
- console.error(`Internal error: ${err}`);
- });
+ await report.send();
+ })
+ .catch((err) => {
+ console.error(`Internal error: ${err}`);
+ });
}
export async function handler(
@@ -113,12 +120,6 @@ export async function handler(
err = e;
throw e;
} finally {
- ga4(
- req,
- conn,
- res,
- start,
- err,
- );
+ ga4(req, conn, res, start, err);
}
}
diff --git a/routes/about/index.tsx b/routes/about/index.tsx
index af6802c..9f2059a 100644
--- a/routes/about/index.tsx
+++ b/routes/about/index.tsx
@@ -1,9 +1,9 @@
-import { Handlers, PageProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
-import { getPost, Post } from "@/utils/posts.ts";
-import { CSS, render } from "@deno/gfm";
-import { description, title } from "@/utils/website.ts";
+import type { Handlers, PageProps } from "$fresh/server.ts";
import { SEO } from "@/components/SEO.tsx";
+import { getPost, type Post } from "@/utils/posts.ts";
+import { description, title } from "@/utils/website.ts";
+import { CSS, render } from "@deno/gfm";
export const handler: Handlers = {
async GET(_req, ctx) {
diff --git a/routes/entry/[...all].tsx b/routes/entry/[...all].tsx
index 3c12830..b68fa1b 100644
--- a/routes/entry/[...all].tsx
+++ b/routes/entry/[...all].tsx
@@ -1,9 +1,9 @@
-import { Handlers, PageProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
-import { getPost, Post } from "@/utils/posts.ts";
-import { CSS, render } from "@deno/gfm";
-import { description, title } from "@/utils/website.ts";
+import type { Handlers, PageProps } from "$fresh/server.ts";
import { SEO } from "@/components/SEO.tsx";
+import { getPost, type Post } from "@/utils/posts.ts";
+import { description, title } from "@/utils/website.ts";
+import { CSS, render } from "@deno/gfm";
import "https://esm.sh/prismjs@1.29.0/components/prism-typescript?no-check";
import "https://esm.sh/prismjs@1.29.0/components/prism-bash?no-check";
diff --git a/routes/healthz.tsx b/routes/healthz.tsx
index d4ad7b6..a0eb072 100644
--- a/routes/healthz.tsx
+++ b/routes/healthz.tsx
@@ -1,8 +1,8 @@
-import { Handlers, PageProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
-import { getPosts, Post } from "@/utils/posts.ts";
-import { description, title } from "@/utils/website.ts";
+import type { Handlers, PageProps } from "$fresh/server.ts";
import { SEO } from "@/components/SEO.tsx";
+import { getPosts, type Post } from "@/utils/posts.ts";
+import { description, title } from "@/utils/website.ts";
export const handler: Handlers = {
async GET(_req, ctx) {
@@ -23,9 +23,7 @@ export default function HealthPage(props: PageProps) {
ogImage="https://avatars3.githubusercontent.com/u/520693?s=460&v=4"
/>
-
- This blog has {posts.length} entries.
-
+ This blog has {posts.length} entries.
>
);
}
diff --git a/routes/index.tsx b/routes/index.tsx
index b83c25e..d4d2a3f 100644
--- a/routes/index.tsx
+++ b/routes/index.tsx
@@ -1,9 +1,9 @@
-import { Handlers, PageProps } from "$fresh/server.ts";
-import { getPosts, type Post } from "@/utils/posts.ts";
+import { Head } from "$fresh/runtime.ts";
+import type { Handlers, PageProps } from "$fresh/server.ts";
import { Bio } from "@/components/Bio.tsx";
-import { author, description, title } from "@/utils/website.ts";
import { SEO } from "@/components/SEO.tsx";
-import { Head } from "$fresh/runtime.ts";
+import { getPosts, type Post } from "@/utils/posts.ts";
+import { author, description, title } from "@/utils/website.ts";
export const handler: Handlers = {
async GET(_req, ctx) {
@@ -37,9 +37,7 @@ export function PostCard({ post }: { post: Post }) {
return (
-
- {post.title}
-
+ {post.title}