veslx 0.1.66 → 0.1.67
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.
|
@@ -3,8 +3,12 @@ import { Link } from "react-router-dom";
|
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
4
|
import { formatDate } from "../lib/format-date.js";
|
|
5
5
|
import { ArrowRight, Presentation } from "lucide-react";
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
function isRouterLink(url) {
|
|
7
|
+
return url.startsWith("/") && !url.startsWith("//") && !url.startsWith("/raw/");
|
|
8
|
+
}
|
|
9
|
+
function PostListItem({ title, description, date, href, external, openInNewTab, isSlides }) {
|
|
10
|
+
const useRouter = !external && isRouterLink(href) && !href.startsWith("http") && !href.startsWith("mailto:");
|
|
11
|
+
const newTab = openInNewTab ?? href.startsWith("http");
|
|
8
12
|
const className = cn(
|
|
9
13
|
"group block py-3 px-3 -mx-3 rounded-md",
|
|
10
14
|
"transition-colors duration-150"
|
|
@@ -31,22 +35,22 @@ function PostListItem({ title, description, date, href, linkPath, external, open
|
|
|
31
35
|
}
|
|
32
36
|
)
|
|
33
37
|
] });
|
|
34
|
-
if (
|
|
38
|
+
if (useRouter) {
|
|
35
39
|
return /* @__PURE__ */ jsx(
|
|
36
|
-
|
|
40
|
+
Link,
|
|
37
41
|
{
|
|
38
|
-
|
|
39
|
-
target: openInNewTab ? "_blank" : void 0,
|
|
40
|
-
rel: openInNewTab ? "noopener noreferrer" : void 0,
|
|
42
|
+
to: href,
|
|
41
43
|
className,
|
|
42
44
|
children: content
|
|
43
45
|
}
|
|
44
46
|
);
|
|
45
47
|
}
|
|
46
48
|
return /* @__PURE__ */ jsx(
|
|
47
|
-
|
|
49
|
+
"a",
|
|
48
50
|
{
|
|
49
|
-
|
|
51
|
+
href,
|
|
52
|
+
target: newTab ? "_blank" : void 0,
|
|
53
|
+
rel: newTab ? "noopener noreferrer" : void 0,
|
|
50
54
|
className,
|
|
51
55
|
children: content
|
|
52
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-list-item.js","sources":["../../../src/components/post-list-item.tsx"],"sourcesContent":["import { Link } from \"react-router-dom\";\nimport { cn } from \"@/lib/utils\";\nimport { formatDate } from \"@/lib/format-date\";\nimport { ArrowRight, Presentation } from \"lucide-react\";\n\ninterface PostListItemProps {\n title: string;\n description?: string;\n date?: Date;\n href
|
|
1
|
+
{"version":3,"file":"post-list-item.js","sources":["../../../src/components/post-list-item.tsx"],"sourcesContent":["import { Link } from \"react-router-dom\";\nimport { cn } from \"@/lib/utils\";\nimport { formatDate } from \"@/lib/format-date\";\nimport { ArrowRight, Presentation } from \"lucide-react\";\n\ninterface PostListItemProps {\n title: string;\n description?: string;\n date?: Date;\n href: string;\n external?: boolean;\n openInNewTab?: boolean;\n isSlides?: boolean;\n}\n\nfunction isRouterLink(url: string): boolean {\n return url.startsWith('/') && !url.startsWith('//') && !url.startsWith('/raw/');\n}\n\nexport function PostListItem({ title, description, date, href, external, openInNewTab, isSlides }: PostListItemProps) {\n const useRouter = !external && isRouterLink(href) && !href.startsWith('http') && !href.startsWith('mailto:');\n const newTab = openInNewTab ?? href.startsWith('http');\n const className = cn(\n \"group block py-3 px-3 -mx-3 rounded-md\",\n \"transition-colors duration-150\",\n );\n\n const content = (\n <article className=\"flex items-center gap-4\">\n {/* Main content */}\n <div className=\"flex-1 min-w-0\">\n <div className={cn(\n \"text-sm font-medium text-foreground\",\n \"group-hover:underline\",\n \"flex items-center gap-2\"\n )}>\n <span>{title}</span>\n <ArrowRight className=\"h-3 w-3 opacity-0 -translate-x-1 group-hover:opacity-100 group-hover:translate-x-0 transition-all duration-200 text-primary\" />\n </div>\n\n {description && (\n <div className=\"text-sm text-muted-foreground line-clamp-1 mt-0.5\">\n {description}\n </div>\n )}\n </div>\n\n {isSlides && (\n <Presentation className=\"h-3 w-3 text-muted-foreground\" />\n )}\n <time\n dateTime={date?.toISOString()}\n className=\"font-mono text-xs text-muted-foreground tabular-nums w-20 flex-shrink-0\"\n >\n {date && formatDate(date)}\n </time>\n </article>\n );\n\n if (useRouter) {\n return (\n <Link\n to={href}\n className={className}\n >\n {content}\n </Link>\n );\n }\n\n return (\n <a\n href={href}\n target={newTab ? \"_blank\" : undefined}\n rel={newTab ? \"noopener noreferrer\" : undefined}\n className={className}\n >\n {content}\n </a>\n );\n}\n"],"names":[],"mappings":";;;;;AAeA,SAAS,aAAa,KAAsB;AAC1C,SAAO,IAAI,WAAW,GAAG,KAAK,CAAC,IAAI,WAAW,IAAI,KAAK,CAAC,IAAI,WAAW,OAAO;AAChF;AAEO,SAAS,aAAa,EAAE,OAAO,aAAa,MAAM,MAAM,UAAU,cAAc,YAA+B;AACpH,QAAM,YAAY,CAAC,YAAY,aAAa,IAAI,KAAK,CAAC,KAAK,WAAW,MAAM,KAAK,CAAC,KAAK,WAAW,SAAS;AAC3G,QAAM,SAAS,gBAAgB,KAAK,WAAW,MAAM;AACrD,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,EAAA;AAGF,QAAM,UACJ,qBAAC,WAAA,EAAQ,WAAU,2BAEjB,UAAA;AAAA,IAAA,qBAAC,OAAA,EAAI,WAAU,kBACb,UAAA;AAAA,MAAA,qBAAC,SAAI,WAAW;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,MAAA,GAEA,UAAA;AAAA,QAAA,oBAAC,UAAM,UAAA,MAAA,CAAM;AAAA,QACb,oBAAC,YAAA,EAAW,WAAU,8HAAA,CAA8H;AAAA,MAAA,GACtJ;AAAA,MAEC,eACC,oBAAC,OAAA,EAAI,WAAU,qDACZ,UAAA,YAAA,CACH;AAAA,IAAA,GAEJ;AAAA,IAEC,YACC,oBAAC,cAAA,EAAa,WAAU,gCAAA,CAAgC;AAAA,IAE1D;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,UAAU,6BAAM;AAAA,QAChB,WAAU;AAAA,QAET,UAAA,QAAQ,WAAW,IAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAC1B,GACF;AAGF,MAAI,WAAW;AACb,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI;AAAA,QACJ;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AAEA,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,QAAQ,SAAS,WAAW;AAAA,MAC5B,KAAK,SAAS,wBAAwB;AAAA,MACtC;AAAA,MAEC,UAAA;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
package/package.json
CHANGED
|
@@ -7,16 +7,19 @@ interface PostListItemProps {
|
|
|
7
7
|
title: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
date?: Date;
|
|
10
|
-
href
|
|
11
|
-
/** Alias for href (used in MDX as linkPath) */
|
|
12
|
-
linkPath?: string;
|
|
10
|
+
href: string;
|
|
13
11
|
external?: boolean;
|
|
14
12
|
openInNewTab?: boolean;
|
|
15
13
|
isSlides?: boolean;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function isRouterLink(url: string): boolean {
|
|
17
|
+
return url.startsWith('/') && !url.startsWith('//') && !url.startsWith('/raw/');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function PostListItem({ title, description, date, href, external, openInNewTab, isSlides }: PostListItemProps) {
|
|
21
|
+
const useRouter = !external && isRouterLink(href) && !href.startsWith('http') && !href.startsWith('mailto:');
|
|
22
|
+
const newTab = openInNewTab ?? href.startsWith('http');
|
|
20
23
|
const className = cn(
|
|
21
24
|
"group block py-3 px-3 -mx-3 rounded-md",
|
|
22
25
|
"transition-colors duration-150",
|
|
@@ -54,25 +57,25 @@ export function PostListItem({ title, description, date, href, linkPath, externa
|
|
|
54
57
|
</article>
|
|
55
58
|
);
|
|
56
59
|
|
|
57
|
-
if (
|
|
60
|
+
if (useRouter) {
|
|
58
61
|
return (
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
target={openInNewTab ? "_blank" : undefined}
|
|
62
|
-
rel={openInNewTab ? "noopener noreferrer" : undefined}
|
|
62
|
+
<Link
|
|
63
|
+
to={href}
|
|
63
64
|
className={className}
|
|
64
65
|
>
|
|
65
66
|
{content}
|
|
66
|
-
</
|
|
67
|
+
</Link>
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
return (
|
|
71
|
-
<
|
|
72
|
-
|
|
72
|
+
<a
|
|
73
|
+
href={href}
|
|
74
|
+
target={newTab ? "_blank" : undefined}
|
|
75
|
+
rel={newTab ? "noopener noreferrer" : undefined}
|
|
73
76
|
className={className}
|
|
74
77
|
>
|
|
75
78
|
{content}
|
|
76
|
-
</
|
|
79
|
+
</a>
|
|
77
80
|
);
|
|
78
81
|
}
|