File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import Navbar from "@/components/Navbar";
4
4
import PdfViewer from "@/components/pdfViewer" ;
5
5
import Loader from "@/components/ui/loader" ;
6
6
import { type ErrorResponse , type PaperResponse } from "@/interface" ;
7
+ import { extractBracketContent } from "@/util/utils" ;
7
8
import axios , { type AxiosResponse } from "axios" ;
8
9
import { type Metadata } from "next" ;
9
10
import { redirect } from "next/navigation" ; // Import redirect
@@ -164,7 +165,7 @@ const PaperPage = async ({ params }: { params: { id: string } }) => {
164
165
{ paper . subject } { paper . exam } { paper . slot } { paper . year }
165
166
</ h1 >
166
167
< center >
167
- < PdfViewer url = { paper . finalUrl } > </ PdfViewer >
168
+ < PdfViewer url = { paper . finalUrl } name = { ` ${ extractBracketContent ( paper . subject ) } - ${ paper . exam } - ${ paper . slot } - ${ paper . year } ` } > </ PdfViewer >
168
169
</ center >
169
170
</ >
170
171
) }
Original file line number Diff line number Diff line change @@ -23,17 +23,21 @@ import "@react-pdf-viewer/core/lib/styles/index.css";
23
23
import "@react-pdf-viewer/zoom/lib/styles/index.css" ;
24
24
import Link from "next/link" ;
25
25
26
-
27
-
28
26
interface Params {
29
27
params : { id : string } ;
30
28
}
31
29
32
30
interface PdfViewerProps {
33
31
url : string ;
32
+ name : string ;
34
33
}
35
- export default function PdfViewer ( { url } : PdfViewerProps ) {
36
- const getFilePluginInstance = getFilePlugin ( ) ;
34
+
35
+ export default function PdfViewer ( { url, name } : PdfViewerProps ) {
36
+ const getFilePluginInstance = getFilePlugin ( {
37
+ fileNameGenerator : ( ) => {
38
+ return name ;
39
+ } ,
40
+ } ) ;
37
41
const zoomPluginInstance = zoomPlugin ( ) ;
38
42
const { CurrentScale, ZoomIn, ZoomOut } = zoomPluginInstance ;
39
43
const fullScreenPluginInstance = fullScreenPlugin ( ) ;
@@ -43,7 +47,7 @@ export default function PdfViewer({ url }: PdfViewerProps) {
43
47
44
48
return (
45
49
< div >
46
- < div className = "flex w-[95%] items-center justify-between bg-violet-400 dark:bg-gray-900 px-4 py-4 md:w-[80%]" >
50
+ < div className = "flex w-[95%] items-center justify-between bg-violet-400 px-4 py-4 dark:bg-gray-900 md:w-[80%]" >
47
51
< div className = "flex gap-x-4" >
48
52
< ZoomOut >
49
53
{ ( props : RenderZoomOutProps ) => (
You can’t perform that action at this time.
0 commit comments