Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pluginify blog #660

Merged
merged 14 commits into from
Mar 3, 2024
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" },
"imports": {
"@/": "./",
"$fresh/": "https://deno.land/x/fresh@1.6.3/",
"$fresh/": "https://raw.githubusercontent.com/deer/fresh/2159_plugin_routes_tailwind/",
"$gfm": "https://deno.land/x/[email protected]/mod.ts",
"preact": "https://esm.sh/[email protected]",
"preact/": "https://esm.sh/[email protected]/",
Expand Down
2 changes: 2 additions & 0 deletions fresh.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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/[email protected]/mod.ts";
import { blog } from "./plugins/blog/blog.ts";

export default {
plugins: [
Expand All @@ -17,5 +18,6 @@ export default {
tailwind(),
errorHandling,
securityHeaders,
blog(),
],
} satisfies FreshConfig;
4 changes: 0 additions & 4 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import * as $api_users_login_index from "./routes/api/users/[login]/index.ts";
import * as $api_users_login_items from "./routes/api/users/[login]/items.ts";
import * as $api_users_index from "./routes/api/users/index.ts";
import * as $api_vote from "./routes/api/vote.ts";
import * as $blog_slug_ from "./routes/blog/[slug].tsx";
import * as $blog_index from "./routes/blog/index.tsx";
import * as $dashboard_index from "./routes/dashboard/index.tsx";
import * as $dashboard_stats from "./routes/dashboard/stats.tsx";
import * as $dashboard_users from "./routes/dashboard/users.tsx";
Expand Down Expand Up @@ -48,8 +46,6 @@ const manifest = {
"./routes/api/users/[login]/items.ts": $api_users_login_items,
"./routes/api/users/index.ts": $api_users_index,
"./routes/api/vote.ts": $api_vote,
"./routes/blog/[slug].tsx": $blog_slug_,
"./routes/blog/index.tsx": $blog_index,
"./routes/dashboard/index.tsx": $dashboard_index,
"./routes/dashboard/stats.tsx": $dashboard_stats,
"./routes/dashboard/users.tsx": $dashboard_users,
Expand Down
20 changes: 20 additions & 0 deletions plugins/blog/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2023-2024 the Deno authors. All rights reserved. MIT license.
import type { Plugin } from "$fresh/server.ts";
import BlogIndex from "./routes/blog/index.tsx";
import BlogSlug from "./routes/blog/[slug].tsx";
import { toFileUrl } from "std/path/to_file_url.ts";

export function blog() {
return {
name: "blog",
routes: [{
path: "/blog",
component: BlogIndex,
}, {
path: "/blog/[slug]",
component: BlogSlug,
}],
location: import.meta.url,
projectLocation: toFileUrl(Deno.cwd()).href,
} satisfies Plugin;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023-2024 the Deno authors. All rights reserved. MIT license.
import { defineRoute } from "$fresh/server.ts";
import { CSS, render } from "$gfm";
import { getPost } from "@/utils/posts.ts";
import { getPost } from "../../utils/posts.ts";
import Head from "@/components/Head.tsx";
import Share from "@/components/Share.tsx";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023-2024 the Deno authors. All rights reserved. MIT license.
import { defineRoute } from "$fresh/server.ts";
import { getPosts, type Post } from "@/utils/posts.ts";
import { getPosts, type Post } from "../../utils/posts.ts";
import Head from "@/components/Head.tsx";

function PostCard(props: Post) {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion routes/feed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023-2024 the Deno authors. All rights reserved. MIT license.
import { Feed } from "feed";
import { getPosts } from "@/utils/posts.ts";
import { getPosts } from "@/plugins/blog/utils/posts.ts";
import { SITE_NAME } from "@/utils/constants.ts";
import { defineRoute } from "$fresh/server.ts";

Expand Down
Loading