/
index.tsx
55 lines (52 loc) · 1.1 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import * as NextImage from "next/image";
import * as NextRouter from "next/router";
import React from "react";
const OriginalNextImage = NextImage.default;
// Patch Image to disable optimisations within Preview.js.
Object.defineProperty(NextImage, "default", {
configurable: true,
value: (props: NextImage.ImageProps) => (
<OriginalNextImage {...props} unoptimized />
),
});
// Patch useRouter() to fake the router within Preview.js.
Object.defineProperty(NextRouter, "useRouter", {
configurable: true,
value: () => ({
locale: "en-US",
route: "/",
pathname: "/",
query: {},
asPath: "/",
push() {
return Promise.resolve(true);
},
replace() {
return Promise.resolve(true);
},
reload() {
// Do nothing.
},
back() {
// Do nothing.
},
prefetch() {
return Promise.resolve();
},
beforePopState() {
// Do nothing.
},
events: {
on() {
// Do nothing.
},
off() {
// Do nothing.
},
emit() {
// Do nothing.
},
},
isFallback: false,
}),
});