matt HOFFNER commited on
Commit
d3becdb
·
1 Parent(s): 1f57b62
src/app/search/image/loading.jsx DELETED
@@ -1,23 +0,0 @@
1
- export default function loading() {
2
- return (
3
- <div className="pt-10 mx-2 lg:pl-52 max-w-6xl flex sm:space-x-4 flex-col sm:flex-row pb-42">
4
- <div className="animate-pulse">
5
- <div className="h-48 w-48 mb-4 bg-gray-200 rounded-md"></div>
6
- <div className="h-2 w-48 mb-2.5 bg-gray-200 rounded-md"></div>
7
- <div className="h-2 w-44 mb-2.5 bg-gray-200 rounded-md"></div>
8
- </div>
9
- <div className="hidden sm:inline-flex sm:space-x-4">
10
- <div className="animate-pulse">
11
- <div className="h-48 w-48 mb-4 bg-gray-200 rounded-md"></div>
12
- <div className="h-2 w-48 mb-2.5 bg-gray-200 rounded-md"></div>
13
- <div className="h-2 w-44 mb-2.5 bg-gray-200 rounded-md"></div>
14
- </div>
15
- <div className="animate-pulse">
16
- <div className="h-48 w-48 mb-4 bg-gray-200 rounded-md"></div>
17
- <div className="h-2 w-48 mb-2.5 bg-gray-200 rounded-md"></div>
18
- <div className="h-2 w-44 mb-2.5 bg-gray-200 rounded-md"></div>
19
- </div>
20
- </div>
21
- </div>
22
- );
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/app/search/image/page.jsx DELETED
@@ -1,36 +0,0 @@
1
- export const dynamic = "force-dynamic";
2
-
3
- import ImageSearchResults from "@/components/ImageSearchResults";
4
- import Link from "next/link";
5
-
6
- export default async function ImageSearchPage({ searchParams }) {
7
- const startIndex = searchParams.start || "1";
8
- await new Promise((resolve) => setTimeout(resolve, 2000));
9
- const response = await fetch(
10
- `https://www.googleapis.com/customsearch/v1?key=${process.env.API_KEY}&cx=${process.env.CONTEXT_KEY}&q=${searchParams.searchTerm}}&searchType=image&start=${startIndex}`
11
- );
12
-
13
- if (!response.ok) {
14
- console.log(response);
15
- throw new Error("Something went wrong");
16
- }
17
-
18
- const data = await response.json();
19
-
20
- const results = data.items;
21
-
22
- if (!results) {
23
- return (
24
- <div className="flex flex-col justify-center items-center pt-10">
25
- <h1 className="text-3xl mb-4">No results found</h1>
26
- <p className="text-lg">
27
- Try searching for something else or go back to the homepage{" "}
28
- <Link href="/" className="text-blue-500">
29
- Home
30
- </Link>
31
- </p>
32
- </div>
33
- );
34
- }
35
- return <>{results && <ImageSearchResults results={data} />}</>;
36
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/app/search/layout.jsx CHANGED
@@ -1,5 +1,5 @@
1
  import SearchHeader from "@/components/SearchHeader";
2
- import "./../globals.css";
3
 
4
  export default function SearchLayout({ children }) {
5
  return (
 
1
  import SearchHeader from "@/components/SearchHeader";
2
+ import "../../app/globals.css";
3
 
4
  export default function SearchLayout({ children }) {
5
  return (
src/app/search/web/page.jsx CHANGED
@@ -103,4 +103,4 @@ export default function WebSearchPage({ params, searchParams }) {
103
  </MemoizedReactMarkdown>
104
  </div>
105
  );
106
- }
 
103
  </MemoizedReactMarkdown>
104
  </div>
105
  );
106
+ }
src/pages/index.js CHANGED
@@ -24,12 +24,11 @@ export default function Home() {
24
  );
25
  }
26
 
27
- export async function getServerSideProps(context) {
28
  // You can access the query parameters of the request with context.query
29
  const searchParams = context.query;
30
-
31
- // TODO: Perform any necessary operations with searchParams
32
-
33
- // Return searchParams as a prop to your page
34
- return { props: { searchParams } };
35
  }
 
24
  );
25
  }
26
 
27
+ export async function getStaticProps(context) {
28
  // You can access the query parameters of the request with context.query
29
  const searchParams = context.query;
30
+ if (searchParams) {
31
+ return { props: { searchParams } };
32
+ }
33
+ return { props: {} };
 
34
  }