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

next/image #70

Merged
merged 4 commits into from
Feb 2, 2021
Merged
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
2 changes: 1 addition & 1 deletion components/pure/Article.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default styled.article`

figure,
img {
width: 100%;
max-width: 100%;
border-radius: 1rem;
position: relative;
}
Expand Down
12 changes: 2 additions & 10 deletions components/pure/HomeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Tag from 'components/pure/Tag'
import { RiExternalLinkLine } from 'react-icons/ri'
import { GrFormNextLink } from 'react-icons/gr'
import Link from 'next/link'
import { LazyLoadImage } from 'react-lazy-load-image-component'
import Image from 'next/image'

const imgSize = '60px'

Expand All @@ -15,19 +15,11 @@ export default function HomeCard({ title, description, img, link, tags }) {
<a>
<article className="relative flex items-center px-3 py-4 border-2 shadow-lg rounded-md border-accent2 hover:border-accent group bg-bg2 hover:bg-bg">
<div className="mr-2" style={{ minWidth: imgSize }}>
<LazyLoadImage
<Image
src={img.url}
alt={img.alt}
height={imgSize}
width={imgSize}
placeholder={
<img
src={img.blurUpThumb}
alt={img.alt}
width={imgSize}
height={imgSize}
/>
}
/>
</div>
<div>
Expand Down
6 changes: 6 additions & 0 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const homeQuery = `
title
alt
blurUpThumb(imgixParams: {fm: jpg, q:60})
width
height
}
link
title
Expand Down Expand Up @@ -95,6 +97,8 @@ const portfolioQuery = `
alt
title
blurUpThumb(imgixParams: {fm: jpg, q:60})
width
height
}
}
`
Expand Down Expand Up @@ -207,6 +211,8 @@ export async function getPostBySlug(slug, locale, preview = false) {
alt
title
blurUpThumb(imgixParams: {fm: jpg, q:60})
width
height
}
body(markdown: true)
${commonPageQueries}
Expand Down
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ module.exports = {
async redirects() {
return rd.map(buildRedirect)
},
images: {
domains: ['www.datocms-assets.com'],
},
webpack(config, { dev, isServer }) {
// use Preact in production
if (!dev && !isServer) {
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"react": "16.12.0",
"react-dom": "16.12.0",
"react-icons": "3.11.0",
"react-lazy-load-image-component": "^1.5.0-beta.0",
"react-text-loop": "^2.3.0",
"reaviz": "^9.3.0",
"smart-foreground": "^1.0.10",
Expand All @@ -36,7 +35,6 @@
"devDependencies": {
"@types/node": "^14.0.13",
"@types/react": "^16.9.38",
"@types/react-lazy-load-image-component": "^1.3.0",
"@types/styled-components": "^4.4.1",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
Expand Down
12 changes: 3 additions & 9 deletions pages/portfolio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { staticProps } from 'components/data-fetch/withCMS'
import withLayout from 'components/skeleton/withLayout'
import React from 'react'
import styled from 'styled-components'
import { LazyLoadImage } from 'react-lazy-load-image-component'
import Repos, { fetchAllReposData } from 'components/data-fetch/Repos'
import { FaReact, FaNodeJs } from 'react-icons/fa'
import { SiNextDotJs, SiGraphql } from 'react-icons/si'
import NpmCharts, { fetchAllNpmData } from 'components/data-fetch/NpmCharts'
import { _ } from 'lib/locales'
import Image from 'next/image'

export function go(link: string) {
window.open(`https://${link}`)
Expand Down Expand Up @@ -97,17 +97,11 @@ const Page = ({
onClick={() => window.open(project.link)}
className="flex flex-col items-center flex-shrink-0 mr-4 cursor-pointer"
>
<LazyLoadImage
<Image
src={project.picture.url}
alt={project.picture.alt}
width="150px"
placeholder={
<img
src={project.picture.blurUpThumb}
alt={project.picture.alt}
width="150px"
/>
}
height="100%"
/>
<strong className="mt-3 text-accent">{project.name}</strong>
</figure>
Expand Down
10 changes: 4 additions & 6 deletions pages/posts/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import withLayout from 'components/skeleton/withLayout'
import Link from 'next/link'
import { _ } from 'lib/locales'
import { NextSeo } from 'next-seo'
import { LazyLoadImage } from 'react-lazy-load-image-component'
import Article from 'components/pure/Article'
import { IoMdArrowRoundBack } from 'react-icons/io'
import { useRouter } from 'next/router'
import Image from 'next/image'

const formatDate = (d) => new Date(d).toLocaleDateString().replace(/-/g, '/')

Expand Down Expand Up @@ -41,13 +41,11 @@ const Page = ({ post }) => {
<Article>
{post.image?.url ? (
<figure>
<LazyLoadImage
<Image
src={post.image.url}
alt={post.image.alt}
title={post.image.title}
placeholder={
<img src={post.image.blurUpThumb} alt={post.image.alt} />
}
width={post.image.width}
height={post.image.height}
/>
<h1>{post.title}</h1>
</figure>
Expand Down
80 changes: 40 additions & 40 deletions public/favicon/manifest.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"name": "App",
"icons": [
{
"src": "\/favicon\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/favicon\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/favicon\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/favicon\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/favicon\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/favicon\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}
"name": "App",
"icons": [
{
"src": "/favicon/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "/favicon/android-icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0"
},
{
"src": "/favicon/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "/favicon/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "/favicon/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "/favicon/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
]
}