Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/components/next.tsx
1503 views
1
/* A link to the @cocalc/next site */
2
3
import { A } from "./A";
4
import { join } from "path";
5
import { appBasePath } from "@cocalc/frontend/customize/app-base-path";
6
7
interface Props {
8
href: string;
9
style?;
10
children?;
11
query?;
12
sameTab?: boolean;
13
}
14
15
export default function Next({ href, style, children, query, sameTab }: Props) {
16
if (query) {
17
query = Object.entries(query)
18
.map(
19
([key, value]) =>
20
`${encodeURIComponent(key)}=${encodeURIComponent(value as any)}`,
21
)
22
.join("&");
23
}
24
const href0 = `${join(appBasePath, href)}${query ? "?" + query : ""}`;
25
if (sameTab) {
26
return (
27
<a style={style} href={href0}>
28
{children}
29
</a>
30
);
31
}
32
return (
33
<A style={style} href={href0}>
34
{children}
35
</A>
36
);
37
}
38
39