Skip to content

Commit

Permalink
Merge pull request #617 from iron-fish/fix-docs-anchor-links
Browse files Browse the repository at this point in the history
Fix docs heading links
  • Loading branch information
dgca authored Feb 27, 2024
2 parents 6426501 + c3f5a8a commit c200fbb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 4 additions & 1 deletion layouts/Documentation/Documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
VStack,
NAV_HEIGHT,
HStack,
Button,
SidebarItem,
ArrowButton,
} from "@/lib/ui";
Expand All @@ -21,6 +20,7 @@ import Head from "next/head";
import Link from "next/link";
import { useRouter } from "next/router";
import { ComponentProps, useEffect, useMemo, useRef, useState } from "react";
import { useIsClient } from "usehooks-ts";

type Props = {
frontMatter: {
Expand Down Expand Up @@ -209,6 +209,7 @@ function flattenSidebarItems(sidebarItems: SidebarItems): SidebarItem[] {

function PrevNextButtons({ sidebarItems }: { sidebarItems: SidebarItems }) {
const router = useRouter();
const isClient = useIsClient();

const flattenedItems = useMemo(() => {
return flattenSidebarItems(sidebarItems);
Expand All @@ -225,6 +226,8 @@ function PrevNextButtons({ sidebarItems }: { sidebarItems: SidebarItems }) {
};
}, [flattenedItems, router.asPath]);

if (!isClient) return null;

return (
<HStack justifyContent="space-between" mt={20}>
<ArrowButton
Expand Down
11 changes: 2 additions & 9 deletions lib/ui/src/components/MDXRenderer/MDXRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
import { MDXProvider as BaseMDXProvider } from "@mdx-js/react";
import { kebabCase } from "lodash-es";
import { MDXRemote, MDXRemoteProps } from "next-mdx-remote";
import Head from "next/head";
import NextLink from "next/link";
import { ComponentProps, ReactNode, useCallback, useState } from "react";
import { FAQItem } from "../../components/FAQItem/FAQItem";
Expand All @@ -43,6 +42,7 @@ function HeadingWithAnchor(props: ComponentProps<typeof Heading>) {
id={headingId}
ref={handleHeadingId}
fontWeight="normal"
scrollMarginTop="100px"
_hover={{
'a[href^="#"]': {
color: "blue",
Expand All @@ -51,14 +51,7 @@ function HeadingWithAnchor(props: ComponentProps<typeof Heading>) {
>
{props.children}&nbsp;
{headingId && (
<Link
href={`#${headingId}`}
color="transparent"
onClick={(e) => {
e.preventDefault();
smoothScrollToElByQuerySelector(`#${headingId}`);
}}
>
<Link href={`#${headingId}`} color="transparent">
#
</Link>
)}
Expand Down
2 changes: 1 addition & 1 deletion search/indexes/blog-index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion search/indexes/documentation-index.json

Large diffs are not rendered by default.

0 comments on commit c200fbb

Please sign in to comment.