Skip to content

Commit 5d307ed

Browse files
committed
Merge branch 'feat-recomendations' into feat-rag-chat
2 parents 235e9b4 + 8a076a8 commit 5d307ed

24 files changed

+406
-229
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
"@faustwp/cli": "^3.2.3",
2727
"@faustwp/core": "^3.2.3",
2828
"@headlessui/react": "^2.2.4",
29-
"@heroicons/react": "^2.2.0",
30-
"@icons-pack/react-simple-icons": "^13.1.0",
3129
"@jsdevtools/rehype-url-inspector": "^2.0.2",
3230
"@next/third-parties": "^15.3.4",
3331
"@octokit/core": "^7.0.2",
@@ -47,6 +45,8 @@
4745
"react": "^19.1.0",
4846
"react-dom": "^19.1.0",
4947
"react-markdown": "^10.1.0",
48+
"react-icons": "^5.5.0",
49+
"react-intersection-observer": "^9.16.0",
5050
"rehype-callouts": "^2.1.0",
5151
"rehype-external-links": "^3.0.0",
5252
"rehype-pretty-code": "^0.14.1",

pnpm-lock.yaml

Lines changed: 30 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/smart-search.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { hash } from "node:crypto";
21
import { env, exit } from "node:process";
32
import { getTextContentFromMd } from "../src/lib/remark-parsing.mjs";
43
import {
54
getAllDocMeta,
65
getRawDocContent,
76
getDocUriFromPath,
7+
generateDocIdFromUri,
88
} from "../src/lib/remote-mdx-files.mjs";
99

1010
const {
@@ -59,7 +59,7 @@ async function collectPages() {
5959

6060
const cleanedPath = getDocUriFromPath(entry.path);
6161

62-
const id = hash("sha-1", `mdx:${cleanedPath}`);
62+
const id = generateDocIdFromUri(cleanedPath);
6363

6464
pages.push({
6565
id,

src/components/blog-breadcrumbs.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChevronRightIcon } from "@heroicons/react/24/outline";
1+
import { HiOutlineChevronRight } from "react-icons/hi2";
22
import Link from "@/components/link";
33

44
export default function BlogBreadcrumbs({ currentPostTitle }) {
@@ -13,7 +13,7 @@ export default function BlogBreadcrumbs({ currentPostTitle }) {
1313
>
1414
<span>Blog</span>
1515
<span>
16-
<ChevronRightIcon className="inline h-5 w-10 pl-4 align-text-top" />
16+
<HiOutlineChevronRight className="inline h-5 w-10 pl-4 align-text-top" />
1717
</span>
1818
</Link>
1919

src/components/doc-type-tag.jsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { classNames } from "@/utils/strings";
2+
3+
export default function DocTypeTag(type) {
4+
if (!type || !type.type) {
5+
return;
6+
}
7+
8+
const theType = type.type || type;
9+
10+
const config = {
11+
name: "Ext",
12+
className: "bg-gray-500",
13+
};
14+
15+
if (theType === "mdx_doc") {
16+
config.name = "Doc";
17+
config.className = "bg-teal-800";
18+
} else if (theType === "post" || theType === "page") {
19+
config.name = "Blog";
20+
config.className = "bg-purple-600";
21+
}
22+
23+
return (
24+
<span
25+
className={classNames(
26+
"mr-2 inline-block rounded px-2 py-1 text-xs font-semibold text-gray-200 uppercase",
27+
config.className,
28+
)}
29+
>
30+
{config.name}
31+
</span>
32+
);
33+
}

src/components/docs-breadcrumbs.jsx

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ChevronRightIcon } from "@heroicons/react/24/outline";
21
import { useRouter } from "next/router";
2+
import { HiOutlineChevronRight } from "react-icons/hi2";
33
import Link from "@/components/link";
44
import { sendSelectItemEvent } from "@/lib/analytics.mjs";
5-
import { normalizeHref } from "@/utils/strings";
5+
import { classNames, normalizeHref } from "@/utils/strings";
66

7-
export default function DocsBreadcrumbs({ routes }) {
7+
export default function DocsBreadcrumbs({ routes, className }) {
88
const generateBreadcrumbs = (breadcrumbRoutes, currentRoute) => {
99
const breadcrumbs = [];
1010

@@ -48,37 +48,40 @@ export default function DocsBreadcrumbs({ routes }) {
4848
}
4949

5050
return (
51-
<div className="mt-4 mb-7 md:mt-2 md:mb-10">
52-
<div className="flex flex-wrap items-center gap-2 text-sm">
53-
{breadcrumbLinks.map((breadcrumb, index) =>
54-
normalizeHref(breadcrumb.route) === normalizeHref(currentPath) ? (
55-
<span key={index}>{breadcrumb.title}</span>
56-
) : (
57-
<Link
58-
key={index}
59-
className="font-normal text-gray-400 no-underline transition duration-200 ease-in hover:text-white focus:text-white"
60-
href={breadcrumb.route}
61-
noDefaultStyles
62-
aria-label={breadcrumb.title}
63-
onClick={() => {
64-
sendSelectItemEvent({
65-
list: { id: "docs_breadcrumbs", name: "Docs Breadcrumbs" },
66-
item: {
67-
item_id: breadcrumb.route,
68-
item_name: breadcrumb.title,
69-
item_category: "mdx_doc",
70-
},
71-
});
72-
}}
73-
>
74-
<span>{breadcrumb.title}</span>
75-
<span>
76-
<ChevronRightIcon className="inline h-5 w-10 pl-4 align-text-top" />
77-
</span>
78-
</Link>
79-
),
80-
)}
81-
</div>
82-
</div>
51+
<nav
52+
className={classNames(
53+
"flex flex-wrap items-center gap-2 text-sm",
54+
className,
55+
)}
56+
>
57+
{breadcrumbLinks.map((breadcrumb, index) =>
58+
normalizeHref(breadcrumb.route) === normalizeHref(currentPath) ? (
59+
<span key={index}>{breadcrumb.title}</span>
60+
) : (
61+
<Link
62+
key={index}
63+
className="font-normal text-gray-400 no-underline transition duration-200 ease-in hover:text-white focus:text-white"
64+
href={breadcrumb.route}
65+
noDefaultStyles
66+
aria-label={breadcrumb.title}
67+
onClick={() => {
68+
sendSelectItemEvent({
69+
list: { id: "docs_breadcrumbs", name: "Docs Breadcrumbs" },
70+
item: {
71+
item_id: breadcrumb.route,
72+
item_name: breadcrumb.title,
73+
item_category: "mdx_doc",
74+
},
75+
});
76+
}}
77+
>
78+
<span>{breadcrumb.title}</span>
79+
<span>
80+
<HiOutlineChevronRight className="inline h-5 w-10 pl-4 align-text-top" />
81+
</span>
82+
</Link>
83+
),
84+
)}
85+
</nav>
8386
);
8487
}

src/components/docs-layout.jsx

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import {
33
DisclosureButton,
44
DisclosurePanel,
55
} from "@headlessui/react";
6-
import { ChevronRightIcon, ChevronDownIcon } from "@heroicons/react/24/outline";
76
import { useRouter } from "next/router";
7+
import { HiOutlineChevronRight, HiOutlineChevronDown } from "react-icons/hi2";
88
import DocsBreadcrumbs from "./docs-breadcrumbs";
9-
import DocsPreviousNextLinks from "./docs-previous-next-link";
109
import OnThisPageNav from "./on-this-page-nav";
1110
import DocsNav from "@/components/docs-nav";
11+
import Recommendations from "@/components/docs-recommendations";
1212
import Link from "@/components/link";
1313
import Seo from "@/components/seo";
1414
import "rehype-callouts/theme/vitepress";
@@ -36,6 +36,7 @@ export default function DocumentPage({
3636
children,
3737
docsNavData: routes,
3838
source: { frontmatter, scope },
39+
id,
3940
}) {
4041
const flatRoutes = flattenRoutes(routes);
4142
const {
@@ -57,8 +58,8 @@ export default function DocumentPage({
5758
className="sticky top-[84px] z-5 border-b-[1px] border-gray-800 bg-gray-900/80 backdrop-blur-xs md:hidden"
5859
>
5960
<DisclosureButton className="group flex items-center rounded-md px-2 py-1.5 text-white/70 hover:text-white">
60-
<ChevronDownIcon className="relative z-20 hidden h-4 w-4 group-data-open:inline" />
61-
<ChevronRightIcon className="inline h-4 w-4 group-data-open:hidden" />
61+
<HiOutlineChevronDown className="relative z-20 hidden h-4 w-4 group-data-open:inline" />
62+
<HiOutlineChevronRight className="inline h-4 w-4 group-data-open:hidden" />
6263
<span className="pl-1">Menu</span>
6364
</DisclosureButton>
6465
<DisclosurePanel as="nav" className="hidden data-open:block">
@@ -93,17 +94,32 @@ export default function DocumentPage({
9394
Edit this doc on GitHub
9495
</Link>
9596
</nav>
96-
<article
97-
id="docs-article"
98-
className="container-main xs:py-20 prose prose-invert min-h-[calc(100vh-120px)] max-w-full py-0 sm:max-w-[80ch] sm:py-20 md:py-8"
99-
>
100-
<DocsBreadcrumbs routes={flatRoutes} />
101-
{frontmatter?.title && (
102-
<h1 className="article-title break-words">{frontmatter.title}</h1>
103-
)}
104-
{children}
105-
<DocsPreviousNextLinks routes={flatRoutes} />
106-
</article>
97+
<div className="container-main xs:py-20 min-h-[calc(100vh-120px)] max-w-full py-0 sm:max-w-[80ch] sm:py-20 md:py-8">
98+
<DocsBreadcrumbs
99+
routes={flatRoutes}
100+
className="mt-4 mb-7 md:mt-2 md:mb-10"
101+
/>
102+
<article id="docs-article" className="prose prose-invert">
103+
{frontmatter?.title && (
104+
<h1 className="article-title break-words">{frontmatter.title}</h1>
105+
)}
106+
{children}
107+
</article>
108+
109+
{
110+
// This only puts recommendations on content pages and not on the main docs index or category pages
111+
slug.length > 1 && (
112+
<>
113+
<hr className="my-16 border-t border-gray-700" />
114+
<Recommendations
115+
// Passing in key is important to force re-render when routing between docs, otherwise the recommendations may not update
116+
key={id}
117+
docID={id}
118+
/>
119+
</>
120+
)
121+
}
122+
</div>
107123
</main>
108124
</>
109125
);

0 commit comments

Comments
 (0)