Skip to content

Commit eb3d7de

Browse files
committed
update to next 12
1 parent a844a93 commit eb3d7de

File tree

11 files changed

+164
-328
lines changed

11 files changed

+164
-328
lines changed

lib/notion.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ const notion = new Client({
44
auth: process.env.NOTION_TOKEN,
55
});
66

7-
export const getDatabase = async (databaseId: string) => {
7+
export const getItemsFromDatabase = async (databaseId: string) => {
88
const response = await notion.databases.query({
99
database_id: databaseId,
1010
});
1111
return response.results;
1212
};
1313

14-
export const getPage = async (pageId: string) => {
14+
export const getPageById = async (pageId: string) => {
1515
const response = await notion.pages.retrieve({ page_id: pageId });
1616
return response;
1717
};

package-lock.json

Lines changed: 132 additions & 304 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@types/react-router-dom": "5.3.2",
3333
"clsx": "1.1.1",
3434
"express": "4.17.1",
35-
"next": "11.1.2",
35+
"next": "12.0.0",
3636
"next-compose-plugins": "2.2.1",
3737
"next-fonts": "1.5.1",
3838
"next-secure-headers": "2.2.0",
@@ -50,7 +50,7 @@
5050
"@typescript-eslint/eslint-plugin-tslint": "5.2.0",
5151
"@typescript-eslint/parser": "5.2.0",
5252
"eslint": "8.1.0",
53-
"eslint-config-next": "11.1.2",
53+
"eslint-config-next": "12.0.0",
5454
"eslint-plugin-import": "2.25.2",
5555
"eslint-plugin-react": "7.26.1",
5656
"eslint-plugin-react-hooks": "4.2.0",

pages/api/rss.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Request, Response } from 'express';
2-
import { getDatabase } from '../../lib/notion';
2+
import { getItemsFromDatabase } from '../../lib/notion';
33
import { postsDatabaseId } from '../index';
44

55
const title = 'Articles by Brennan Moore';
66
const description = 'todo';
77
const baseUrl = 'https://www.zamaing.com/';
88

99
const getRssXml = async () => {
10-
const posts = await getDatabase(postsDatabaseId);
10+
const posts = await getItemsFromDatabase(postsDatabaseId);
1111

1212
const orderedPosts = posts
1313
.filter(

pages/api/sitemap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Request, Response } from 'express';
22
import { SitemapStream, streamToPromise } from 'sitemap';
3-
import { getDatabase } from '../../lib/notion';
3+
import { getItemsFromDatabase } from '../../lib/notion';
44
import { postsDatabaseId } from '../index';
55

66
export default async (_req: Request, res: Response) => {
7-
const posts = await getDatabase(postsDatabaseId);
7+
const posts = await getItemsFromDatabase(postsDatabaseId);
88

99
const smStream = new SitemapStream({
1010
hostname: 'https://www.kelp.nyc',

pages/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import React from 'react';
66
import { Text } from '../components/article/text';
77
import Footer from '../components/homepage/footer';
88
import Header from '../components/homepage/header';
9-
import { getDatabase } from '../lib/notion';
9+
import { getItemsFromDatabase } from '../lib/notion';
1010
import styles from './index.module.css';
1111

1212
export const postsDatabaseId = process.env.NOTION_POSTS_DATABASE_ID!;
@@ -208,8 +208,8 @@ export default function Home(props: IProps) {
208208
}
209209

210210
export const getStaticProps = async () => {
211-
const posts = await getDatabase(postsDatabaseId);
212-
const photos = await getDatabase(photosDatabaseId);
211+
const posts = await getItemsFromDatabase(postsDatabaseId);
212+
const photos = await getItemsFromDatabase(photosDatabaseId);
213213

214214
return {
215215
props: {

pages/photos/[id].tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { Fragment } from 'react';
44
import { Text } from '../../components/article/text';
55
import Footer from '../../components/homepage/footer';
66
import Header from '../../components/homepage/header';
7-
import { getBlocks, getDatabase, getPageBySlug } from '../../lib/notion';
7+
import { getBlocks, getItemsFromDatabase, getPageBySlug } from '../../lib/notion';
88
import { photosDatabaseId } from '../index';
99
import styles from '../writing/writing.module.css';
1010

@@ -100,7 +100,7 @@ export default function Post({ page, blocks }: Params) {
100100
}
101101

102102
export const getStaticPaths = async () => {
103-
const database = await getDatabase(photosDatabaseId);
103+
const database = await getItemsFromDatabase(photosDatabaseId);
104104
const paths = database
105105
.map((post) => {
106106
const slug = (post.properties.Slug as any).rich_text[0]?.plain_text;

pages/photos/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Head from 'next/head';
33
import React from 'react';
44
import Footer from '../../components/homepage/footer';
55
import Header from '../../components/homepage/header';
6-
import { getDatabase } from '../../lib/notion';
6+
import { getItemsFromDatabase } from '../../lib/notion';
77
import { PhotosGrid, photosDatabaseId } from '../index';
88
import styles from '../index.module.css';
99

@@ -46,7 +46,7 @@ export default function Home(props: IProps) {
4646
}
4747

4848
export const getStaticProps = async () => {
49-
const photos = await getDatabase(photosDatabaseId);
49+
const photos = await getItemsFromDatabase(photosDatabaseId);
5050

5151
return {
5252
props: {

pages/writing/[id].tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { renderBlock } from '../../components/article/render-article-block';
55
import { Text } from '../../components/article/text';
66
import Footer from '../../components/homepage/footer';
77
import Header from '../../components/homepage/header';
8-
import { getBlocks, getDatabase, getPageBySlug } from '../../lib/notion';
8+
import { getBlocks, getItemsFromDatabase, getPageBySlug } from '../../lib/notion';
9+
import Custom404 from '../404';
910
import { PostsList, postsDatabaseId } from '../index';
1011
import styles from './writing.module.css';
1112

@@ -15,7 +16,7 @@ export type Block = Params['blocks'][0];
1516

1617
export default function Post({ page, blocks, posts }: Params) {
1718
if (!page || !blocks) {
18-
return <div />;
19+
return <Custom404 />;
1920
}
2021
const excerpt = (page.properties.Excerpt as any).rich_text[0]?.plain_text;
2122
const title = (page.properties.Title as any).title[0].plain_text;
@@ -60,7 +61,7 @@ export default function Post({ page, blocks, posts }: Params) {
6061
}
6162

6263
export const getStaticPaths = async () => {
63-
const database = await getDatabase(postsDatabaseId);
64+
const database = await getItemsFromDatabase(postsDatabaseId);
6465
const paths = database
6566
.map((post) => {
6667
const slug = (post.properties.Slug as any).rich_text[0]?.plain_text;
@@ -77,7 +78,7 @@ export const getStaticPaths = async () => {
7778

7879
export const getStaticProps = async (context: { params: { id: string } }) => {
7980
const { id } = context.params;
80-
const posts = await getDatabase(postsDatabaseId);
81+
const posts = await getItemsFromDatabase(postsDatabaseId);
8182
const page = await getPageBySlug(id, postsDatabaseId);
8283
const blocks = await getBlocks(page.id);
8384

pages/writing/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Head from 'next/head';
33
import React from 'react';
44
import Footer from '../../components/homepage/footer';
55
import Header from '../../components/homepage/header';
6-
import { getDatabase } from '../../lib/notion';
6+
import { getItemsFromDatabase } from '../../lib/notion';
77
import { PostsList, postsDatabaseId } from '../index';
88
import styles from '../index.module.css';
99

@@ -53,7 +53,7 @@ export default function Home(props: IProps) {
5353
}
5454

5555
export const getStaticProps = async () => {
56-
const posts = await getDatabase(postsDatabaseId);
56+
const posts = await getItemsFromDatabase(postsDatabaseId);
5757

5858
return {
5959
props: {

0 commit comments

Comments
 (0)