Skip to content

Commit 627d435

Browse files
committed
added linking to exhibits to sitemap
1 parent 9bb590f commit 627d435

File tree

4 files changed

+104
-143
lines changed

4 files changed

+104
-143
lines changed

src/app/exhibitsPage/page.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import Exhibit from '../../components/userComponents/Exhibit/Exhibit';
1111
/**
1212
* @param evt on click of button
1313
*/
14-
function goBack(evt: React.SyntheticEvent) {
14+
function goBack(evt : React.SyntheticEvent) {
1515
// ignore the native anchor action
1616
evt.preventDefault();
17-
1817
window.history.back();
1918
}
2019

@@ -42,7 +41,21 @@ function App() {
4241
setExhibits(fetchedExhibits);
4342
};
4443
getExhibits();
44+
// Detect the hash in URL and scroll to the element with the corresponding ID
4545
}, [exhibits]);
46+
47+
useEffect(() => {
48+
const { hash } = window.location;
49+
if (hash) {
50+
setTimeout(() => {
51+
const element = document.querySelector(hash);
52+
const yOffset = -50;
53+
const y =
54+
element.getBoundingClientRect().top + window.scrollY + yOffset;
55+
window.scrollTo({ top: y, behavior: 'smooth' });
56+
}, 1000);
57+
}
58+
}, []);
4659
return (
4760
<div className="bg-ivory">
4861
<NavBar />
@@ -70,7 +83,7 @@ function App() {
7083
{exhibits.map(exhibit => (
7184
<Exhibit
7285
title={exhibit.title}
73-
description={exhibit.description}
86+
description={exhibit.description || ''}
7487
image={exhibit.image || ''}
7588
key={exhibit.id}
7689
id={exhibit.id}

src/components/userComponents/Exhibit/Exhibit.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import Image from 'next/image';
66
* @param root0 passed in
77
* @param root0.title title of exhibit
88
* @param root0.description description of exhibit
9-
* @param root0.category category of exhibit
109
* @param root0.image image
1110
* @param root0.id id of exhibit
1211
* @returns exhibit component
@@ -23,7 +22,7 @@ export default function Exhibit({
2322
id: string;
2423
}) {
2524
return (
26-
<li key={id}>
25+
<li key={id} id={`a${id}`}>
2726
<div className="w-[100%] px-4 pt-6 pb-7 bg-mint-cream rounded flex-col justify-start items-start gap-2.5 inline-flex mt-6">
2827
<div className="flex-col justify-start items-start gap-5 flex">
2928
<div className="justify-start items-center gap-2 inline-flex">

src/components/userComponents/SiteMap/DisplayPreviewCard.tsx

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -48,100 +48,104 @@ function DisplayPreviewCard({
4848
useEffect(() => {
4949
const fetchDetails = async () => {
5050
setLoading(true);
51-
52-
let imageUrl = '';
53-
let displayName = '';
54-
55-
if ('name' in tour) {
51+
52+
let imageUrl = '';
53+
let displayName = '';
54+
55+
if ('name' in tour) {
5656
// Fetch images for a tour
5757
const images = await fetchImagesForTour(tour.id);
5858
if (images && images.length > 0) {
59-
imageUrl = images[0].url;
59+
imageUrl = images[0].url;
6060
}
61-
displayName = tour.name;
61+
displayName = tour.name;
6262
} else {
6363
// Handle as an ExhibitRow
64-
const imageObj = await fetchExhibitImage(tour.id);
64+
const imageObj = await fetchExhibitImage(tour.id);
6565
if (imageObj) {
66-
imageUrl = imageObj.image;
66+
imageUrl = imageObj.image;
6767
}
68-
displayName = tour.title;
68+
displayName = tour.title;
6969
}
70-
70+
7171
// Set state variables
7272
setPreviewImage(imageUrl);
7373
setname1(displayName);
7474
setLoading(false);
7575
};
76-
76+
7777
fetchDetails();
7878
}, [tour]);
79-
8079

8180
/** route this to spotlights */
8281

8382
return (
84-
<div className="flex flex-col items-center justify-center w-[25rem] h-[8.25rem] max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg mx-auto p-4 pb-[2.87rem] pr-[1.19rem] pl-[1.19rem] rounded-md">
85-
<div
86-
className="flex flex-row items-center rounded-md overflow-hidden bg-ivory cursor-pointer w-full sm:w-4/4 md:w-5/5 lg:w-2/2 xl:w-5/5 flex-shrink-0 shadow-xl"
87-
aria-hidden="true"
88-
>
89-
{!loading &&
83+
<div className="flex flex-col items-center justify-center w-[25rem] h-[8.25rem] max-w-xs sm:max-w-sm md:max-w-md lg:max-w-lg mx-auto p-4 pb-[2.87rem] pr-[1.19rem] pl-[1.19rem] rounded-md">
84+
<div
85+
className="flex flex-row items-center rounded-md overflow-hidden bg-ivory cursor-pointer w-full sm:w-4/4 md:w-5/5 lg:w-2/2 xl:w-5/5 flex-shrink-0 shadow-xl"
86+
aria-hidden="true"
87+
>
88+
{!loading && (
9089
<div className="relative w-[7.8125rem] z-10 h-[8.25rem] shrink-0 rounded-tl-md rounded-tr-none rounded-br-none rounded-bl-md">
91-
9290
<Image
93-
9491
src={previewImage}
95-
alt='placeholder'
92+
alt="placeholder"
9693
layout="fill"
9794
objectFit="cover"
98-
/>
99-
</div>
100-
}
101-
<div
102-
className="justify-items-center align-middle z-20 overflow-hidden w-full h-full"
103-
onClick={handleClick}
104-
onKeyDown={e => {
105-
if (handleClick && e.key === 'Enter') {
106-
handleClick();
107-
}
108-
}}
109-
role="button"
110-
tabIndex={0}
111-
>
112-
<div className="">
113-
<div className="flex justify-end items-center pt-2 pr-2" onClick={(e) => {
114-
e.stopPropagation(); // This prevents the click from propagating to the parent link
115-
handleClose(); // Then, your handleClose function is called
116-
}}>
117-
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">
118-
<path d="M10.0523 11.0274L3.35083 4.32596M10.0524 4.32596L3.35083 11.0275" stroke="#272929" strokeWidth="1.11692" strokeLinecap="round" strokeLinejoin="round"/>
119-
</svg>
120-
</div>
121-
<Link href={`/spotlightPage/${id}`}>
122-
<h3
123-
className="relative truncate text-asparagus pr-[0.31rem] pl-[0.75rem] pt-[0rem] uppercase font-light text-xs leading-normal"
124-
95+
/>
96+
</div>
97+
)}
98+
<div
99+
className="justify-items-center align-middle z-20 overflow-hidden w-full h-full"
100+
onClick={handleClick}
101+
onKeyDown={e => {
102+
if (handleClick && e.key === 'Enter') {
103+
handleClick();
104+
}
105+
}}
106+
role="button"
107+
tabIndex={0}
108+
>
109+
<div className="">
110+
<div
111+
className="flex justify-end items-center pt-2 pr-2"
112+
onClick={e => {
113+
e.stopPropagation(); // This prevents the click from propagating to the parent link
114+
handleClose(); // Then, your handleClose function is called
115+
}}
116+
>
117+
<svg
118+
xmlns="http://www.w3.org/2000/svg"
119+
width="14"
120+
height="15"
121+
viewBox="0 0 14 15"
122+
fill="none"
125123
>
124+
<path
125+
d="M10.0523 11.0274L3.35083 4.32596M10.0524 4.32596L3.35083 11.0275"
126+
stroke="#272929"
127+
strokeWidth="1.11692"
128+
strokeLinecap="round"
129+
strokeLinejoin="round"
130+
/>
131+
</svg>
132+
</div>
133+
<Link href={`/exhibitsPage/#a${id}`}>
134+
<h3 className="relative truncate text-asparagus pr-[0.31rem] pl-[0.75rem] pt-[0rem] uppercase font-light text-xs leading-normal">
126135
{category}
127136
</h3>
128-
<h3
129-
className="relative truncate font-medium font-lato text-night pr-[0.31rem] pl-[0.75rem] pt-[0.30rem] pb-[0rem] text-base leading-normal"
130-
131-
>
137+
<h3 className="relative truncate font-medium font-lato text-night pr-[0.31rem] pl-[0.75rem] pt-[0.30rem] pb-[0rem] text-base leading-normal">
132138
{name1}
133139
</h3>
134-
140+
135141
<h4 className="relative font-lato h-[2rem] pr-[0.31rem] pt-[0rem] pl-[0.75rem] pb-[2.4rem] text-shadow line-clamp-2 text-sm">
136142
{description}
137143
</h4>
138-
</Link>
139-
</div>
144+
</Link>
140145
</div>
141146
</div>
142147
</div>
143-
144-
148+
</div>
145149
);
146150
}
147151

src/supabase/exhibits/queries.tsx

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use client';
22

3-
<<<<<<< HEAD
43
import supabase from '../client';
54
import { ExhibitRow } from '../../types/types';
65

@@ -12,25 +11,10 @@ export async function fetchAllExhibits(): Promise<ExhibitRow[]> {
1211
const { data, error } = await supabase.from('exhibits').select('*');
1312
if (error) {
1413
throw new Error(error.message);
15-
=======
16-
import { ExhibitRow } from '../../types/types';
17-
18-
/**
19-
* Fetches all tours from the database.
20-
* @returns A promise that resolves to an array of ExhibitRow objects.
21-
*/
22-
export async function fetchAllExhibits(): Promise<ExhibitRow[]> {
23-
const { data, error } = await supabase.from('exhibits').select('*');
24-
if (error) {
25-
throw new Error(`An error occurred trying to read exhibits: ${error}`);
26-
>>>>>>> b191485 (added database and page)
2714
}
2815
return data;
2916
}
3017

31-
<<<<<<< HEAD
32-
33-
3418
/**
3519
* Fetches a single exhibit from the database.
3620
* @param exhibitId - The id of the exhibit to fetch.
@@ -52,29 +36,35 @@ export async function fetchExhibit(exhibitId: string): Promise<ExhibitRow> {
5236
* @param exhibitId - The id of the exhibit to fetch.
5337
* @returns A promise that resolves to a ExhibitRow object.
5438
*/
55-
export async function fetchExhibitImage(exhibitId: string): Promise<{ image: string }> {
56-
const { data, error } = await supabase
57-
.from('exhibits')
58-
.select('image')
59-
.eq('id', exhibitId)
60-
.single();
39+
export async function fetchExhibitImage(
40+
exhibitId: string,
41+
): Promise<{ image: string }> {
42+
const { data, error } = await supabase
43+
.from('exhibits')
44+
.select('image')
45+
.eq('id', exhibitId)
46+
.single();
6147

62-
if (error) {
63-
throw new Error(error.message);
64-
}
48+
if (error) {
49+
throw new Error(error.message);
50+
}
6551

66-
// Provide a default image URL if the image is null
67-
const imageUrl = data?.image ?? "https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg"; // Adjust the default image path as needed
52+
// Provide a default image URL if the image is null
53+
const imageUrl =
54+
data?.image ??
55+
'https://buffer.com/cdn-cgi/image/w=1000,fit=contain,q=90,f=auto/library/content/images/size/w1200/2023/10/free-images.jpg'; // Adjust the default image path as needed
6856

69-
return { image: imageUrl };
57+
return { image: imageUrl };
7058
}
7159

7260
/**
7361
* Inserts a single exhibit into the database.
7462
* @param exhibitData - The exhibit to insert.
7563
* @returns A promise that resolves to a ExhibitRow object.
7664
*/
77-
export async function insertExhibit(exhibitData: ExhibitRow): Promise<ExhibitRow | null> {
65+
export async function insertExhibit(
66+
exhibitData: ExhibitRow,
67+
): Promise<ExhibitRow | null> {
7868
const { data, error } = await supabase.from('exhibits').insert(exhibitData);
7969
if (error) {
8070
throw new Error(error.message);
@@ -88,7 +78,7 @@ export async function insertExhibit(exhibitData: ExhibitRow): Promise<ExhibitRow
8878
* @returns A promise that resolves to a ExhibitRow object.
8979
*/
9080
export async function updateExhibit(
91-
newExhibitData: ExhibitRow,
81+
newExhibitData: ExhibitRow,
9282
): Promise<ExhibitRow | null> {
9383
const { data, error } = await supabase
9484
.from('exhibits')
@@ -105,54 +95,9 @@ export async function updateExhibit(
10595
* @param exhibitData - The exhibit to upsert.
10696
* @returns A promise that resolves to a ExhibitRow object.
10797
*/
108-
export async function upsertTour(exhibitData: ExhibitRow): Promise<ExhibitRow | null> {
109-
const { data, error } = await supabase.from('exhibits').upsert(exhibitData);
110-
if (error) {
111-
throw new Error(error.message);
112-
}
113-
return data;
114-
}
115-
116-
/**
117-
* Deletes a single exhibit from the database.
118-
* @param exhibitId - The id of the exhibit to delete.
119-
* @returns A promise that resolves to a ExhibitRow object.
120-
*/
121-
export async function deleteExhibit(exhibitId: string): Promise<ExhibitRow | null> {
122-
const { data, error } = await supabase
123-
.from('exhibits')
124-
.delete()
125-
.eq('id', exhibitId);
126-
if (error) {
127-
throw new Error(error.message);
128-
}
129-
return data;
130-
}
131-
=======
132-
/**
133-
* Updates a single exhibit in the database.
134-
* @param newExhibitData - The updated exhibit data.
135-
* @returns A promise that resolves to a ExhibitRow object.
136-
*/
137-
export async function updateExhibit(
138-
newExhibitData: ExhibitRow,
98+
export async function upsertTour(
99+
exhibitData: ExhibitRow,
139100
): Promise<ExhibitRow | null> {
140-
const { data, error } = await supabase
141-
.from('exhibits')
142-
.update(newExhibitData)
143-
.eq('id', newExhibitData.id);
144-
if (error) {
145-
throw new Error(error.message);
146-
}
147-
return data;
148-
}
149-
150-
/**
151-
* Upserts a single exhibit into the database.
152-
* @param exhibitData - The exhibit to upsert.
153-
* @returns A promise that resolves to a ExhibitRow object.
154-
*/
155-
export async function upsertTour(exhibitData: ExhibitRow): Promise<ExhibitRow | null> {
156101
const { data, error } = await supabase.from('exhibits').upsert(exhibitData);
157102
if (error) {
158103
throw new Error(error.message);
@@ -165,7 +110,9 @@ export async function upsertTour(exhibitData: ExhibitRow): Promise<ExhibitRow |
165110
* @param exhibitId - The id of the exhibit to delete.
166111
* @returns A promise that resolves to a ExhibitRow object.
167112
*/
168-
export async function deleteExhibit(exhibitId: string): Promise<ExhibitRow | null> {
113+
export async function deleteExhibit(
114+
exhibitId: string,
115+
): Promise<ExhibitRow | null> {
169116
const { data, error } = await supabase
170117
.from('exhibits')
171118
.delete()
@@ -175,5 +122,3 @@ export async function deleteExhibit(exhibitId: string): Promise<ExhibitRow | nul
175122
}
176123
return data;
177124
}
178-
179-
>>>>>>> b191485 (added database and page)

0 commit comments

Comments
 (0)