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: Add blog #195

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ UPSTASH_RATELIMITER_EXCLUDED_IPS="..." // List of IPs separated by comma
RESEND_API_KEY="re_..."
QWEATHER_API_KEY="..."
API_NINJA_API_KEY="..."
BASEHUB_TOKEN="bshb_pk_..."
NEXT_PUBLIC_CONVEX_URL="https://..."
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
FORCE_COLOR: 3
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
BASEHUB_TOKEN: ${{ secrets.BASEHUB_TOKEN }}

jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
QWEATHER_API_KEY: ${{ secrets.QWEATHER_API_KEY }}
API_NINJA_API_KEY: ${{ secrets.API_NINJA_API_KEY }}
NEXT_PUBLIC_CONVEX_URL: ${{ secrets.NEXT_PUBLIC_CONVEX_URL_PROD }}
BASEHUB_TOKEN: ${{ secrets.BASEHUB_TOKEN }}

jobs:
test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-convex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
FORCE_COLOR: 3
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
BASEHUB_TOKEN: ${{ secrets.BASEHUB_TOKEN }}

jobs:
update-city-data:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ coverage
.next/
out/
next-env.d.ts
analyze

# production
build
Expand Down
4 changes: 3 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "dotenv -v SKIP_ENV_VALIDATION=1 next lint",
"start": "pnpm with-env next start",
"typecheck": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --"
"with-env": "dotenv -e ../../.env --",
"postinstall": "basehub"
},
"dependencies": {
"@ducanh2912/next-pwa": "^10.2.5",
Expand All @@ -30,6 +31,7 @@
"@weatherio/city-data": "workspace:^0.1.0",
"@weatherio/types": "workspace:^0.1.0",
"@weatherio/ui": "workspace:^0.1.0",
"basehub": "^1.3.10",
"clsx": "^2.1.0",
"convex": "^1.10.0",
"dayjs": "^1.11.10",
Expand Down
55 changes: 55 additions & 0 deletions apps/web/src/app/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Metadata } from "next";
import Link from "next/link";
import { basehub } from "basehub";

export const revalidate = 60;
export const dynamic = "force-static";

export async function generateMetadata(): Promise<Metadata> {
const { weatherIoBlog } = await basehub().query({
weatherIoBlog: {
_title: true,
title: true,
subtitle: true,
},
});

return {
title: weatherIoBlog._title,
description: weatherIoBlog.subtitle,
// etc...
};
}

const BlogPage = async () => {
const { weatherIoBlog } = await basehub({ next: { revalidate: 60 } }).query({
weatherIoBlog: {
title: true,
subtitle: true,
blogPosts: {
items: {
_id: true,
_title: true,
_slug: true,
},
},
},
});

return (
<div className="container">
<div>{weatherIoBlog.subtitle}</div>
<ul>
{weatherIoBlog.blogPosts.items.map((post) => {
return (
<li key={post._id}>
<Link href={`/blog/${post._slug}`}>{post._title}</Link>
</li>
);
})}
</ul>
</div>
);
};

export default BlogPage;
33 changes: 33 additions & 0 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import "~/styles/globals.css";

import { Inter } from "next/font/google";
import Image from "next/image";

import image from "~/assets/icon-512x-512-any.png";

const inter = Inter({
subsets: ["latin"],
variable: "--font-sans",
});

export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body className={`font-sans ${inter.variable}`}>
<nav className="container z-50 mb-7 flex h-16 items-center border-b bg-background">
<div className="mr-8 hidden items-center md:flex">
<Image src={image} alt="Logo" className="mr-2 h-6 w-6" />
<span className="text-lg font-bold tracking-tight">
Weather.io&apos;s Blog
</span>
</div>
</nav>
{children}
</body>
</html>
);
}
Binary file added apps/web/src/assets/icon-512x-512-any.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading