Skip to content

Commit 521a7a0

Browse files
committed
back to nextjs images
1 parent 6e8d2c5 commit 521a7a0

File tree

7 files changed

+11
-70
lines changed

7 files changed

+11
-70
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ This is a [Next.js](https://nextjs.org/) blog written in Typescript that uses [N
1313
- Robust eslint and prettier config
1414
- Supports all Notion blocks current supported by the API
1515
- Pages for photos and writing
16-
- imgix cdn for images (to reduce Vercel hosting cost and improve speed)
1716

1817
## Getting Started
1918

components/article/render-article-block.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import Image from 'next/image';
12
import React, { Fragment } from 'react';
23
import { TwitterTweetEmbed } from 'react-twitter-embed';
34
import { Text } from '../../components/article/text';
4-
import { Image, signImageUrl } from '../../components/image/imgix';
55
import { Block } from '../../pages/writing/[id]';
66
import styles from './block.module.css';
77

@@ -111,10 +111,9 @@ export const renderBlock = (block: Block, width = 640) => {
111111
case 'image':
112112
const url = value.type === 'external' ? value.external.url : value.file.url;
113113
const caption = value.caption && value.caption[0] ? value.caption[0].plain_text : '';
114-
const { src, srcSet } = signImageUrl(url, width);
115114
return (
116115
<figure>
117-
<Image src={src} srcSet={srcSet} alt={caption} width={width} />
116+
<Image src={url} alt={caption} width={width} />
118117
{caption && <figcaption>{caption}</figcaption>}
119118
</figure>
120119
);

components/image/imgix.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

next.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const nextConfig = {
2121
];
2222
},
2323

24+
images: {
25+
domains: ['s3.us-west-2.amazonaws.com'],
26+
},
27+
2428
async headers() {
2529
return [
2630
{

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@types/react-router-dom": "5.3.2",
3333
"clsx": "1.1.1",
3434
"express": "4.17.2",
35-
"imgix-core-js": "2.3.2",
3635
"next": "12.0.7",
3736
"next-compose-plugins": "2.2.1",
3837
"next-fonts": "1.5.1",

pages/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { QueryDatabaseResponse } from '@notionhq/client/build/src/api-endpoints';
22
import Head from 'next/head';
3+
import Image from 'next/image';
34
import Link from 'next/link';
45
import React from 'react';
56
import { useMeasure } from 'react-use';
67
import { Text } from '../components/article/text';
78
import Footer from '../components/homepage/footer';
89
import Header from '../components/homepage/header';
9-
import { Image, signImageUrl } from '../components/image/imgix';
1010
import { getItemsFromDatabase } from '../lib/notion';
1111
import styles from './index.module.css';
1212

@@ -28,19 +28,12 @@ const Photo = (props: { post: IProps['photos'][0] }) => {
2828
const url = (props.post.properties.Cover as any)?.files[0]?.file.url;
2929
const slug = (props.post.properties.Slug as any).rich_text[0]?.plain_text;
3030
const normalizedWidth = width < 297 ? 297 : width;
31-
const { src, srcSet } = signImageUrl(url, normalizedWidth, normalizedWidth);
3231
return (
3332
<div className={styles.gridItem} ref={ref}>
34-
{src && (
33+
{url && (
3534
<Link href={`/photos/${slug}`}>
3635
<a className={styles.photoLinkImage}>
37-
<Image
38-
src={src}
39-
srcSet={srcSet}
40-
width={normalizedWidth}
41-
height={normalizedWidth}
42-
alt={title}
43-
/>
36+
<Image src={url} width={normalizedWidth} height={normalizedWidth} alt={title} />
4437
</a>
4538
</Link>
4639
)}

pages/photos/[id].tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Head from 'next/head';
2+
import Image from 'next/image';
23
import React from 'react';
34
import { useMeasure } from 'react-use';
45
import { Text } from '../../components/article/text';
56
import Footer from '../../components/homepage/footer';
67
import Header from '../../components/homepage/header';
7-
import { Image, signImageUrl } from '../../components/image/imgix';
88
import { getBlocks, getItemsFromDatabase, getPageBySlug } from '../../lib/notion';
99
import { photosDatabaseId } from '../index';
1010
import styles from '../writing/writing.module.css';
@@ -47,17 +47,9 @@ const renderBlock = (block: Block, width = 720) => {
4747
case 'image':
4848
const url = value.type === 'external' ? value.external.url : value.file.url;
4949
const caption = value.caption && value.caption[0] ? value.caption[0].plain_text : '';
50-
const { src, srcSet } = signImageUrl(url, width, width);
5150
return (
5251
<figure>
53-
<Image
54-
width={width}
55-
height={width}
56-
src={src}
57-
srcSet={srcSet}
58-
alt={caption}
59-
style={{ minHeight: 300 }}
60-
/>
52+
<Image width={width} height={width} src={url} alt={caption} />
6153
{caption && <figcaption>{caption}</figcaption>}
6254
</figure>
6355
);

0 commit comments

Comments
 (0)