-
Notifications
You must be signed in to change notification settings - Fork 425
/
Copy pathDocsLayout.astro
159 lines (132 loc) · 3.9 KB
/
DocsLayout.astro
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
import PageContent from "~/components/PageContent/PageContent.astro"
import LeftSidebar from "~/components/LeftSidebar/LeftSidebar.astro"
import RightSidebar from "~/components/RightSidebar/RightSidebar.astro"
import * as CONFIG from "~/config"
import type { BaseFrontmatter } from "~/content/config"
import WhatsNext from "~/components/PageContent/WhatsNext.astro"
import type { MarkdownHeading } from "astro"
import StickyHeader from "~/components/StickyHeader/StickyHeader"
import BaseLayout from "./BaseLayout.astro"
interface Props {
frontmatter: BaseFrontmatter
headings?: MarkdownHeading[]
}
const { frontmatter, headings } = Astro.props
const titleHeading: MarkdownHeading = {
text: frontmatter.title,
slug: "overview",
depth: 1,
}
const filteredHeadings = headings?.filter((h) => h.depth < 5)
const initialHeadings = [titleHeading].concat(filteredHeadings ?? [])
const whatsNext = frontmatter.whatsnext
const currentPage = new URL(Astro.request.url).pathname
const fileExtension = frontmatter.fileExtension || "mdx"
const baseDirectory = fileExtension === "astro" ? "src/pages" : "src/content"
const currentFile = `${baseDirectory}${currentPage.replace(/\/$/, "")}${
frontmatter.isIndex ? "/index" : ""
}.${fileExtension}`
const githubEditUrl = CONFIG.GITHUB_EDIT_URL + currentFile
const formattedContentTitle = `${frontmatter.title} | ${CONFIG.SITE.title}`
const includeLinkToWalletScript = !!Astro.props.frontmatter.metadata?.linkToWallet
---
<BaseLayout title={formattedContentTitle} metadata={frontmatter.metadata}>
<StickyHeader client:media="(max-width: 50em)" {initialHeadings} />
<main>
<div id="left-bg"></div>
<div class="layout">
<aside id="grid-left" title="Site Navigation">
<LeftSidebar currentPage={currentPage} section={frontmatter.section} />
</aside>
<div id="grid-main">
<PageContent {titleHeading}>
<slot />
</PageContent>
{whatsNext && <WhatsNext content={whatsNext} />}
</div>
<aside id="grid-right" title="Table of Contents">
<RightSidebar {githubEditUrl} headings={initialHeadings} />
</aside>
</div>
</main>
<style>
main {
margin-bottom: 0 !important;
}
.layout {
display: grid;
grid-template-columns: auto;
--gutter: var(--space-6x);
--doc-padding: 2rem;
margin-bottom: 0;
}
#grid-left,
#grid-right {
display: none;
}
#grid-main {
padding: var(--doc-padding) var(--gutter);
display: flex;
flex-direction: column;
margin-bottom: var(--space-10x);
min-width: 0;
}
@media (min-width: 50em) {
main {
display: grid;
grid-template-columns: auto fit-content(100%) auto;
}
.layout {
grid-template-columns: auto auto auto;
gap: var(--gutter);
max-width: 1440px;
}
#grid-left,
#left-bg {
background: #fafbfd;
}
#grid-left,
#grid-right {
display: flex;
}
#grid-main {
padding: 0 0 var(--doc-padding) 0;
}
#grid-left {
width: 260px;
padding-left: var(--space-8x);
}
#grid-right {
width: 0;
padding-right: 0;
transition: 300ms ease-in-out;
transition-property: width padding-right;
}
}
@media (min-width: 992px) {
.layout {
gap: var(--doc-padding);
}
#grid-left {
width: 285px;
padding-left: var(--space-16x);
}
}
@media (min-width: 1200px) {
#grid-right {
width: 315px;
padding-right: var(--space-16x);
}
}
</style>
<script define:vars={{ includeLinkToWalletScript }}>
window["includeLinkToWalletScript"] = includeLinkToWalletScript
</script>
<script>
import "~/scripts"
if (window["includeLinkToWalletScript"]) {
import("~/scripts/link-to-wallet")
}
</script>
</BaseLayout>