Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THC 856 create main article theme template #267

Merged
merged 15 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/Callout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ if (Astro.slots.has("default")) {
---

<!-- Pass the assigned information to the BuildBanner React component -->
<Banner client:only="react" title={title ? title : typeTitle} kind={bannerType}>
<Fragment set:html={content} slot="description" />
</Banner>
<div class="my-7">
<Banner
client:only="react"
title={title ? title : typeTitle}
kind={bannerType}
>
<Fragment set:html={content} slot="description" />
</Banner>
</div>
6 changes: 3 additions & 3 deletions src/components/LeftSidebar/Navigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import classNames from "classnames";

import { getLanguageFromURL } from "@i18n/locales";
import type { getNavigationEntries } from "src/utils/helpers/navigation/getNavigationEntries";

import NavigationItem from "./NavigationItem";

import type { NavigationData } from "src/utils/helpers/navigation/types";

interface NavigationProps {
navigationEntries: ReturnType<typeof getNavigationEntries>;
navigationEntries: NavigationData["languageTree"];
}

const { navigationEntries } = Astro.props as NavigationProps;
Expand Down
45 changes: 45 additions & 0 deletions src/components/PageBreadcrumbs/PageBreadcrumbs.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
import classNames from "classnames";

import type { NavigationData } from "src/utils/helpers/navigation/types";

import "./breadcrumbs.css";

interface BreadcrumbsProps {
breadcrumbs: NavigationData["breadcrumbs"];
}

const { breadcrumbs } = Astro.props as BreadcrumbsProps;
const currentPage = Astro.url.pathname;
const currentPageMatch = currentPage.endsWith("/")
? currentPage.slice(1, -1)
: currentPage.slice(1);
---

<div aria-label="breadcrumbs" class="mb-8">
<nav>
<ul class="flex flex-row gap-x-6">
{
breadcrumbs.map((breadcrumb, i) => (
<li
class={classNames(" relative", {
"breadcrumbs-item":
breadcrumbs.length > 1 && i !== breadcrumbs.length - 1,
})}
>
<a
class={classNames("cursor-pointer text-sm", {
"text-black font-semibold": currentPageMatch === breadcrumb.url,
"text-secondary font-medium":
currentPageMatch !== breadcrumb.url,
})}
href={`/${breadcrumb.url}`}
>
{breadcrumb.title}
</a>
</li>
))
}
</ul>
</nav>
</div>
8 changes: 8 additions & 0 deletions src/components/PageBreadcrumbs/breadcrumbs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.breadcrumbs-item::after {
content: "•";
font-weight: 500;
position: absolute;
top: -5px;
right: -16px;
font-size: 20px;
}
9 changes: 2 additions & 7 deletions src/components/PageContent/PageContent.astro
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
---
import type { MarkdownHeading } from "astro";
import MoreMenu from "../RightSidebar/MoreMenu.astro";
import TableOfContents from "../RightSidebar/TableOfContents";

type Props = {
title: string;
headings: MarkdownHeading[];
githubEditUrl: string;
};

const { title, headings, githubEditUrl } = Astro.props;
const { title, headings } = Astro.props;
---

<article id="article" class="w-full">
<article id="article" class="article-main w-full">
<section class="main-section">
<h1 class="content-title" id="overview">{title}</h1>
<nav class="block sm:hidden">
<TableOfContents client:media="(max-width: 50em)" headings={headings} />
</nav>
<slot />
</section>
<nav class="block sm:hidden">
<MoreMenu editHref={githubEditUrl} />
</nav>
</article>
75 changes: 0 additions & 75 deletions src/components/RightSidebar/MoreMenu.astro

This file was deleted.

5 changes: 1 addition & 4 deletions src/components/RightSidebar/RightSidebar.astro
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
---
import type { MarkdownHeading } from "astro";
import TableOfContents from "./TableOfContents";
import MoreMenu from "./MoreMenu.astro";

type Props = {
headings: MarkdownHeading[];
githubEditUrl: string;
};

const { headings, githubEditUrl } = Astro.props;
const { headings } = Astro.props;
---

<nav class="w-full sticky top-10" aria-labelledby="grid-right">
<div class="h-full p-0 overflow-auto xs:hidden lg:block">
<TableOfContents client:visible headings={headings} />
<MoreMenu editHref={githubEditUrl} />
</div>
</nav>
5 changes: 3 additions & 2 deletions src/components/RightSidebar/TableOfContents.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** @jsxImportSource react */
import type { MarkdownHeading } from "astro";
import type { FC } from "react";
import { unescape } from "html-escaper";
Expand Down Expand Up @@ -100,7 +99,9 @@ const TableOfContents: FC<{ headings: MarkdownHeading[] }> = ({
.map((heading) => (
<li
key={heading.slug}
className={`header-link depth-${heading.depth} ${
className={`header-link before:content-none depth-${
heading.depth
} ${
currentID === heading.slug ? "current-header-link" : ""
}`.trim()}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/atlas/BuildTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ const BuildTabs: FC<{
}, []);

return (
<>
<div id="tabs-container">
<Tabs
items={currentTabs.items}
value={currentTabs.activeTab}
onChange={(id) => handleTabChange(id, currentTabs.isTabsHaveSync)}
/>
{content}
</>
</div>
);
};

Expand Down
20 changes: 8 additions & 12 deletions src/layouts/MainLayout.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
import type { MarkdownHeading } from "astro";
import type { CollectionEntry } from "astro:content";

import HeadCommon from "../components/HeadCommon.astro";
import HeadSEO from "../components/HeadSEO.astro";
import PageContent from "../components/PageContent/PageContent.astro";
import PageBreadcrumbs from "@components/PageBreadcrumbs/PageBreadcrumbs.astro";
import Navigation from "../components/LeftSidebar/Navigation.astro";
import { GITHUB_EDIT_URL, SITE } from "../consts";
import { SITE } from "../consts";
import { getNavigationEntries } from "src/utils/helpers/navigation/getNavigationEntries";
import SidebarHeader from "@components/LeftSidebar/SidebarHeader/SidebarHeader.astro";
import SidebarSearch from "@components/LeftSidebar/SidebarSearch/SidebarSearch.astro";
Expand All @@ -23,11 +25,8 @@ type Props = CollectionEntry<"docs">["data"] & {
const pages = await Astro.glob("../content/docs/**/*.mdx");
const currentPage = Astro.url.pathname;
const navigationEntries = getNavigationEntries(pages, currentPage);

const { headings, ...data } = Astro.props;
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const currentFile = `src/content/docs${currentPage.replace(/\/$/, "")}.md`;
const githubEditUrl = `${GITHUB_EDIT_URL}/${currentFile}`;
const currentLang = getLanguageFromURL(currentPage);
const homeUrl = `${Astro.url.origin}/${currentLang}`;
---
Expand All @@ -54,7 +53,7 @@ const homeUrl = `${Astro.url.origin}/${currentLang}`;
<SidebarHeader homeUrl={homeUrl} />
{/* Search input */}
<SidebarSearch />
<Navigation navigationEntries={navigationEntries} />
<Navigation navigationEntries={navigationEntries?.languageTree} />
<div class="h-[63px] p-[22px] border-t-[1px] border-[#CDD0E0]">
<LanguageSwitch
client:load
Expand All @@ -66,18 +65,15 @@ const homeUrl = `${Astro.url.origin}/${currentLang}`;
</aside>
<div
id="content-main"
class="article-main xs:pl-4 lg:pl-0 pr-4 flex mt-9 mb-16 xs:w-full lg:w-[calc(100%-326px-272px)]"
class="xs:pl-4 lg:pl-0 pr-4 flex flex-col mt-14 mb-16 xs:w-full lg:w-[calc(100%-326px-272px)]"
>
<PageContent
title={data.title}
headings={headings}
githubEditUrl={githubEditUrl}
>
<PageBreadcrumbs breadcrumbs={navigationEntries?.breadcrumbs} />
<PageContent title={data.title} headings={headings}>
<slot />
</PageContent>
</div>
<aside class="relative pl-8 w-[272px]" title="Table of Contents">
<RightSidebar headings={headings} githubEditUrl={githubEditUrl} />
<RightSidebar headings={headings} />
</aside>
</main>
</body>
Expand Down
Loading
Loading