Skip to content

Commit 7d11130

Browse files
authored
Serp tweak (#25093)
* temp search * styling tweaks
1 parent 06960e2 commit 7d11130

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/search/InstantSearch.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
FloatingPortal,
2222
} from "@floating-ui/react";
2323
import { PiCaretDownBold } from "react-icons/pi";
24+
import { subDays } from "date-fns";
2425
import { setSearchParams } from "~/util/url";
2526
import he from "he";
2627

@@ -73,6 +74,13 @@ function InfiniteHits(props: UseInfiniteHitsProps) {
7374
.map(([, value]) => value);
7475

7576
const title = hierarchy ? hierarchy.join(" > ") : "Documentation";
77+
const today = new Date();
78+
const futureDate = subDays(today, item.lastModified);
79+
const options: Intl.DateTimeFormatOptions = {
80+
year: "numeric",
81+
month: "long",
82+
day: "numeric",
83+
};
7684

7785
return (
7886
<a
@@ -84,6 +92,11 @@ function InfiniteHits(props: UseInfiniteHitsProps) {
8492
<p className="line-clamp-2">
8593
<Highlight attribute="content" hit={item} />
8694
</p>
95+
{item.lastModified && (
96+
<span className="text-cl1-gray-4! dark:text-cl1-gray-7! mt-2 text-sm">
97+
{futureDate.toLocaleDateString("en-US", options)}
98+
</span>
99+
)}
87100
</a>
88101
);
89102
})}

0 commit comments

Comments
 (0)