Skip to content

Commit bcc9cb2

Browse files
authored
Merge pull request #448 from code-hike/next
Update website
2 parents a5021d6 + 228011e commit bcc9cb2

File tree

11 files changed

+811
-14
lines changed

11 files changed

+811
-14
lines changed

apps/web/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const metadata: Metadata = {
2929
title: "Code Hike",
3030
description:
3131
"Use Markdown and React to build rich content websites. Documentation, tutorials, blogs, videos, interactive walkthroughs, and more.",
32-
metadataBase: new URL("https://codehike.org"),
32+
// metadataBase: new URL("https://codehike.org"),
3333
openGraph: {
3434
title: "Code Hike",
3535
images: `https://codehike.org/codehike.png`,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use client"
2+
import {
3+
Tooltip,
4+
TooltipContent,
5+
TooltipProvider,
6+
TooltipTrigger,
7+
} from "@/components/ui/tooltip"
8+
9+
import React from "react"
10+
11+
const BlocksContext = React.createContext<any>(null)
12+
13+
export function BlocksToContext({
14+
children,
15+
...rest
16+
}: {
17+
children: React.ReactNode
18+
rest: any
19+
}) {
20+
return (
21+
<BlocksContext.Provider value={rest}>{children}</BlocksContext.Provider>
22+
)
23+
}
24+
25+
export function useBlocksContext(name: string) {
26+
return React.useContext(BlocksContext)[name]
27+
}
28+
29+
export function WithTooltip({
30+
children,
31+
name,
32+
}: {
33+
children: React.ReactNode
34+
name: string
35+
}) {
36+
const block = useBlocksContext(name)
37+
const className = block.isCode
38+
? "p-0 [&>*]:my-0 border-none overflow-auto rounded-none"
39+
: ""
40+
return (
41+
<TooltipProvider>
42+
<Tooltip>
43+
<TooltipTrigger className="underline decoration-dotted underline-offset-4 cursor-help">
44+
{children}
45+
</TooltipTrigger>
46+
<TooltipContent className={className}>{block?.children}</TooltipContent>
47+
</Tooltip>
48+
</TooltipProvider>
49+
)
50+
}

apps/web/components/code.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ import { tooltip } from "./annotations/tooltip"
2626

2727
export async function InlineCode({ codeblock }: { codeblock: RawCode }) {
2828
const highlighted = await highlight(codeblock, theme)
29-
return <Inline code={highlighted} style={highlighted.style} />
29+
return (
30+
<Inline
31+
code={highlighted}
32+
style={highlighted.style}
33+
className="selection:bg-editor-selectionBackground"
34+
/>
35+
)
3036
}
3137

3238
export async function Code({
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
5+
6+
import { cn } from "@/lib/utils"
7+
8+
const HoverCard = HoverCardPrimitive.Root
9+
10+
const HoverCardTrigger = HoverCardPrimitive.Trigger
11+
12+
const HoverCardContent = React.forwardRef<
13+
React.ElementRef<typeof HoverCardPrimitive.Content>,
14+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
15+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16+
<HoverCardPrimitive.Content
17+
ref={ref}
18+
align={align}
19+
sideOffset={sideOffset}
20+
className={cn(
21+
"z-50 w-64 rounded-md border border-zinc-200 bg-white p-4 text-zinc-950 shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-50",
22+
className
23+
)}
24+
{...props}
25+
/>
26+
))
27+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
28+
29+
export { HoverCard, HoverCardTrigger, HoverCardContent }

0 commit comments

Comments
 (0)