|
1 | | -import AddressIcon from '../icons/address-icon'; |
2 | | -import DateIcon from '../icons/date-icon'; |
3 | | -import LogisticsItem from './logistics-item'; |
4 | | -import classes from './event-logistics.module.css'; |
| 1 | +import AddressIcon from "../icons/address-icon"; |
| 2 | +import DateIcon from "../icons/date-icon"; |
| 3 | +import LogisticsItem from "./logistics-item"; |
| 4 | +import classes from "./event-logistics.module.css"; |
| 5 | +import Image from "next/image"; |
| 6 | + |
| 7 | +// IMAGE OPTIMISATION: |
| 8 | +// Next.js has built-in Image optimisation |
| 9 | +// It automatically generates suitable image on request |
| 10 | +// And caches the image on server for future use |
| 11 | +// Next.js re-fetches the image on window resize |
| 12 | +// It needs height and width property |
| 13 | +// It'll fetch the image based on the height and width passed to it |
| 14 | +// But the image will be displayed based on the CSS |
5 | 15 |
|
6 | 16 | function EventLogistics(props) { |
7 | 17 | const { date, address, image, imageAlt } = props; |
8 | 18 |
|
9 | | - const humanReadableDate = new Date(date).toLocaleDateString('en-US', { |
10 | | - day: 'numeric', |
11 | | - month: 'long', |
12 | | - year: 'numeric', |
| 19 | + const humanReadableDate = new Date(date).toLocaleDateString("en-US", { |
| 20 | + day: "numeric", |
| 21 | + month: "long", |
| 22 | + year: "numeric", |
13 | 23 | }); |
14 | | - const addressText = address.replace(', ', '\n'); |
| 24 | + const addressText = address.replace(", ", "\n"); |
15 | 25 |
|
16 | 26 | return ( |
17 | 27 | <section className={classes.logistics}> |
18 | 28 | <div className={classes.image}> |
19 | | - <img src={`/${image}`} alt={imageAlt} /> |
| 29 | + <Image src={`/${image}`} alt={imageAlt} width={400} height={400} /> |
| 30 | + {/* <img src={`/${image}`} alt={imageAlt} /> */} |
20 | 31 | </div> |
21 | 32 | <ul className={classes.list}> |
22 | 33 | <LogisticsItem icon={DateIcon}> |
|
0 commit comments