astro-awesomeness 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/src/components/command-menu.tsx +81 -0
- package/src/components/index.ts +22 -0
- package/src/components/theme-toggle.tsx +61 -0
- package/src/components/ui/button.tsx +62 -0
- package/src/components/ui/command.tsx +156 -0
- package/src/components/ui/dialog.tsx +145 -0
- package/src/content/index.test.ts +74 -0
- package/src/content/index.ts +33 -0
- package/src/index.ts +3 -0
- package/src/lib/cn.test.ts +15 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/format-date.test.ts +21 -0
- package/src/lib/format-date.ts +14 -0
- package/src/lib/get-related-posts.test.ts +31 -0
- package/src/lib/get-related-posts.ts +19 -0
- package/src/lib/index.ts +5 -0
- package/src/lib/reading-time.test.ts +25 -0
- package/src/lib/reading-time.ts +14 -0
- package/src/lib/slugify.test.ts +21 -0
- package/src/lib/slugify.ts +11 -0
- package/src/styles/globals.css +209 -0
- package/src/tailwind-preset.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro-awesomeness",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Astro 5 blog theme with shadcn primitives and a Tailwind v4 preset.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"src
|
|
16
|
-
"src/layouts"
|
|
15
|
+
"src"
|
|
17
16
|
],
|
|
18
17
|
"type": "module",
|
|
19
18
|
"exports": {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Search } from "lucide-react";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Command,
|
|
6
|
+
CommandEmpty,
|
|
7
|
+
CommandGroup,
|
|
8
|
+
CommandInput,
|
|
9
|
+
CommandItem,
|
|
10
|
+
CommandList,
|
|
11
|
+
} from "./ui/command";
|
|
12
|
+
import { Dialog, DialogContent, DialogTrigger } from "./ui/dialog";
|
|
13
|
+
import { Button } from "./ui/button";
|
|
14
|
+
|
|
15
|
+
type CommandMenuItem = { description?: string; title: string; url: string };
|
|
16
|
+
|
|
17
|
+
type CommandMenuProps = {
|
|
18
|
+
emptyMessage?: string;
|
|
19
|
+
items: Array<CommandMenuItem>;
|
|
20
|
+
placeholder?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const CommandMenu = ({
|
|
24
|
+
emptyMessage = "No results.",
|
|
25
|
+
items,
|
|
26
|
+
placeholder = "Search posts…",
|
|
27
|
+
}: CommandMenuProps) => {
|
|
28
|
+
const [open, setOpen] = useState(false);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
32
|
+
if (event.key === "k" && (event.metaKey || event.ctrlKey)) {
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
setOpen((value) => !value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
38
|
+
return () => {
|
|
39
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Dialog onOpenChange={setOpen} open={open}>
|
|
45
|
+
<DialogTrigger asChild>
|
|
46
|
+
<Button aria-label="Open search" size="icon" variant="ghost">
|
|
47
|
+
<Search />
|
|
48
|
+
</Button>
|
|
49
|
+
</DialogTrigger>
|
|
50
|
+
<DialogContent className="p-0">
|
|
51
|
+
<Command>
|
|
52
|
+
<CommandInput placeholder={placeholder} />
|
|
53
|
+
<CommandList>
|
|
54
|
+
<CommandEmpty>{emptyMessage}</CommandEmpty>
|
|
55
|
+
<CommandGroup heading="Posts">
|
|
56
|
+
{items.map((item) => (
|
|
57
|
+
<CommandItem
|
|
58
|
+
key={item.url}
|
|
59
|
+
onSelect={() => {
|
|
60
|
+
window.location.href = item.url;
|
|
61
|
+
}}
|
|
62
|
+
value={item.title}
|
|
63
|
+
>
|
|
64
|
+
<div className="flex flex-col">
|
|
65
|
+
<span>{item.title}</span>
|
|
66
|
+
{item.description ? (
|
|
67
|
+
<span className="text-muted-foreground text-xs">{item.description}</span>
|
|
68
|
+
) : null}
|
|
69
|
+
</div>
|
|
70
|
+
</CommandItem>
|
|
71
|
+
))}
|
|
72
|
+
</CommandGroup>
|
|
73
|
+
</CommandList>
|
|
74
|
+
</Command>
|
|
75
|
+
</DialogContent>
|
|
76
|
+
</Dialog>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { CommandMenu };
|
|
81
|
+
export type { CommandMenuItem, CommandMenuProps };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { Button, buttonVariants } from "./ui/button";
|
|
2
|
+
export {
|
|
3
|
+
Command,
|
|
4
|
+
CommandEmpty,
|
|
5
|
+
CommandGroup,
|
|
6
|
+
CommandInput,
|
|
7
|
+
CommandItem,
|
|
8
|
+
CommandList,
|
|
9
|
+
CommandSeparator,
|
|
10
|
+
CommandShortcut,
|
|
11
|
+
} from "./ui/command";
|
|
12
|
+
export {
|
|
13
|
+
Dialog,
|
|
14
|
+
DialogContent,
|
|
15
|
+
DialogDescription,
|
|
16
|
+
DialogFooter,
|
|
17
|
+
DialogHeader,
|
|
18
|
+
DialogTitle,
|
|
19
|
+
DialogTrigger,
|
|
20
|
+
} from "./ui/dialog";
|
|
21
|
+
export { CommandMenu, type CommandMenuItem, type CommandMenuProps } from "./command-menu";
|
|
22
|
+
export { ThemeToggle } from "./theme-toggle";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Moon, Sun } from "lucide-react";
|
|
2
|
+
import { useEffect, useState, useSyncExternalStore } from "react";
|
|
3
|
+
|
|
4
|
+
import { Button } from "./ui/button";
|
|
5
|
+
|
|
6
|
+
type Theme = "light" | "dark";
|
|
7
|
+
|
|
8
|
+
const getStoredTheme = (): Theme | null => {
|
|
9
|
+
if (typeof window === "undefined") {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const stored = window.localStorage.getItem("theme");
|
|
13
|
+
if (stored === "light" || stored === "dark") {
|
|
14
|
+
return stored;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getPrefersDark = (): boolean => {
|
|
20
|
+
if (typeof window === "undefined") {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const subscribePrefersDark = (callback: () => void) => {
|
|
27
|
+
if (typeof window === "undefined") {
|
|
28
|
+
return () => {};
|
|
29
|
+
}
|
|
30
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
31
|
+
media.addEventListener("change", callback);
|
|
32
|
+
return () => {
|
|
33
|
+
media.removeEventListener("change", callback);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const ThemeToggle = () => {
|
|
38
|
+
// useSyncExternalStore avoids hydration mismatch warnings while still letting
|
|
39
|
+
// us read the actual system preference on the client.
|
|
40
|
+
const prefersDark = useSyncExternalStore(subscribePrefersDark, getPrefersDark, () => false);
|
|
41
|
+
const [override, setOverride] = useState<Theme | null>(() => getStoredTheme());
|
|
42
|
+
const theme: Theme = override ?? (prefersDark ? "dark" : "light");
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
document.documentElement.classList.toggle("dark", theme === "dark");
|
|
46
|
+
}, [theme]);
|
|
47
|
+
|
|
48
|
+
const handleClick = () => {
|
|
49
|
+
const next: Theme = theme === "dark" ? "light" : "dark";
|
|
50
|
+
window.localStorage.setItem("theme", next);
|
|
51
|
+
setOverride(next);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Button aria-label="Toggle theme" onClick={handleClick} size="icon" variant="ghost">
|
|
56
|
+
{theme === "dark" ? <Sun /> : <Moon />}
|
|
57
|
+
</Button>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { ThemeToggle };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/cn";
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
9
|
+
{
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
size: "default",
|
|
12
|
+
variant: "default",
|
|
13
|
+
},
|
|
14
|
+
variants: {
|
|
15
|
+
size: {
|
|
16
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
17
|
+
icon: "size-9",
|
|
18
|
+
"icon-lg": "size-10",
|
|
19
|
+
"icon-sm": "size-8",
|
|
20
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
21
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
22
|
+
sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
|
|
23
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
24
|
+
},
|
|
25
|
+
variant: {
|
|
26
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
27
|
+
destructive:
|
|
28
|
+
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
|
|
29
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
30
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
31
|
+
outline:
|
|
32
|
+
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
33
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const Button = ({
|
|
40
|
+
asChild = false,
|
|
41
|
+
className,
|
|
42
|
+
size = "default",
|
|
43
|
+
variant = "default",
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<"button"> &
|
|
46
|
+
VariantProps<typeof buttonVariants> & {
|
|
47
|
+
asChild?: boolean;
|
|
48
|
+
}) => {
|
|
49
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Comp
|
|
53
|
+
className={cn(buttonVariants({ className, size, variant }))}
|
|
54
|
+
data-size={size}
|
|
55
|
+
data-slot="button"
|
|
56
|
+
data-variant={variant}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
+
import { SearchIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../../lib/cn";
|
|
8
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./dialog";
|
|
9
|
+
|
|
10
|
+
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
|
|
11
|
+
return (
|
|
12
|
+
<CommandPrimitive
|
|
13
|
+
className={cn(
|
|
14
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
data-slot="command"
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function CommandDialog({
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
description = "Search for a command to run...",
|
|
27
|
+
showCloseButton = true,
|
|
28
|
+
title = "Command Palette",
|
|
29
|
+
...props
|
|
30
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
31
|
+
className?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
showCloseButton?: boolean;
|
|
34
|
+
title?: string;
|
|
35
|
+
}) {
|
|
36
|
+
return (
|
|
37
|
+
<Dialog {...props}>
|
|
38
|
+
<DialogHeader className="sr-only">
|
|
39
|
+
<DialogTitle>{title}</DialogTitle>
|
|
40
|
+
<DialogDescription>{description}</DialogDescription>
|
|
41
|
+
</DialogHeader>
|
|
42
|
+
<DialogContent
|
|
43
|
+
className={cn("overflow-hidden p-0", className)}
|
|
44
|
+
showCloseButton={showCloseButton}
|
|
45
|
+
>
|
|
46
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
47
|
+
{children}
|
|
48
|
+
</Command>
|
|
49
|
+
</DialogContent>
|
|
50
|
+
</Dialog>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function CommandInput({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
58
|
+
return (
|
|
59
|
+
<div className="flex h-9 items-center gap-2 border-b px-3" data-slot="command-input-wrapper">
|
|
60
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
61
|
+
<CommandPrimitive.Input
|
|
62
|
+
className={cn(
|
|
63
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
data-slot="command-input"
|
|
67
|
+
{...props}
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
74
|
+
return (
|
|
75
|
+
<CommandPrimitive.List
|
|
76
|
+
className={cn("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto", className)}
|
|
77
|
+
data-slot="command-list"
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
84
|
+
return (
|
|
85
|
+
<CommandPrimitive.Empty
|
|
86
|
+
className="py-6 text-center text-sm"
|
|
87
|
+
data-slot="command-empty"
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function CommandGroup({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
97
|
+
return (
|
|
98
|
+
<CommandPrimitive.Group
|
|
99
|
+
className={cn(
|
|
100
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
101
|
+
className,
|
|
102
|
+
)}
|
|
103
|
+
data-slot="command-group"
|
|
104
|
+
{...props}
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function CommandSeparator({
|
|
110
|
+
className,
|
|
111
|
+
...props
|
|
112
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
113
|
+
return (
|
|
114
|
+
<CommandPrimitive.Separator
|
|
115
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
116
|
+
data-slot="command-separator"
|
|
117
|
+
{...props}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
123
|
+
return (
|
|
124
|
+
<CommandPrimitive.Item
|
|
125
|
+
className={cn(
|
|
126
|
+
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
data-slot="command-item"
|
|
130
|
+
{...props}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function CommandShortcut({ className, ...props }: React.ComponentProps<"span">) {
|
|
136
|
+
return (
|
|
137
|
+
<span
|
|
138
|
+
className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
|
|
139
|
+
data-slot="command-shortcut"
|
|
140
|
+
{...props}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
Command,
|
|
147
|
+
// fallow-ignore-next-line unused-export
|
|
148
|
+
CommandDialog,
|
|
149
|
+
CommandInput,
|
|
150
|
+
CommandList,
|
|
151
|
+
CommandEmpty,
|
|
152
|
+
CommandGroup,
|
|
153
|
+
CommandItem,
|
|
154
|
+
CommandShortcut,
|
|
155
|
+
CommandSeparator,
|
|
156
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { XIcon } from "lucide-react";
|
|
3
|
+
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../../lib/cn";
|
|
6
|
+
import { Button } from "./button";
|
|
7
|
+
|
|
8
|
+
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
9
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
13
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
17
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
21
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function DialogOverlay({
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
28
|
+
return (
|
|
29
|
+
<DialogPrimitive.Overlay
|
|
30
|
+
className={cn(
|
|
31
|
+
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
data-slot="dialog-overlay"
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function DialogContent({
|
|
41
|
+
children,
|
|
42
|
+
className,
|
|
43
|
+
showCloseButton = true,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
46
|
+
showCloseButton?: boolean;
|
|
47
|
+
}) {
|
|
48
|
+
return (
|
|
49
|
+
<DialogPortal data-slot="dialog-portal">
|
|
50
|
+
<DialogOverlay />
|
|
51
|
+
<DialogPrimitive.Content
|
|
52
|
+
className={cn(
|
|
53
|
+
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
data-slot="dialog-content"
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
{showCloseButton && (
|
|
61
|
+
<DialogPrimitive.Close
|
|
62
|
+
className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
63
|
+
data-slot="dialog-close"
|
|
64
|
+
>
|
|
65
|
+
<XIcon />
|
|
66
|
+
<span className="sr-only">Close</span>
|
|
67
|
+
</DialogPrimitive.Close>
|
|
68
|
+
)}
|
|
69
|
+
</DialogPrimitive.Content>
|
|
70
|
+
</DialogPortal>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
75
|
+
return (
|
|
76
|
+
<div
|
|
77
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
78
|
+
data-slot="dialog-header"
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function DialogFooter({
|
|
85
|
+
children,
|
|
86
|
+
className,
|
|
87
|
+
showCloseButton = false,
|
|
88
|
+
...props
|
|
89
|
+
}: React.ComponentProps<"div"> & {
|
|
90
|
+
showCloseButton?: boolean;
|
|
91
|
+
}) {
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
95
|
+
data-slot="dialog-footer"
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
{children}
|
|
99
|
+
{showCloseButton && (
|
|
100
|
+
<DialogPrimitive.Close asChild>
|
|
101
|
+
<Button variant="outline">Close</Button>
|
|
102
|
+
</DialogPrimitive.Close>
|
|
103
|
+
)}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
109
|
+
return (
|
|
110
|
+
<DialogPrimitive.Title
|
|
111
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
112
|
+
data-slot="dialog-title"
|
|
113
|
+
{...props}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function DialogDescription({
|
|
119
|
+
className,
|
|
120
|
+
...props
|
|
121
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
122
|
+
return (
|
|
123
|
+
<DialogPrimitive.Description
|
|
124
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
125
|
+
data-slot="dialog-description"
|
|
126
|
+
{...props}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
Dialog,
|
|
133
|
+
// fallow-ignore-next-line unused-export
|
|
134
|
+
DialogClose,
|
|
135
|
+
DialogContent,
|
|
136
|
+
DialogDescription,
|
|
137
|
+
DialogFooter,
|
|
138
|
+
DialogHeader,
|
|
139
|
+
// fallow-ignore-next-line unused-export
|
|
140
|
+
DialogOverlay,
|
|
141
|
+
// fallow-ignore-next-line unused-export
|
|
142
|
+
DialogPortal,
|
|
143
|
+
DialogTitle,
|
|
144
|
+
DialogTrigger,
|
|
145
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { authorSchema, postSchema, tagSchema } from "./index";
|
|
4
|
+
|
|
5
|
+
describe("postSchema", () => {
|
|
6
|
+
it("accepts a minimal post", () => {
|
|
7
|
+
const result = postSchema.safeParse({
|
|
8
|
+
description: "World",
|
|
9
|
+
pubDate: new Date("2026-01-01"),
|
|
10
|
+
title: "Hello",
|
|
11
|
+
});
|
|
12
|
+
expect(result.success).toBe(true);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("rejects missing title", () => {
|
|
16
|
+
const result = postSchema.safeParse({
|
|
17
|
+
description: "World",
|
|
18
|
+
pubDate: new Date(),
|
|
19
|
+
});
|
|
20
|
+
expect(result.success).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("coerces ISO date string to Date", () => {
|
|
24
|
+
const result = postSchema.safeParse({
|
|
25
|
+
description: "World",
|
|
26
|
+
pubDate: "2026-01-01",
|
|
27
|
+
title: "Hello",
|
|
28
|
+
});
|
|
29
|
+
expect(result.success).toBe(true);
|
|
30
|
+
if (result.success) {
|
|
31
|
+
expect(result.data.pubDate).toBeInstanceOf(Date);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("defaults draft to false", () => {
|
|
36
|
+
const result = postSchema.safeParse({
|
|
37
|
+
description: "World",
|
|
38
|
+
pubDate: new Date(),
|
|
39
|
+
title: "Hello",
|
|
40
|
+
});
|
|
41
|
+
if (result.success) {
|
|
42
|
+
expect(result.data.draft).toBe(false);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("validates tags as string array", () => {
|
|
47
|
+
const result = postSchema.safeParse({
|
|
48
|
+
description: "World",
|
|
49
|
+
pubDate: new Date(),
|
|
50
|
+
tags: ["foo", "bar"],
|
|
51
|
+
title: "Hello",
|
|
52
|
+
});
|
|
53
|
+
expect(result.success).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("tagSchema", () => {
|
|
58
|
+
it("accepts a minimal tag", () => {
|
|
59
|
+
expect(tagSchema.safeParse({ name: "javascript" }).success).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
it("rejects missing name", () => {
|
|
62
|
+
expect(tagSchema.safeParse({}).success).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("authorSchema", () => {
|
|
67
|
+
it("accepts a minimal author", () => {
|
|
68
|
+
expect(authorSchema.safeParse({ name: "Pedro" }).success).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
it("validates url field as URL string", () => {
|
|
71
|
+
const result = authorSchema.safeParse({ name: "Pedro", url: "not-a-url" });
|
|
72
|
+
expect(result.success).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const postSchema = z.object({
|
|
4
|
+
author: z.string().optional(),
|
|
5
|
+
cover: z.string().optional(),
|
|
6
|
+
coverAlt: z.string().optional(),
|
|
7
|
+
description: z.string().min(1),
|
|
8
|
+
draft: z.boolean().default(false),
|
|
9
|
+
pubDate: z.coerce.date(),
|
|
10
|
+
series: z.string().optional(),
|
|
11
|
+
tags: z.array(z.string()).default([]),
|
|
12
|
+
title: z.string().min(1),
|
|
13
|
+
updatedDate: z.coerce.date().optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const tagSchema = z.object({
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
name: z.string().min(1),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const authorSchema = z.object({
|
|
22
|
+
avatar: z.string().optional(),
|
|
23
|
+
bio: z.string().optional(),
|
|
24
|
+
name: z.string().min(1),
|
|
25
|
+
url: z.string().url().optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
type Post = z.infer<typeof postSchema>;
|
|
29
|
+
type Tag = z.infer<typeof tagSchema>;
|
|
30
|
+
type Author = z.infer<typeof authorSchema>;
|
|
31
|
+
|
|
32
|
+
export { authorSchema, postSchema, tagSchema };
|
|
33
|
+
export type { Author, Post, Tag };
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { cn } from "./cn";
|
|
4
|
+
|
|
5
|
+
describe("cn", () => {
|
|
6
|
+
it("merges class names", () => {
|
|
7
|
+
expect(cn("a", "b")).toBe("a b");
|
|
8
|
+
});
|
|
9
|
+
it("dedupes conflicting tailwind classes (last wins)", () => {
|
|
10
|
+
expect(cn("p-2", "p-4")).toBe("p-4");
|
|
11
|
+
});
|
|
12
|
+
it("filters falsy values", () => {
|
|
13
|
+
expect(cn("a", false, undefined, null, "b")).toBe("a b");
|
|
14
|
+
});
|
|
15
|
+
});
|
package/src/lib/cn.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { formatDate } from "./format-date";
|
|
4
|
+
|
|
5
|
+
describe("formatDate", () => {
|
|
6
|
+
it("formats a Date in en-US by default", () => {
|
|
7
|
+
expect(formatDate(new Date("2026-05-20T00:00:00Z"))).toBe("May 20, 2026");
|
|
8
|
+
});
|
|
9
|
+
it("respects locale", () => {
|
|
10
|
+
expect(formatDate(new Date("2026-05-20T00:00:00Z"), "pt-BR")).toMatch(/20 de maio de 2026/iv);
|
|
11
|
+
});
|
|
12
|
+
it("respects custom options", () => {
|
|
13
|
+
expect(
|
|
14
|
+
formatDate(new Date("2026-05-20T00:00:00Z"), "en-US", {
|
|
15
|
+
day: "2-digit",
|
|
16
|
+
month: "short",
|
|
17
|
+
year: "numeric",
|
|
18
|
+
}),
|
|
19
|
+
).toBe("May 20, 2026");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const defaultOptions: Intl.DateTimeFormatOptions = {
|
|
2
|
+
day: "numeric",
|
|
3
|
+
month: "long",
|
|
4
|
+
timeZone: "UTC",
|
|
5
|
+
year: "numeric",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const formatDate = (
|
|
9
|
+
date: Date,
|
|
10
|
+
locale: string = "en-US",
|
|
11
|
+
options: Intl.DateTimeFormatOptions = defaultOptions,
|
|
12
|
+
) => new Intl.DateTimeFormat(locale, { ...defaultOptions, ...options }).format(date);
|
|
13
|
+
|
|
14
|
+
export { formatDate };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { getRelatedPosts } from "./get-related-posts";
|
|
4
|
+
|
|
5
|
+
type TestPost = { data: { tags: Array<string> }; slug: string };
|
|
6
|
+
|
|
7
|
+
const a: TestPost = { data: { tags: ["x", "y"] }, slug: "a" };
|
|
8
|
+
const b: TestPost = { data: { tags: ["x"] }, slug: "b" };
|
|
9
|
+
const c: TestPost = { data: { tags: ["z"] }, slug: "c" };
|
|
10
|
+
const d: TestPost = { data: { tags: ["x", "y", "z"] }, slug: "d" };
|
|
11
|
+
|
|
12
|
+
describe("getRelatedPosts", () => {
|
|
13
|
+
it("excludes the current post", () => {
|
|
14
|
+
const related = getRelatedPosts(a, [a, b, c, d], 3);
|
|
15
|
+
expect(related.find((p) => p.slug === "a")).toBeUndefined();
|
|
16
|
+
});
|
|
17
|
+
it("ranks by shared tag count (desc)", () => {
|
|
18
|
+
const related = getRelatedPosts(a, [a, b, c, d], 3);
|
|
19
|
+
expect(related.map((p) => p.slug)).toEqual(["d", "b", "c"]);
|
|
20
|
+
});
|
|
21
|
+
it("limits to n", () => {
|
|
22
|
+
const related = getRelatedPosts(a, [a, b, c, d], 1);
|
|
23
|
+
expect(related).toHaveLength(1);
|
|
24
|
+
expect(related[0].slug).toBe("d");
|
|
25
|
+
});
|
|
26
|
+
it("falls back to other posts when no overlap exists", () => {
|
|
27
|
+
const lonely: TestPost = { data: { tags: ["nothing"] }, slug: "lonely" };
|
|
28
|
+
const related = getRelatedPosts(lonely, [lonely, b, c], 2);
|
|
29
|
+
expect(related).toHaveLength(2);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type HasTags = { data: { tags: Array<string> }; slug: string };
|
|
2
|
+
|
|
3
|
+
const countShared = (a: Array<string>, b: Array<string>) => {
|
|
4
|
+
const setB = new Set(b);
|
|
5
|
+
return a.filter((tag) => setB.has(tag)).length;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const getRelatedPosts = <T extends HasTags>(current: T, all: Array<T>, n: number) =>
|
|
9
|
+
all
|
|
10
|
+
.filter((post) => post.slug !== current.slug)
|
|
11
|
+
.map((post) => ({
|
|
12
|
+
post,
|
|
13
|
+
score: countShared(current.data.tags, post.data.tags),
|
|
14
|
+
}))
|
|
15
|
+
.toSorted((x, y) => y.score - x.score)
|
|
16
|
+
.slice(0, n)
|
|
17
|
+
.map(({ post }) => post);
|
|
18
|
+
|
|
19
|
+
export { getRelatedPosts };
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { readingTime } from "./reading-time";
|
|
4
|
+
|
|
5
|
+
describe("readingTime", () => {
|
|
6
|
+
it("returns 1 minute for short text", () => {
|
|
7
|
+
expect(readingTime("Hello world.")).toEqual({ minutes: 1, words: 2 });
|
|
8
|
+
});
|
|
9
|
+
it("scales by words at 200 wpm", () => {
|
|
10
|
+
const text = "word ".repeat(400).trim();
|
|
11
|
+
expect(readingTime(text)).toEqual({ minutes: 2, words: 400 });
|
|
12
|
+
});
|
|
13
|
+
it("strips HTML tags before counting", () => {
|
|
14
|
+
expect(readingTime("<p>Hello <strong>world</strong>.</p>")).toEqual({
|
|
15
|
+
minutes: 1,
|
|
16
|
+
words: 2,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it("counts markdown text", () => {
|
|
20
|
+
expect(readingTime("# Title\n\nSome body **text** here.")).toEqual({
|
|
21
|
+
minutes: 1,
|
|
22
|
+
words: 5,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const WORDS_PER_MINUTE = 200;
|
|
2
|
+
|
|
3
|
+
const readingTime = (input: string) => {
|
|
4
|
+
const stripped = input
|
|
5
|
+
.replaceAll(/<[^>]*>/gv, "")
|
|
6
|
+
.replaceAll(/[#*_`>\-]/gv, " ")
|
|
7
|
+
.replaceAll(/\s+/gv, " ")
|
|
8
|
+
.trim();
|
|
9
|
+
const words = stripped.length === 0 ? 0 : stripped.split(" ").length;
|
|
10
|
+
const minutes = Math.max(1, Math.ceil(words / WORDS_PER_MINUTE));
|
|
11
|
+
return { minutes, words };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { readingTime };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { slugify } from "./slugify";
|
|
4
|
+
|
|
5
|
+
describe("slugify", () => {
|
|
6
|
+
it("lowercases and hyphenates", () => {
|
|
7
|
+
expect(slugify("Hello World")).toBe("hello-world");
|
|
8
|
+
});
|
|
9
|
+
it("strips diacritics", () => {
|
|
10
|
+
expect(slugify("São Paulo")).toBe("sao-paulo");
|
|
11
|
+
});
|
|
12
|
+
it("strips punctuation", () => {
|
|
13
|
+
expect(slugify("It's a Test!")).toBe("its-a-test");
|
|
14
|
+
});
|
|
15
|
+
it("collapses repeated hyphens", () => {
|
|
16
|
+
expect(slugify("foo -- bar")).toBe("foo-bar");
|
|
17
|
+
});
|
|
18
|
+
it("trims leading/trailing hyphens", () => {
|
|
19
|
+
expect(slugify("-foo-")).toBe("foo");
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/* This stylesheet is consumed AFTER `@import "tailwindcss"` in the host app.
|
|
2
|
+
It contributes tokens, base styles, prose, and the dark variant. */
|
|
3
|
+
|
|
4
|
+
@import "tw-animate-css";
|
|
5
|
+
|
|
6
|
+
@custom-variant dark (&:is(.dark *));
|
|
7
|
+
|
|
8
|
+
@theme {
|
|
9
|
+
--color-background: oklch(1 0 0);
|
|
10
|
+
--color-foreground: oklch(0.145 0 0);
|
|
11
|
+
--color-card: oklch(1 0 0);
|
|
12
|
+
--color-card-foreground: oklch(0.145 0 0);
|
|
13
|
+
--color-popover: oklch(1 0 0);
|
|
14
|
+
--color-popover-foreground: oklch(0.145 0 0);
|
|
15
|
+
--color-primary: oklch(0.205 0 0);
|
|
16
|
+
--color-primary-foreground: oklch(0.985 0 0);
|
|
17
|
+
--color-secondary: oklch(0.97 0 0);
|
|
18
|
+
--color-secondary-foreground: oklch(0.205 0 0);
|
|
19
|
+
--color-muted: oklch(0.97 0 0);
|
|
20
|
+
--color-muted-foreground: oklch(0.556 0 0);
|
|
21
|
+
--color-accent: oklch(0.97 0 0);
|
|
22
|
+
--color-accent-foreground: oklch(0.205 0 0);
|
|
23
|
+
--color-destructive: oklch(0.577 0.245 27.325);
|
|
24
|
+
--color-destructive-foreground: oklch(0.985 0 0);
|
|
25
|
+
--color-border: oklch(0.922 0 0);
|
|
26
|
+
--color-input: oklch(0.922 0 0);
|
|
27
|
+
--color-ring: oklch(0.708 0 0);
|
|
28
|
+
|
|
29
|
+
--radius-sm: 0.25rem;
|
|
30
|
+
--radius-md: 0.5rem;
|
|
31
|
+
--radius-lg: 0.75rem;
|
|
32
|
+
--radius-xl: 1rem;
|
|
33
|
+
|
|
34
|
+
--font-sans:
|
|
35
|
+
ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
36
|
+
--font-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
|
|
37
|
+
--font-mono:
|
|
38
|
+
ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.dark {
|
|
42
|
+
--color-background: oklch(0.145 0 0);
|
|
43
|
+
--color-foreground: oklch(0.985 0 0);
|
|
44
|
+
--color-card: oklch(0.145 0 0);
|
|
45
|
+
--color-card-foreground: oklch(0.985 0 0);
|
|
46
|
+
--color-popover: oklch(0.145 0 0);
|
|
47
|
+
--color-popover-foreground: oklch(0.985 0 0);
|
|
48
|
+
--color-primary: oklch(0.985 0 0);
|
|
49
|
+
--color-primary-foreground: oklch(0.205 0 0);
|
|
50
|
+
--color-secondary: oklch(0.269 0 0);
|
|
51
|
+
--color-secondary-foreground: oklch(0.985 0 0);
|
|
52
|
+
--color-muted: oklch(0.269 0 0);
|
|
53
|
+
--color-muted-foreground: oklch(0.708 0 0);
|
|
54
|
+
--color-accent: oklch(0.269 0 0);
|
|
55
|
+
--color-accent-foreground: oklch(0.985 0 0);
|
|
56
|
+
--color-destructive: oklch(0.704 0.191 22.216);
|
|
57
|
+
--color-destructive-foreground: oklch(0.985 0 0);
|
|
58
|
+
--color-border: oklch(0.269 0 0);
|
|
59
|
+
--color-input: oklch(0.269 0 0);
|
|
60
|
+
--color-ring: oklch(0.556 0 0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@layer base {
|
|
64
|
+
*,
|
|
65
|
+
*::before,
|
|
66
|
+
*::after {
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
}
|
|
69
|
+
html {
|
|
70
|
+
-webkit-text-size-adjust: 100%;
|
|
71
|
+
}
|
|
72
|
+
body {
|
|
73
|
+
background-color: var(--color-background);
|
|
74
|
+
color: var(--color-foreground);
|
|
75
|
+
font-family: var(--font-sans);
|
|
76
|
+
font-feature-settings:
|
|
77
|
+
"rlig" 1,
|
|
78
|
+
"calt" 1;
|
|
79
|
+
line-height: 1.6;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
:focus-visible {
|
|
83
|
+
outline: 2px solid var(--color-ring);
|
|
84
|
+
outline-offset: 2px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
button:not(:disabled),
|
|
88
|
+
[role="button"]:not(:disabled) {
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
::-webkit-scrollbar {
|
|
93
|
+
width: 6px;
|
|
94
|
+
height: 6px;
|
|
95
|
+
}
|
|
96
|
+
::-webkit-scrollbar-track {
|
|
97
|
+
background: transparent;
|
|
98
|
+
}
|
|
99
|
+
::-webkit-scrollbar-thumb {
|
|
100
|
+
background: var(--color-border);
|
|
101
|
+
border-radius: 6px;
|
|
102
|
+
}
|
|
103
|
+
* {
|
|
104
|
+
scrollbar-width: thin;
|
|
105
|
+
scrollbar-color: var(--color-border) transparent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@layer components {
|
|
110
|
+
.prose {
|
|
111
|
+
max-width: 65ch;
|
|
112
|
+
color: var(--color-foreground);
|
|
113
|
+
font-size: 1rem;
|
|
114
|
+
line-height: 1.75;
|
|
115
|
+
}
|
|
116
|
+
.prose :where(h1, h2, h3, h4, h5, h6) {
|
|
117
|
+
color: var(--color-foreground);
|
|
118
|
+
font-weight: 700;
|
|
119
|
+
line-height: 1.25;
|
|
120
|
+
margin-top: 2em;
|
|
121
|
+
margin-bottom: 0.75em;
|
|
122
|
+
scroll-margin-top: 4rem;
|
|
123
|
+
}
|
|
124
|
+
.prose h1 {
|
|
125
|
+
font-size: 2.25rem;
|
|
126
|
+
}
|
|
127
|
+
.prose h2 {
|
|
128
|
+
font-size: 1.75rem;
|
|
129
|
+
}
|
|
130
|
+
.prose h3 {
|
|
131
|
+
font-size: 1.375rem;
|
|
132
|
+
}
|
|
133
|
+
.prose p {
|
|
134
|
+
margin-top: 1em;
|
|
135
|
+
margin-bottom: 1em;
|
|
136
|
+
}
|
|
137
|
+
.prose a {
|
|
138
|
+
color: var(--color-accent-foreground);
|
|
139
|
+
text-decoration: underline;
|
|
140
|
+
text-underline-offset: 0.2em;
|
|
141
|
+
text-decoration-color: var(--color-border);
|
|
142
|
+
transition: text-decoration-color 0.15s;
|
|
143
|
+
}
|
|
144
|
+
.prose a:hover {
|
|
145
|
+
text-decoration-color: var(--color-accent-foreground);
|
|
146
|
+
}
|
|
147
|
+
.prose blockquote {
|
|
148
|
+
margin: 1.5em 0;
|
|
149
|
+
padding-left: 1em;
|
|
150
|
+
border-left: 3px solid var(--color-border);
|
|
151
|
+
color: var(--color-muted-foreground);
|
|
152
|
+
font-style: italic;
|
|
153
|
+
}
|
|
154
|
+
.prose code {
|
|
155
|
+
font-family: var(--font-mono);
|
|
156
|
+
font-size: 0.875em;
|
|
157
|
+
background-color: var(--color-muted);
|
|
158
|
+
padding: 0.125em 0.375em;
|
|
159
|
+
border-radius: var(--radius-sm);
|
|
160
|
+
}
|
|
161
|
+
.prose pre {
|
|
162
|
+
margin: 1.5em 0;
|
|
163
|
+
padding: 1em 1.25em;
|
|
164
|
+
background-color: var(--color-muted);
|
|
165
|
+
border-radius: var(--radius-md);
|
|
166
|
+
overflow-x: auto;
|
|
167
|
+
font-size: 0.875rem;
|
|
168
|
+
line-height: 1.6;
|
|
169
|
+
}
|
|
170
|
+
.prose pre code {
|
|
171
|
+
background: none;
|
|
172
|
+
padding: 0;
|
|
173
|
+
font-size: inherit;
|
|
174
|
+
}
|
|
175
|
+
.prose ul,
|
|
176
|
+
.prose ol {
|
|
177
|
+
margin: 1em 0;
|
|
178
|
+
padding-left: 1.5em;
|
|
179
|
+
}
|
|
180
|
+
.prose li {
|
|
181
|
+
margin: 0.25em 0;
|
|
182
|
+
}
|
|
183
|
+
.prose ul {
|
|
184
|
+
list-style-type: disc;
|
|
185
|
+
}
|
|
186
|
+
.prose ol {
|
|
187
|
+
list-style-type: decimal;
|
|
188
|
+
}
|
|
189
|
+
.prose img {
|
|
190
|
+
border-radius: var(--radius-md);
|
|
191
|
+
margin: 1.5em 0;
|
|
192
|
+
}
|
|
193
|
+
.prose hr {
|
|
194
|
+
margin: 2em 0;
|
|
195
|
+
border: 0;
|
|
196
|
+
border-top: 1px solid var(--color-border);
|
|
197
|
+
}
|
|
198
|
+
.prose table {
|
|
199
|
+
width: 100%;
|
|
200
|
+
border-collapse: collapse;
|
|
201
|
+
margin: 1.5em 0;
|
|
202
|
+
}
|
|
203
|
+
.prose th,
|
|
204
|
+
.prose td {
|
|
205
|
+
padding: 0.5em 0.75em;
|
|
206
|
+
border-bottom: 1px solid var(--color-border);
|
|
207
|
+
text-align: left;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import plugin from "tailwindcss/plugin";
|
|
2
|
+
|
|
3
|
+
const awesomenessPreset = plugin(({ addUtilities, addVariant }) => {
|
|
4
|
+
addVariant("dark", "&:is(.dark *)");
|
|
5
|
+
|
|
6
|
+
addUtilities({
|
|
7
|
+
".icon-inline-end": { marginInlineStart: "0.375rem" },
|
|
8
|
+
".icon-inline-start": { marginInlineEnd: "0.375rem" },
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export default awesomenessPreset;
|