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

docs improvements #698

Merged
merged 59 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d381b9e
add new font weight for Inter
ryanwaits Jul 12, 2024
af6b609
add roll button
ryanwaits Jul 12, 2024
24122aa
update styles
ryanwaits Jul 12, 2024
d77fb78
initial design updates
ryanwaits Jul 12, 2024
083c620
update imports
ryanwaits Jul 12, 2024
037cea7
remove unused imports
ryanwaits Jul 12, 2024
eccc095
update metadata
ryanwaits Jul 13, 2024
4ad3a1e
update toggle modes
ryanwaits Jul 13, 2024
f0cf660
add docs logo
ryanwaits Jul 13, 2024
90f6ae6
style updates
ryanwaits Jul 13, 2024
093dd4a
icon updates
ryanwaits Jul 13, 2024
c834e34
add inter font
ryanwaits Jul 13, 2024
9d8ceda
add svg images
ryanwaits Jul 13, 2024
d20c7e5
style adjustments to card
ryanwaits Jul 13, 2024
91f61fd
add new icon components
ryanwaits Jul 13, 2024
675889f
add footer
ryanwaits Jul 13, 2024
6113437
add back accidental deletion of existing chainhook guide
ryanwaits Jul 13, 2024
a4424c8
remove unused imports
ryanwaits Jul 13, 2024
d51dc32
add custom Callout component
ryanwaits Jul 13, 2024
ffca489
update styles
ryanwaits Jul 13, 2024
cedd4d1
updates
ryanwaits Jul 13, 2024
88f2cc0
adjust styling for code blocks
ryanwaits Jul 14, 2024
fcd287c
more style updates
ryanwaits Jul 16, 2024
0e202de
small adjustments to ui components
ryanwaits Jul 16, 2024
d9028d6
upgrade fumadocs openapi package
ryanwaits Jul 16, 2024
205d1b6
update content with new components
ryanwaits Jul 16, 2024
5db26ee
add custom class and override styling
ryanwaits Jul 16, 2024
4d2d521
move and update hiro icon
ryanwaits Jul 16, 2024
b3a9373
update callout component for `help` type
ryanwaits Jul 16, 2024
cb2e34e
update with new callout component
ryanwaits Jul 16, 2024
97e3c73
fix override issue with main page footer
ryanwaits Jul 16, 2024
46e901b
add more icons
ryanwaits Jul 16, 2024
a6cdaa9
small adjustments to styling
ryanwaits Jul 16, 2024
83dc702
updates
ryanwaits Jul 16, 2024
9787d20
resolve merge conflict
ryanwaits Jul 17, 2024
4456811
update class names to bitcoin
ryanwaits Jul 17, 2024
1bcd8a4
minor adjustments to config and bitcoin sections
ryanwaits Jul 17, 2024
0880082
update components to use theme colors
ryanwaits Jul 17, 2024
68f5762
remove unused import
ryanwaits Jul 17, 2024
eb6075d
fix broken link
ryanwaits Jul 17, 2024
92595f7
update badge styling
ryanwaits Jul 17, 2024
d26686d
updates
ryanwaits Jul 18, 2024
d40d1c2
add footer
ryanwaits Jul 18, 2024
6554b56
fix typo in linking to discord
ryanwaits Jul 18, 2024
827d1ac
fix svg stroke
ryanwaits Jul 18, 2024
f54179d
add social media icons
ryanwaits Jul 18, 2024
2aebead
create page footer component
ryanwaits Jul 18, 2024
f31c964
update footer
ryanwaits Jul 18, 2024
b504f1f
fix callout titles
ryanwaits Jul 18, 2024
7295db7
update bitcoin section and update some styling
ryanwaits Jul 19, 2024
dfdad59
Update footer.tsx
max-crawford Jul 19, 2024
3192cf4
Update footer.tsx
max-crawford Jul 19, 2024
f0d0f86
update callout titles
ryanwaits Jul 19, 2024
89e381e
update archive guide
ryanwaits Jul 19, 2024
652a736
remove the rest of stacks and ordinals guides
ryanwaits Jul 19, 2024
435c619
fix spacing
ryanwaits Jul 19, 2024
cb77649
curate the guides list
ryanwaits Jul 19, 2024
ba7e7c4
update sidebar
ryanwaits Jul 19, 2024
15d0731
use custom card
ryanwaits Jul 19, 2024
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
65 changes: 40 additions & 25 deletions app/(docs)/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ExternalLinkIcon } from "lucide-react";
import type { Metadata } from "next";
import { Card, Cards } from "fumadocs-ui/components/card";
import { RollButton } from "fumadocs-ui/components/roll-button";
import { DocsPage, DocsBody } from "fumadocs-ui/page";
import { notFound } from "next/navigation";
import { utils, type Page } from "@/utils/source";
Expand Down Expand Up @@ -76,18 +77,9 @@ export default function Page({ params }: { params: Param }): JSX.Element {
toc={page.data.exports.toc}
tableOfContent={{
enabled: page.data.toc,
footer: (
<a
href={`https://github.com/hirosystems/docs/blob/main/${path}`}
target="_blank"
rel="noreferrer noopener"
className="inline-flex items-center text-xs text-muted-foreground hover:text-foreground"
>
Edit on Github <ExternalLinkIcon className="ml-1 size-3" />
</a>
),
}}
>
<RollButton />
{page.data.title !== "Home" && (
<h1 className="text-3xl font-bold text-foreground sm:text-4xl">
{prefix} {page.data.title}
Expand Down Expand Up @@ -131,7 +123,7 @@ function Category({ page }: { page: Page }): JSX.Element {
);
}

export const metadata: Metadata = {
const metadata: Metadata = {
metadataBase: new URL(
`https://${process.env.NEXT_PUBLIC_VERCEL_URL}` || "https://docs.hiro.so"
),
Expand Down Expand Up @@ -164,24 +156,47 @@ export const metadata: Metadata = {
},
};

// export function generateMetadata({ params }: { params: Param }): Metadata {
// const page = utils.getPage(params.slug);
function generateCustomTitle(file: {
flattenedPath: string;
name: string;
}): string {
const segments = file.flattenedPath.split("/");
const isRootLevelSegment = segments.length === 3;
let relevantSegments: string[] = [];

// if (!page) notFound();
if (isRootLevelSegment) {
relevantSegments = [segments[1]];
}

// const description =
// page.data.description ??
// "All the developer docs, guides and resources you need to build on Bitcoin layers.";
return (
relevantSegments[0]?.charAt(0)?.toUpperCase() +
relevantSegments[0]?.slice(1)
);
}

export function generateMetadata({ params }: { params: Param }): Metadata {
const page = utils.getPage(params.slug);

// const imageParams = new URLSearchParams();
// imageParams.set("title", page.data.title);
// imageParams.set("description", description);
if (!page) notFound();

const description =
page.data.description ??
"All the developer docs, guides and resources you need to build on Bitcoin layers.";

const imageParams = new URLSearchParams();
imageParams.set("title", page.data.title);
imageParams.set("description", description);

// return createMetadata({
// title: page.data.title,
// description,
// });
// }
const customTitle = generateCustomTitle(page.file);

return createMetadata({
...metadata,
title: customTitle.length
? `${customTitle} ${page.data.title}`
: page.data.title,
description,
});
}

export function generateStaticParams(): Param[] {
return utils.getPages().map<Param>((page) => ({
Expand Down
27 changes: 25 additions & 2 deletions app/(docs)/layout.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,32 @@ import { cn } from "@/utils/cn";
import { modes } from "@/utils/modes";
import { ChevronLeft } from "lucide-react";

type Mode = "stacks" | "bitcoin" | null | undefined;

const itemVariants = cva(
"rounded-md px-2 py-1 transition-colors hover:text-accent-foreground",
{
variants: {
active: {
true: "bg-background text-accent-foreground",
true: "text-accent-foreground",
},
mode: {
bitcoin: "bg-[hsl(var(--hiro))]",
stacks: "bg-background",
},
},
compoundVariants: [
{
active: true,
mode: "bitcoin",
className: "hsl(var(--hiro)) dark:text-background",
},
{
active: true,
mode: "stacks",
className: "bg-background",
},
],
}
);

Expand All @@ -36,7 +54,12 @@ export function NavChildren(): JSX.Element {
<Link
key={m.param}
href={`/${m.param}`}
className={cn(itemVariants({ active: mode === m.param }))}
className={cn(
itemVariants({
active: mode === m.param,
mode: mode === m.param ? (m.param as Mode) : undefined,
})
)}
>
<div className="inline-flex items-center gap-2">
{m.icon && <m.icon className="shrink-0 size-3" />}
Expand Down
20 changes: 6 additions & 14 deletions app/(docs)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,14 @@ import type { ReactNode } from "react";
import { ArrowUpRight } from "lucide-react";
import { utils } from "@/utils/source";
import { create } from "@/components/ui/icon";
import { HiroIcon, HiroSVG } from "../(home)/icons";
import { DocsLogo } from "@/components/ui/icon";
import { Body, NavChildren, SidebarBanner } from "./layout.client";

export const layoutOptions: Omit<DocsLayoutProps, "children"> = {
tree: utils.pageTree,
nav: {
transparentMode: "top",
title: (
<div className="text-md flex gap-3 items-center group">
<HiroIcon className="size-11 shrink-0 rounded-md" />
<span className="max-lg:hidden text-gray-500">|</span>
<span className="max-lg:hidden text-gray-500 group-hover:text-primary">
Documentation
</span>
</div>
),
title: <DocsLogo className="size-28" />,
children: <NavChildren />,
links: [
{
Expand All @@ -37,10 +29,10 @@ export const layoutOptions: Omit<DocsLayoutProps, "children"> = {
],
},
links: [
// {
// text: "Guides",
// url: "/guides",
// },
{
text: "Guides",
url: "/guides",
},
],
sidebar: {
defaultOpenLevel: 0,
Expand Down
64 changes: 0 additions & 64 deletions app/(home)/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,5 @@
import type { SVGProps } from "react";

export function HiroIcon(props: SVGProps<SVGSVGElement>): JSX.Element {
return (
<svg
width="46"
height="14"
viewBox="0 0 46 14"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M25.2475 11.9154V13.1997H18.553V11.9154H21.1896V5.75148H18.553V4.46726H22.5939V11.9154H25.2475ZM20.8302 1.86474C20.8302 1.26521 21.3096 0.802795 21.9092 0.802795C22.5087 0.802795 22.9711 1.26521 22.9711 1.86474C22.9711 2.49833 22.5087 2.94371 21.9092 2.94371C21.3096 2.94371 20.8302 2.49833 20.8302 1.86474Z"
fill="hsl(var(--icon))"
/>
<path
d="M34.981 4.46698V5.83639H33.8509C31.813 5.83639 31.2143 7.39482 31.2143 8.78126V11.9143H34.1592V13.1986H27.8582V11.9143H29.81V5.7512H27.8582V4.46698H31.1454L31.1965 5.93942C31.59 5.25471 32.3777 4.46698 34.0391 4.46698H34.981Z"
fill="hsl(var(--icon))"
/>
<path
d="M37.1479 8.83343C37.1479 6.1798 38.9287 4.3642 41.4801 4.3642C44.0315 4.3642 45.8122 6.17899 45.8122 8.83343C45.8122 11.4879 44.0315 13.3027 41.4801 13.3027C38.9287 13.3027 37.1479 11.4879 37.1479 8.83343ZM44.3738 8.83343C44.3738 6.96753 43.2097 5.61435 41.4801 5.61435C39.7505 5.61435 38.5863 6.96672 38.5863 8.83343C38.5863 10.7001 39.7505 12.0525 41.4801 12.0525C43.2097 12.0525 44.3738 10.7001 44.3738 8.83343Z"
fill="hsl(var(--icon))"
/>
<path
d="M10.8542 13.2058L14.9227 1.15863H16.4722L12.4038 13.2058H10.8542Z"
fill="hsl(var(--icon))"
/>
<path
d="M0.743164 13.2059L4.81163 1.15869H6.36033L2.29267 13.2059H0.743164Z"
fill="hsl(var(--icon))"
/>
<path
d="M10.9086 6.54071H6.7436L6.30957 7.82494H10.4746L10.9086 6.54071Z"
fill="hsl(var(--icon))"
/>
</svg>
);
}

export function HiroSVG(props: SVGProps<SVGSVGElement>): JSX.Element {
return (
<svg
width="43"
height="43"
viewBox="0 0 43 43"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M23.8896 28.7348L28.756 14.3248H30.6094L25.7431 28.7348H23.8896Z"
fill="currentColor"
/>
<path
d="M11.797 28.7345L16.6634 14.3246H18.5158L13.6504 28.7345H11.797Z"
fill="currentColor"
/>
<path
d="M23.9537 20.7611H18.9718L18.4526 22.2972H23.4345L23.9537 20.7611Z"
fill="currentColor"
/>
</svg>
);
}

export function HiroPlatformSVG(props: SVGProps<SVGSVGElement>): JSX.Element {
return (
<svg width="474" height="40" viewBox="0 0 474 40" fill="none" {...props}>
Expand Down
Binary file added app/fonts/Inter-SemiBold.woff2
Binary file not shown.
5 changes: 5 additions & 0 deletions app/fonts/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export const inter = localFont({
weight: "normal",
style: "normal",
},
{
path: "./Inter-SemiBold.woff2",
weight: "600",
style: "normal",
},
],
display: "swap",
variable: "--font-inter",
Expand Down
Loading
Loading