Skip to content

Commit 20602b2

Browse files
Merge remote-tracking branch 'refs/remotes/origin/staging' into staging
2 parents d07b9f7 + 146a038 commit 20602b2

File tree

13 files changed

+42
-22
lines changed

13 files changed

+42
-22
lines changed

public/sitemap.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<urlset
3+
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
6+
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
7+
8+
<url>
9+
<loc>https://papers.codechefvit.com/</loc>
10+
<lastmod>2024-11-03T19:02:33+00:00</lastmod>
11+
<priority>1.00</priority>
12+
</url>
13+
<url>
14+
<loc>https://papers.codechefvit.com/upload</loc>
15+
<lastmod>2024-11-03T19:02:33+00:00</lastmod>
16+
<priority>0.80</priority>
17+
</url>
18+
19+
20+
</urlset>

src/app/api/search/route.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,34 @@ export async function GET(req: Request) {
99
await connectToDatabase();
1010
const url = new URL(req.url);
1111
const searchText = url.searchParams.get("text");
12+
console.log(searchText);
1213

1314
if (!searchText) {
1415
return NextResponse.json(
1516
{ message: "Text query parameter is required" },
16-
{ status: 400 }
17+
{ status: 400 },
1718
);
1819
}
1920

2021
const subjects = await Paper.aggregate([
21-
{ $match: { subject: { $regex: searchText, $options: "i" } } },
22+
{ $match: { subject: { $regex: new RegExp(searchText, "i") } } }, // case-insensitive partial match
2223
{ $group: { _id: "$subject" } },
2324
{ $project: { _id: 0, subject: "$_id" } },
2425
]);
26+
console.log(subjects);
2527

2628
if (subjects.length === 0) {
2729
return NextResponse.json(
2830
{ message: "No subjects found for the specified text" },
29-
{ status: 404 }
31+
{ status: 404 },
3032
);
3133
}
3234

3335
return NextResponse.json({ subjects }, { status: 200 });
3436
} catch (error) {
3537
return NextResponse.json(
3638
{ message: "Failed to fetch subjects", error },
37-
{ status: 500 }
39+
{ status: 500 },
3840
);
3941
}
4042
}

src/app/api/upload/route.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function POST(req: Request) {
5656
);
5757
}
5858
} else {
59-
[public_id_cloudinary, finalUrl] = await uploadPDFFile(files[0] as File, uploadPreset);
59+
[public_id_cloudinary, finalUrl] = await uploadPDFFile(files[0]!, uploadPreset);
6060
}
6161
const thumbnailResponse = cloudinary.v2.image(finalUrl!, {
6262
format: "jpg",
@@ -99,17 +99,15 @@ async function uploadPDFFile(file: File | ArrayBuffer, uploadPreset: string) {
9999
}
100100
else // for images that are pdf
101101
{
102-
bytes = file as ArrayBuffer;
102+
bytes = file;
103103
}
104104
return uploadFile(bytes, uploadPreset, "application/pdf")
105105
}
106106
async function uploadFile(bytes: ArrayBuffer, uploadPreset: string, fileType: string) {
107107
try {
108108
const buffer = Buffer.from(bytes);
109109
const dataUrl = `data:${fileType};base64,${buffer.toString("base64")}`;
110-
111-
const uploadResult: CloudinaryUploadResult =
112-
await cloudinary.v2.uploader.unsigned_upload(dataUrl, uploadPreset);
110+
const uploadResult = await cloudinary.v2.uploader.unsigned_upload(dataUrl, uploadPreset) as CloudinaryUploadResult;
113111
return [uploadResult.public_id, uploadResult.secure_url ];
114112
} catch (e) {
115113
throw (e);

src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default function RootLayout({
8989
}) {
9090
return (
9191
<html lang="en" className={`${GeistSans.variable}`}>
92+
<meta name="google-site-verification" content="SjVFuH8GzIj3Ooh2JcWufBoSMWTzo77TACHomonCKVs" />
9293
<body>
9394
<ThemeProvider
9495
attribute="class"

src/components/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Card = ({
5858
key={paper._id}
5959
className={`flex flex-col justify-between w-56 space-y-1 rounded-xl border border-black dark:border-[#7480FF]/25 ${checked ? "bg-[#EEF2FF] dark:bg-[#050b1f]" : ""} p-4 `}
6060
>
61-
<Link href={paper.finalUrl} target="_blank" rel="noopener noreferrer">
61+
<Link href={`/paper/${paper._id}`} target="_blank" rel="noopener noreferrer">
6262
<Image
6363
src={paper.thumbnailUrl}
6464
alt={paper.subject}
@@ -90,7 +90,7 @@ const Card = ({
9090
<p className="text-sm">Select</p>
9191
</div>
9292
<div className="flex gap-2">
93-
<Link href={paper.finalUrl} target="_blank" rel="noopener noreferrer">
93+
<Link href={`/paper/${paper._id}`} target="_blank" rel="noopener noreferrer">
9494
<Eye size={20} />
9595
</Link>
9696
<button onClick={() => handleDownload(paper)}>

src/components/CatalogueContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ const CatalogueContent = () => {
111111
setLoading(true);
112112

113113
try {
114-
const papersResponse = await axios.get("/api/papers", {
114+
const papersResponse = await axios.get<{ papers: Paper[], filters: Filters }>("/api/papers", {
115115
params: { subject },
116116
});
117117
const papersData: Paper[] = papersResponse.data.papers;
118-
const filters: Filters = papersResponse.data;
118+
const filters: Filters = papersResponse.data.filters;
119119

120120
setFilterOptions(filters);
121121

src/components/PreviewCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const PreviewCard = ({ paper }: { paper: Paper }) => {
1616
key={paper._id}
1717
className="w-56 space-y-1 rounded-xl border border-black border-opacity-50 p-4 dark:border-[#7480FF]/25"
1818
>
19-
<Link href={paper.finalUrl} target="_blank" rel="noopener noreferrer">
19+
<Link href={`/paper/${paper._id}`} target="_blank" rel="noopener noreferrer">
2020
<Image
2121
src={paper.thumbnailUrl}
2222
alt={paper.subject}

src/components/StoredPapers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function StoredPapers() {
1313
async function fetchPapers() {
1414
try {
1515
const response = await axios.get("/api/selected-papers");
16-
setDisplayPapers(response.data);
16+
setDisplayPapers(response.data as Paper[]);
1717
} catch (error) {
1818
setDisplayPapers(papers);
1919
console.error("Failed to fetch papers:", error);

src/components/searchbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function SearchBar() {
2020
if (text.length > 1) {
2121
setLoading(true);
2222
try {
23-
const searchResponse = await axios.get("/api/search", {
23+
const searchResponse = await axios.get<{ subjects: { subject: string }[] }>("/api/search", {
2424
params: { text },
2525
});
2626

@@ -51,7 +51,7 @@ function SearchBar() {
5151
if (text.length <= 1) {
5252
setSuggestions([]);
5353
}
54-
debouncedSearch(text);
54+
void debouncedSearch(text);
5555
};
5656

5757
const handleSelectSuggestion = async (suggestion: string) => {

src/components/ui/command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Command = React.forwardRef<
2323
))
2424
Command.displayName = CommandPrimitive.displayName
2525

26-
interface CommandDialogProps extends DialogProps {}
26+
type CommandDialogProps = DialogProps
2727

2828
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
2929
return (

0 commit comments

Comments
 (0)