diff --git a/fresh.config.ts b/fresh.config.ts index 95cd5313..a4acddf8 100644 --- a/fresh.config.ts +++ b/fresh.config.ts @@ -4,7 +4,6 @@ import kvOAuthPlugin from "./plugins/kv_oauth.ts"; import sessionPlugin from "./plugins/session.ts"; import errorHandling from "./plugins/error_handling.ts"; import securityHeaders from "./plugins/security_headers.ts"; -import welcomePlugin from "./plugins/welcome.ts"; import type { FreshConfig } from "$fresh/server.ts"; import { ga4Plugin } from "https://deno.land/x/fresh_ga4@0.0.4/mod.ts"; import { blog } from "./plugins/blog/mod.ts"; @@ -12,7 +11,6 @@ import { blog } from "./plugins/blog/mod.ts"; export default { plugins: [ ga4Plugin(), - welcomePlugin, kvOAuthPlugin, sessionPlugin, tailwind(), diff --git a/plugins/welcome.ts b/plugins/welcome.ts deleted file mode 100644 index 22e66cc1..00000000 --- a/plugins/welcome.ts +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2023-2025 the Deno authors. All rights reserved. MIT license. -import type { Plugin } from "$fresh/server.ts"; -import { isGitHubSetup } from "@/utils/github.ts"; -import { redirect } from "@/utils/http.ts"; - -export default { - name: "welcome", - middlewares: [{ - path: "/", - middleware: { - handler: async (req, ctx) => { - const { pathname } = new URL(req.url); - return !isGitHubSetup() && pathname !== "/welcome" && - ctx.destination === "route" - ? redirect("/welcome") - : await ctx.next(); - }, - }, - }], -} as Plugin; diff --git a/routes/index.tsx b/routes/index.tsx index e8eb742c..8d20f3a6 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -3,8 +3,14 @@ import type { State } from "@/plugins/session.ts"; import Head from "@/components/Head.tsx"; import ItemsList from "@/islands/ItemsList.tsx"; import { defineRoute } from "$fresh/server.ts"; +import { isGitHubSetup } from "@/utils/github.ts"; +import { redirect } from "@/utils/http.ts"; export default defineRoute((_req, ctx) => { + if (!isGitHubSetup() && ctx.url.pathname !== "/welcome") { + return redirect("/welcome"); + } + const isSignedIn = ctx.state.sessionUser !== undefined; const endpoint = "/api/items";