jevstrudel.git / website / src / layouts / MainLayout.astro
MainLayout.astro53 lines · 2.1 KB · raw
1---
2import HeadCommon from '../components/HeadCommon.astro';
3import HeadSEO from '../components/HeadSEO.astro';
4import Header from '../components/Header/Header.astro';
5import PageContent from '../components/PageContent/PageContent.astro';
6import LeftSidebar from '../components/LeftSidebar/LeftSidebar.astro';
7import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
8import * as CONFIG from '../config';
9import type { MarkdownHeading } from 'astro';
10import '../docs/docs.css';
11
12type Props = {
13  frontmatter: CONFIG.Frontmatter;
14  headings: MarkdownHeading[];
15};
16
17const { frontmatter, headings } = Astro.props as Props;
18const canonicalURL = new URL(Astro.url.pathname, Astro.site);
19const currentPage = Astro.url.pathname;
20const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.mdx`;
21const githubEditUrl = `${CONFIG.GITHUB_EDIT_URL}/${currentFile}`;
22---
23
24<html dir={frontmatter.dir ?? 'ltr'} lang={frontmatter.lang ?? 'en'} class="initial dark">
25  <head>
26    <HeadCommon />
27    <HeadSEO frontmatter={frontmatter} canonicalUrl={canonicalURL} />
28    <title>
29      {frontmatter.title ? `${frontmatter.title} 🌀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}
30    </title>
31  </head>
32
33  <body class="h-app-height m-0 text-gray-50 bg-background">
34    <div class="w-full h-full space-y-4 flex flex-col">
35      <header class="max-w-full fixed top-0 w-full z-[100]">
36        <Header currentPage={currentPage} />
37      </header>
38      <main class="relative pt-16">
39        <div class="h-full top-0 overflow-auto min-w-[300px] flex xl:justify-center pr-4 pl-4 md:pl-[300px] xl:pl-0">
40          <aside title="Site Navigation" class="w-[300px] px-6 left-0 hidden md:block fixed h-full">
41            <LeftSidebar currentPage={currentPage} />
42          </aside>
43          <PageContent frontmatter={frontmatter} headings={headings} githubEditUrl={githubEditUrl}>
44            <slot />
45          </PageContent>
46          <aside class="fixed right-0 h-full overflow-auto pr-4 pl-0 pb-16 hidden xl:block" title="Table of Contents">
47            <RightSidebar headings={headings} githubEditUrl={githubEditUrl} />
48          </aside>
49        </div>
50      </main>
51    </div>
52  </body>
53</html>