Skip to content

Commit f306911

Browse files
authored
Merge pull request #18 from khaykingleb/improve-links
Improve links
2 parents 5678ccd + a115c10 commit f306911

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ format: ## Format project
7777
pnpm run format
7878
.PHONY: format
7979

80+
ngrok-dev: ## Run ngrok for development server
81+
@echo "Running ngrok."
82+
ngrok http 5173
83+
.PHONY: ngrok-dev
84+
85+
ngrok-prod: ## Run ngrok for production server
86+
@echo "Running ngrok."
87+
ngrok http 3000
88+
.PHONY: ngrok-prod
89+
8090
##@ Miscullaneous
8191

8292
create-secrets-baseline: ## Create secrets baseline file

app/data/posts.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface Post {
2+
id: number;
3+
title: string;
4+
content: string;
5+
notionPageId: string;
6+
tags: string[];
7+
}
8+
9+
export const posts: Post[] = [
10+
{
11+
id: 1,
12+
title: "Introduction to Digital Signal Processing",
13+
content: "Created: 2024/09/22",
14+
notionPageId: "5987cc697c874323920215fbaad8cbbd", // pragma: allowlist secret
15+
tags: ["notes", "speech", "dsp"],
16+
},
17+
];

app/routes/_index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const meta: MetaFunction = () => {
99
{ title: "About | Gleb Khaykin" },
1010
{ property: "og:title", content: "About | Gleb Khaykin" },
1111
{ property: "og:description", content: "Gleb Khaykin's personal website" },
12+
{
13+
property: "og:image",
14+
content: "/img/van_gogh_wheatfield_with_crows.jpg",
15+
},
1216
];
1317
};
1418

app/routes/blog.$pageid.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defer, LoaderFunction, LoaderFunctionArgs } from "@remix-run/node";
2-
import { Await, useLoaderData } from "@remix-run/react";
2+
import { Await, MetaFunction, useLoaderData } from "@remix-run/react";
33
import { NotionAPI } from "notion-client";
44
import React, { lazy, Suspense } from "react";
55
import { ClientOnly } from "remix-utils/client-only";
@@ -14,6 +14,7 @@ import { NotionRenderer } from "vendor/react-notion-x/packages/react-notion-x";
1414

1515
import { Footer } from "~/components/organisms/Footer";
1616
import { Header } from "~/components/organisms/Header";
17+
import { Post, posts } from "~/data/posts";
1718

1819
const Equation = lazy(() =>
1920
import("react-notion-x/build/third-party/equation").then((module) => ({
@@ -91,7 +92,27 @@ export const loader: LoaderFunction = async ({
9192
throw new Error("Page ID is required");
9293
}
9394
const recordMapPromise = notion.getPage(pageId);
94-
return defer({ recordMap: recordMapPromise });
95+
const post = posts.find((p) => p.notionPageId === pageId);
96+
return defer({ recordMap: recordMapPromise, post });
97+
};
98+
99+
export const meta: MetaFunction<typeof loader> = ({
100+
data,
101+
}: {
102+
data: { post: Post };
103+
}) => {
104+
const { title, content, tags } = data.post;
105+
const description = `${content}; Tags: ${tags.join(", ")}`;
106+
return [
107+
{ title: `${title} | Gleb Khaykin` },
108+
{ property: "og:title", content: `${title} | Gleb Khaykin` },
109+
{ property: "og:description", content: description },
110+
{ property: "og:type", content: "article" },
111+
{
112+
property: "og:image",
113+
content: "/img/van_gogh_wheatfield_with_cypresses.jpg",
114+
},
115+
];
95116
};
96117

97118
export default function NotionRoute() {

app/routes/blog._index.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
11
import { MetaFunction } from "@remix-run/node";
2-
import React, { useCallback, useEffect, useMemo, useState } from "react";
2+
import { useCallback, useEffect, useMemo, useState } from "react";
33

44
import { TagSearchBar } from "~/components/molecules/TagSearchBar";
5-
import type { CarouselItem } from "~/components/organisms/Carousel";
65
import { Carousel } from "~/components/organisms/Carousel";
76
import { Footer } from "~/components/organisms/Footer";
87
import { Header } from "~/components/organisms/Header";
98
import { Pagination } from "~/components/organisms/Pagination";
10-
11-
const posts: CarouselItem[] = [
12-
{
13-
id: 1,
14-
title: "Introduction to Digital Signal Processing",
15-
content: "Created: 2024/09/22",
16-
notionPageId: "5987cc697c874323920215fbaad8cbbd", // pragma: allowlist secret
17-
tags: ["notes", "speech", "dsp"],
18-
},
19-
];
9+
import { posts } from "~/data/posts";
2010

2111
export const meta: MetaFunction = () => {
2212
return [
2313
{ title: "Posts | Gleb Khaykin" },
2414
{ property: "og:title", content: "Posts | Gleb Khaykin" },
2515
{ property: "og:description", content: "Gleb Khaykin's personal website" },
16+
{
17+
property: "og:image",
18+
content: "/img/van_gogh_wheatfield_under_thunderclouds.jpg",
19+
},
2620
];
2721
};
2822

0 commit comments

Comments
 (0)