@fullstackdatasolutions/articles 1.1.0 → 1.2.0
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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/index.cjs +41 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +41 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ArticleDetailHero.tsx +44 -19
- package/src/Breadcrumb.tsx +4 -1
- package/src/__tests__/ArticleDetailHero.test.tsx +57 -0
package/dist/index.d.cts
CHANGED
|
@@ -602,10 +602,12 @@ declare function AuthorDetailHero({ author, articleCount }: AuthorDetailHeroProp
|
|
|
602
602
|
type BreadcrumbProps = Readonly<{
|
|
603
603
|
items: BreadcrumbItem[];
|
|
604
604
|
className?: string;
|
|
605
|
+
/** Max-width utility class applied to the breadcrumb list. Default: 'max-w-7xl'. */
|
|
606
|
+
containerClassName?: string;
|
|
605
607
|
showSchema?: boolean;
|
|
606
608
|
separator?: string;
|
|
607
609
|
}>;
|
|
608
|
-
declare function Breadcrumb({ items, className, showSchema, separator, }: BreadcrumbProps): react_jsx_runtime.JSX.Element | null;
|
|
610
|
+
declare function Breadcrumb({ items, className, containerClassName, showSchema, separator, }: BreadcrumbProps): react_jsx_runtime.JSX.Element | null;
|
|
609
611
|
declare function BreadcrumbSchema({ items }: Readonly<{
|
|
610
612
|
items: BreadcrumbItem[];
|
|
611
613
|
}>): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -602,10 +602,12 @@ declare function AuthorDetailHero({ author, articleCount }: AuthorDetailHeroProp
|
|
|
602
602
|
type BreadcrumbProps = Readonly<{
|
|
603
603
|
items: BreadcrumbItem[];
|
|
604
604
|
className?: string;
|
|
605
|
+
/** Max-width utility class applied to the breadcrumb list. Default: 'max-w-7xl'. */
|
|
606
|
+
containerClassName?: string;
|
|
605
607
|
showSchema?: boolean;
|
|
606
608
|
separator?: string;
|
|
607
609
|
}>;
|
|
608
|
-
declare function Breadcrumb({ items, className, showSchema, separator, }: BreadcrumbProps): react_jsx_runtime.JSX.Element | null;
|
|
610
|
+
declare function Breadcrumb({ items, className, containerClassName, showSchema, separator, }: BreadcrumbProps): react_jsx_runtime.JSX.Element | null;
|
|
609
611
|
declare function BreadcrumbSchema({ items }: Readonly<{
|
|
610
612
|
items: BreadcrumbItem[];
|
|
611
613
|
}>): react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -194,6 +194,7 @@ function getDisplayItems(items) {
|
|
|
194
194
|
function Breadcrumb({
|
|
195
195
|
items,
|
|
196
196
|
className = "",
|
|
197
|
+
containerClassName = "max-w-7xl",
|
|
197
198
|
showSchema = true,
|
|
198
199
|
separator = ">"
|
|
199
200
|
}) {
|
|
@@ -205,7 +206,7 @@ function Breadcrumb({
|
|
|
205
206
|
{
|
|
206
207
|
"aria-label": "Breadcrumb",
|
|
207
208
|
className: `border-b border-border bg-background/80 px-4 py-3 text-sm text-muted-foreground ${className}`,
|
|
208
|
-
children: /* @__PURE__ */ jsx2("ol", { className:
|
|
209
|
+
children: /* @__PURE__ */ jsx2("ol", { className: `mx-auto flex items-center gap-2 overflow-hidden ${containerClassName}`, children: displayItems.map((item, index) => {
|
|
209
210
|
const isLast = index === displayItems.length - 1;
|
|
210
211
|
const key = `${item.name}-${index}`;
|
|
211
212
|
return /* @__PURE__ */ jsxs2("li", { className: "flex min-w-0 items-center gap-2", children: [
|
|
@@ -1094,6 +1095,15 @@ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
|
1094
1095
|
function toSlug(cat) {
|
|
1095
1096
|
return cat.toLowerCase().replaceAll(/\s+/g, "-").replaceAll(/[^a-z0-9-]/g, "");
|
|
1096
1097
|
}
|
|
1098
|
+
function resolveAvatarUrl(author, config) {
|
|
1099
|
+
if (!author.avatar) return null;
|
|
1100
|
+
if (author.avatar.startsWith("http://") || author.avatar.startsWith("https://")) {
|
|
1101
|
+
return author.avatar;
|
|
1102
|
+
}
|
|
1103
|
+
if (!(config == null ? void 0 : config.siteUrl)) return null;
|
|
1104
|
+
const siteUrl = config.siteUrl.replace(/\/$/, "");
|
|
1105
|
+
return `${siteUrl}/articles/authors/${author.slug}/${author.avatar.replace(/^\/+/, "")}`;
|
|
1106
|
+
}
|
|
1097
1107
|
function ArticleDetailHero({
|
|
1098
1108
|
article,
|
|
1099
1109
|
categoryBasePath = "/articles/category",
|
|
@@ -1211,24 +1221,36 @@ function ArticleDetailHero({
|
|
|
1211
1221
|
/* @__PURE__ */ jsx13(Clock3, { className: "h-4 w-4" }),
|
|
1212
1222
|
/* @__PURE__ */ jsx13("span", { children: article.readTime })
|
|
1213
1223
|
] }),
|
|
1214
|
-
showConfiguredAuthors &&
|
|
1215
|
-
|
|
1216
|
-
/* @__PURE__ */ jsxs13("
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1224
|
+
showConfiguredAuthors && (() => {
|
|
1225
|
+
const singleAvatarUrl = authors.length === 1 ? resolveAvatarUrl(authors[0], config) : null;
|
|
1226
|
+
return /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1227
|
+
singleAvatarUrl ? /* @__PURE__ */ jsx13(
|
|
1228
|
+
Image5,
|
|
1229
|
+
{
|
|
1230
|
+
src: singleAvatarUrl,
|
|
1231
|
+
alt: "",
|
|
1232
|
+
width: 20,
|
|
1233
|
+
height: 20,
|
|
1234
|
+
className: "h-5 w-5 rounded-full object-cover"
|
|
1235
|
+
}
|
|
1236
|
+
) : /* @__PURE__ */ jsx13(User2, { className: "h-4 w-4" }),
|
|
1237
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
1238
|
+
"By",
|
|
1239
|
+
" ",
|
|
1240
|
+
authors.map((author, index) => /* @__PURE__ */ jsxs13(Fragment3, { children: [
|
|
1241
|
+
index > 0 && ", ",
|
|
1242
|
+
/* @__PURE__ */ jsx13(
|
|
1243
|
+
Link8,
|
|
1244
|
+
{
|
|
1245
|
+
href: `/articles/authors/${author.slug}`,
|
|
1246
|
+
className: "font-medium text-white underline-offset-4 hover:underline",
|
|
1247
|
+
children: author.name
|
|
1248
|
+
}
|
|
1249
|
+
)
|
|
1250
|
+
] }, author.slug))
|
|
1251
|
+
] })
|
|
1252
|
+
] });
|
|
1253
|
+
})(),
|
|
1232
1254
|
showLegacyAuthor && /* @__PURE__ */ jsxs13("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1233
1255
|
/* @__PURE__ */ jsx13(User2, { className: "h-4 w-4" }),
|
|
1234
1256
|
/* @__PURE__ */ jsxs13("span", { children: [
|