Commit 33458a32 by PLN Committed by PLN (Algolia)

fix: solve remaining regressions

parent 526407e3
...@@ -13,7 +13,7 @@ function BackHome() { ...@@ -13,7 +13,7 @@ function BackHome() {
size="lg" size="lg"
cursor="pointer" cursor="pointer"
> >
<a>🏠 Retour à la Galerie</a> 🏠 Retour à la Galerie
</Button> </Button>
</Link> </Link>
</Flex> </Flex>
......
import Image from "next/image"; import Image from "next/image";
import { import { Center, Text, Link, Button } from "@chakra-ui/react";
Box,
Divider,
Center,
Text,
Flex,
Spacer,
Button,
} from "@chakra-ui/react";
import Head from "next/head";
import Link from "next/link";
function NavLinks({ prev, next }) { function NavLinks({ prev, next }) {
let prevText = next == 2 ? "Dernière" : "Précédente"; let prevText = next == 2 ? "Dernière" : "Précédente";
...@@ -18,13 +8,13 @@ function NavLinks({ prev, next }) { ...@@ -18,13 +8,13 @@ function NavLinks({ prev, next }) {
<Center p="6" justify="space-between"> <Center p="6" justify="space-between">
<Link href={"/photos/" + prev}> <Link href={"/photos/" + prev}>
<Button <Button
as="a"
borderRadius="full" borderRadius="full"
colorScheme="gray" colorScheme="gray"
fontSize={["sm", "md", "xl"]} fontSize={["sm", "md", "xl"]}
size="lg" size="lg"
mx={2} mx={2}
cursor="pointer" cursor="pointer"
textDecoration="none"
> >
<Text mr={2}></Text> <Text mr={2}></Text>
<Text>{prevText}</Text> <Text>{prevText}</Text>
...@@ -32,13 +22,13 @@ function NavLinks({ prev, next }) { ...@@ -32,13 +22,13 @@ function NavLinks({ prev, next }) {
</Link> </Link>
<Link href={"/photos/" + next}> <Link href={"/photos/" + next}>
<Button <Button
as="a"
borderRadius="full" borderRadius="full"
colorScheme="gray" colorScheme="gray"
fontSize={["sm", "md", "xl"]} fontSize={["sm", "md", "xl"]}
size="lg" size="lg"
mx={2} mx={2}
cursor="pointer" cursor="pointer"
textDecoration="none"
> >
<Text>{nextText}</Text> <Text>{nextText}</Text>
<Text ml={2}></Text> <Text ml={2}></Text>
......
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
const sizeOf = require('image-size') const sizeOf = require("image-size");
function getContentDirectory(name) { function getContentDirectory(name) {
return path.join(process.cwd(), "public", name); return path.join(process.cwd(), "public", name);
...@@ -22,13 +22,13 @@ function getAllPhotos() { ...@@ -22,13 +22,13 @@ function getAllPhotos() {
console.log(`gACD: total pictures: ${fileNames.length}`); console.log(`gACD: total pictures: ${fileNames.length}`);
return fileNames.map((f, i) => { return fileNames.map((f, i) => {
let id = i+1; // Photos are 1-indexed let id = i + 1; // Photos are 1-indexed
let photo = { let photo = {
id: id, id: id,
path: photoPath(f), path: photoPath(f),
dimensions: photoDimensions(photoPath(f)), dimensions: photoDimensions(photoPath(f)),
prev: getPrevID(id), prev: getPrevID(id),
next: getNextID(id) next: getNextID(id),
}; };
console.log(`Photo ${photo.id} -> ${photo.prev} -> X -> ${photo.next}`); console.log(`Photo ${photo.id} -> ${photo.prev} -> X -> ${photo.next}`);
return photo; return photo;
...@@ -39,26 +39,25 @@ function getPhotoById(id) { ...@@ -39,26 +39,25 @@ function getPhotoById(id) {
const contentDirectory = getContentDirectory(photoDir); const contentDirectory = getContentDirectory(photoDir);
const fileNames = fs.readdirSync(contentDirectory); const fileNames = fs.readdirSync(contentDirectory);
const path = photoPath(fileNames[id - 1]); const path = photoPath(fileNames[id - 1]);
return { id: id, return {
id: id,
path: path, path: path,
dimensions: photoDimensions(path), dimensions: photoDimensions(path),
prev: getPrevID(id), prev: getPrevID(id),
next: getNextID(id) next: getNextID(id),
}; // Photos are 1-indexed }; // Photos are 1-indexed
} }
function getNextID(id) { function getNextID(id) {
const contentDirectory = getContentDirectory(photoDir); const contentDirectory = getContentDirectory(photoDir);
const count = fs.readdirSync(contentDirectory).length; const count = fs.readdirSync(contentDirectory).length;
return (id % count)+1; return ((count + id) % count) + 1;
} }
function getPrevID(id) { function getPrevID(id) {
const contentDirectory = getContentDirectory(photoDir); const contentDirectory = getContentDirectory(photoDir);
const count = fs.readdirSync(contentDirectory).length; const count = fs.readdirSync(contentDirectory).length;
return ((id+count-2) % count)+1; return ((id - 1) % count) || count;
} }
export { getAllPhotos, getPhotoById, getNextID, getPrevID }; export { getAllPhotos, getPhotoById, getNextID, getPrevID };
// pages/_app.js // pages/_app.js
import { ChakraProvider, Divider, Box, Text } from "@chakra-ui/react"; import {
import Link from "next/link"; ChakraProvider,
Container,
Divider,
Box,
Text,
Link,
Stack,
} from "@chakra-ui/react";
function MyApp({ Component, pageProps }) { function MyApp({ Component, pageProps }) {
return ( return (
<ChakraProvider> <ChakraProvider>
<Component {...pageProps} /> <Component {...pageProps} />
<Divider /> <Divider />
<Box m="2"> <Container
as={Stack}
maxW={"6xl"}
py={4}
direction={{ base: "column", md: "row" }}
spacing={2}
justify="center"
align={{ md: "center" }}
>
<Text fontSize="sm" textAlign="center"> <Text fontSize="sm" textAlign="center">
Conçu par{" "} Conçu par{" "}
<Link <Link
href="https://me.plnech.fr" href="https://me.plnech.fr"
isExternal
_hover={{ textDecoration: "underline" }} _hover={{ textDecoration: "underline" }}
> >
Paul-Louis Nech Paul-Louis
</Link>{" "} </Link>{" "}
grace aux contenus partagés par les proches de Philippe -{" "} grace aux contenus partagés par les proches de Philippe.
<Link href="/credits"> </Text>
<u>Crédits</u> <Text fontSize="sm" >
<Link href="/credits" >
Crédits
</Link> </Link>
</Text> </Text>
</Box> </Container>
</ChakraProvider> </ChakraProvider>
); );
} }
......
// pages/index.js // pages/index.js
import Head from "next/head"; import Head from "next/head";
import { Box, Container, Divider, Text, Wrap, WrapItem } from "@chakra-ui/react"; import {
Box,
Container,
Divider,
Text,
Wrap,
WrapItem,
} from "@chakra-ui/react";
import Image from "next/image"; import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
import BackHome from "../components/BackHome";
export async function getStaticProps() { export async function getStaticProps() {
let credits = [ let credits = [
...@@ -15,7 +23,11 @@ export async function getStaticProps() { ...@@ -15,7 +23,11 @@ export async function getStaticProps() {
text: "Pour l'hébergement de ces pages", text: "Pour l'hébergement de ces pages",
link: "vercel.com", link: "vercel.com",
}, },
{ title: "Next.JS", text: "Utilisé pour construire le site", link: "nextjs.org" }, {
title: "Next.JS",
text: "Utilisé pour construire le site",
link: "nextjs.org",
},
]; ];
return { return {
props: { props: {
...@@ -26,56 +38,50 @@ export async function getStaticProps() { ...@@ -26,56 +38,50 @@ export async function getStaticProps() {
export default function Credits({ credits }) { export default function Credits({ credits }) {
return ( return (
<div> <Box p="2rem" bg="gray.200" minH="100vh">
<Head> <Head>
<title>Philippe Bureau - Crédits</title> <title>Philippe Bureau - Crédits</title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<Box overflow="hidden" bg="gray.100" minH="100vh"> </Head>
<Container> <BackHome mt="10px" />
<Container>
<Text
color="gray.700"
fontWeight="semibold"
m="1rem"
textAlign="center"
textDecoration="underline"
fontSize={["xl", "3xl", "4xl", "5xl"]}
>
Philippe Bureau - Crédits
</Text>
</Container>
<Wrap px="1rem" spacing={"4px"} justify="space-around">
{credits.map((credit) => (
<WrapItem
key={"wrap-" + credit.title}
m={"30px"}
bg="white"
// lineHeight="0"
maxW="sm"
borderWidth="1px"
borderRadius={"10px"}
>
<Text <Text
color="gray.700" color="gray.700"
fontWeight="semibold" fontWeight="semibold"
fontSize="2xl"
m="1rem" m="1rem"
textAlign="center"
textDecoration="underline"
fontSize={["5xl", "5xl", "6xl", "6xl"]}
> >
Philippe Bureau - Crédits {credit.title}
</Text> </Text>
</Container> <br />
<Wrap px="1rem" spacing={"4px"} justify="center"> <Text color="gray.500" fontWeight="semibold" fontSize="sm" m="1rem">
{credits.map((credit) => ( {credit.text}
<WrapItem </Text>
key={"wrap-" + credit.title} </WrapItem>
m={"30px"} ))}
bg="white" </Wrap>
lineHeight="0" </Box>
maxW="sm"
borderWidth="1px"
borderRadius={"10px"}
>
<Text
color="gray.700"
fontWeight="semibold"
fontSize="2xl"
m="1rem"
>
{credit.title}
</Text>
<br />
<Text
color="gray.500"
fontWeight="semibold"
fontSize="sm"
m="1rem"
>
{credit.text}
</Text>
</WrapItem>
))}
</Wrap>
</Box>
</Head>
</div>
); );
} }
...@@ -71,7 +71,7 @@ export default function Home({ data, placeholders }) { ...@@ -71,7 +71,7 @@ export default function Home({ data, placeholders }) {
quality={20} quality={20}
// placeholder="blur" // placeholder="blur"
priority priority
// blurDataURL={`${placeholders[photo.id]}`} blurDataURL={`${placeholders[photo.id]}`}
/> />
</Link> </Link>
</WrapItem> </WrapItem>
......
...@@ -70,7 +70,7 @@ export default function Photos({ photo, placeholder }) { ...@@ -70,7 +70,7 @@ export default function Photos({ photo, placeholder }) {
</Head> </Head>
<BackHome /> <BackHome />
<NavLinks prev={pic.prev} next={pic.next} /> <NavLinks prev={photo.prev} next={photo.next} />
<Center> <Center>
<Link href={photo.path}> <Link href={photo.path}>
...@@ -89,7 +89,7 @@ export default function Photos({ photo, placeholder }) { ...@@ -89,7 +89,7 @@ export default function Photos({ photo, placeholder }) {
</Center> </Center>
<Divider my="1rem" /> <Divider my="1rem" />
<NavLinks prev={pic.prev} next={pic.next} /> <NavLinks prev={photo.prev} next={photo.next} />
</Box> </Box>
); );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment