summaryrefslogtreecommitdiff
path: root/docs/src/layouts/MainLayout.astro
blob: 234270a778841007996687915cbaf4cdb65cbfe5 (plain) (blame)
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
---
import HeadCommon from "../components/HeadCommon.astro";
import HeadSEO from "../components/HeadSEO.astro";
import Header from '../components/Header/Header.astro';
import Footer from '../components/Footer/Footer.astro';
import PageContent from '../components/PageContent/PageContent.astro';
import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro';
import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
import { SITE } from "../config.ts";

const { content = {} } = Astro.props;
const currentPage = Astro.request.url.pathname;
const currentFile = `src/pages${currentPage.replace(/\/$/, "")}.md`;
const githubEditUrl = `https://github.com/snowpackjs/astro/blob/main/docs/${currentFile}`;
const formatTitle = (content, SITE) => content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title;
---

<html dir="{content.dir ?? 'ltr'}" lang="{content.lang ?? 'en-us'}" class="initial">
  <head>
    <HeadCommon />
    <HeadSEO {content} canonicalURL={Astro.request.canonicalURL} />
    <title>{formatTitle(content, SITE)}</title>
    <style>
      body {
        width: 100%;
        display: grid;
        grid-template-rows: var(--theme-navbar-height) 1fr;
        --gutter: 0.5rem;
        --doc-padding: 2rem;
      }
      .layout {
        display: grid;
        grid-auto-flow: column;
        grid-template-columns: 
          minmax(var(--gutter), 1fr) 
          minmax(0, var(--max-width)) 
          minmax(var(--gutter), 1fr);
        overflow-x: hidden;
      }
      .layout :global(> *) {
        width: 100%;
        height: 100%;
      }
      .grid-sidebar {
        height: 100vh;
        position: sticky;
        top: 0;
        padding: 0;
      }
      #grid-left {
        position: fixed;
        background-color: var(--theme-bg);
        z-index: 10;
        display: none;
      }
      #grid-main {
        padding: var(--doc-padding) var(--gutter);
        grid-column: 2;
        display: flex;
        flex-direction: column;
        height: 100%;
      }
      #grid-right {
        display: none;
      }   
      :global(.mobile-sidebar-toggle) {
        overflow: hidden;
      }
      :global(.mobile-sidebar-toggle #grid-left) {
        display: block;
        top: 2rem;
      }
      @media (min-width: 50em) {
        .layout {
          overflow: initial;
          grid-template-columns: 
            20rem 
            minmax(0, var(--max-width));
          gap: 1em;
        }
        #grid-left {
          display: flex;
          padding-left: 2rem;
          position: sticky;
          grid-column: 1;
        }
      }

      @media (min-width: 72em) {
        .layout {
          grid-template-columns: 
            20rem 
            minmax(0, var(--max-width)) 
            18rem;
          padding-left: 0;
          padding-right: 0;
          margin: 0 auto;
        }
        #grid-right {
          grid-column: 3;
          display: flex;
        }
      }
    </style>
  </head>

  <body>
    <Header currentPage={currentPage} />
    <main class="layout">
      <aside id="grid-left" class="grid-sidebar" title="Site Navigation">
        <LeftSidebar currentPage={currentPage} />
      </aside>
      <div id="grid-main">
        <PageContent content={content} githubEditUrl={githubEditUrl} currentPage={currentPage}>
          <slot />
        </PageContent>
      </div>
      <aside id="grid-right" class="grid-sidebar" title="Table of Contents">
        <RightSidebar content={content} githubEditUrl={githubEditUrl} />
      </aside>
    </main>
  </body>
</html>