Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow browsing and discover of knowlege base in the search page #1073

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/interface/obsidian/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -858,4 +858,4 @@ img.copy-icon {
100% {
transform: rotate(360deg);
}
}
}
30 changes: 30 additions & 0 deletions src/interface/web/app/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,33 @@ export function useDebounce<T>(value: T, delay: number): T {

return debouncedValue;
}

export const formatDateTime = (isoString: string): string => {
try {
const date = new Date(isoString);
const now = new Date();
const diffInMinutes = Math.floor((now.getTime() - date.getTime()) / 60000);

// Show relative time for recent dates
if (diffInMinutes < 1) return "just now";
if (diffInMinutes < 60) return `${diffInMinutes} minutes ago`;
if (diffInMinutes < 120) return "1 hour ago";
if (diffInMinutes < 1440) return `${Math.floor(diffInMinutes / 60)} hours ago`;

// For older dates, show full formatted date
const formatter = new Intl.DateTimeFormat("en-US", {
month: "long",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "2-digit",
hour12: true,
timeZoneName: "short",
});

return formatter.format(date);
} catch (error) {
console.error("Error formatting date:", error);
return isoString;
}
};
6 changes: 5 additions & 1 deletion src/interface/web/app/search/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata } from "next";

import "../globals.css";
import { ContentSecurityPolicy } from "../common/layoutHelper";
import { Toaster } from "@/components/ui/toaster";

export const metadata: Metadata = {
title: "Khoj AI - Search",
Expand Down Expand Up @@ -35,7 +36,10 @@ export default function RootLayout({
return (
<html>
<ContentSecurityPolicy />
<body>{children}</body>
<body>
{children}
<Toaster />
</body>
</html>
);
}
Loading
Loading