diff --git a/app/course/[[...slug]]/page.tsx b/app/course/[[...slug]]/page.tsx
index 28091610..6e2ea9c9 100644
--- a/app/course/[[...slug]]/page.tsx
+++ b/app/course/[[...slug]]/page.tsx
@@ -5,6 +5,7 @@ import { DocsPage, DocsBody } from 'fumadocs-ui/page';
import { notFound } from 'next/navigation';
import { utils, type Page } from '@/utils/source';
import { createMetadata } from '@/utils/metadata';
+import IndexedDBComponent from '../../tracker'
interface Param {
slug: string[];
@@ -89,6 +90,7 @@ export default function Page({
{page.data.description}
+
{page.data.index ? (
) : (
diff --git a/app/source.ts b/app/source.ts
deleted file mode 100644
index cd0bade7..00000000
--- a/app/source.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { createMDXSource, defaultSchemas } from 'fumadocs-mdx';
-import { z } from 'zod';
-import { loader } from 'fumadocs-core/source';
-import { icons } from 'lucide-react';
-import { map } from '.map';
-import { create } from '@/components/ui/icon';
-
-export const { getPage, getPages, pageTree } = loader({
- baseUrl: '/course',
- rootDir: 'course',
- icon(icon) {
- if (icon && icon in icons)
- return create({ icon: icons[icon as keyof typeof icons] });
- },
- source: createMDXSource(map, {
- schema: {
- frontmatter: defaultSchemas.frontmatter.extend({
- preview: z.string().optional(),
- toc: z.boolean().default(true),
- index: z.boolean().default(false),
- updated: z.string().or(z.date()).transform((value, context) => {
- try {
- return new Date(value);
- } catch {
- context.addIssue({ code: z.ZodIssueCode.custom, message: "Invalid date" });
- return z.NEVER;
- }
- }),
- authors: z.array(z.string()),
- }),
- },
- }),
-});
diff --git a/app/tracker.tsx b/app/tracker.tsx
new file mode 100644
index 00000000..9c70ccbb
--- /dev/null
+++ b/app/tracker.tsx
@@ -0,0 +1,74 @@
+'use client';
+import { useEffect } from 'react';
+import { usePathname } from 'next/navigation';
+
+const IndexedDBComponent: React.FC = () => {
+ const currentPath = usePathname();
+
+ useEffect(() => {
+ const request = indexedDB.open("PathDatabase", 1);
+
+ request.onerror = function (event: any) {
+ console.error("Database error:", event.target.errorCode);
+ };
+
+ request.onupgradeneeded = function (event: any) {
+ const db = event.target.result as IDBDatabase;
+ const objectStore = db.createObjectStore("paths", { keyPath: "id", autoIncrement: true });
+ objectStore.createIndex("path", "path", { unique: false });
+ };
+
+ request.onsuccess = function (event: any) {
+ const db = event.target.result as IDBDatabase;
+ const transaction = db.transaction(["paths"], "readwrite");
+ const objectStore = transaction.objectStore("paths");
+ const index = objectStore.index("path");
+
+ const getRequest = index.get(currentPath);
+
+ getRequest.onsuccess = function (event: any) {
+ if (event.target.result) {
+ console.log("Path already exists in Academy DB:", currentPath);
+ } else {
+ const addRequest = objectStore.add({ path: currentPath });
+
+ addRequest.onsuccess = function () {
+ console.log("Path has been added to Academy DB:", currentPath);
+ };
+
+ addRequest.onerror = function (event: any) {
+ console.error("Error adding path:", event.target.errorCode);
+ };
+ }
+ };
+
+ getRequest.onerror = function (event: any) {
+ console.error("Error checking path:", event.target.errorCode);
+ };
+
+ const getAllRequest = objectStore.getAll();
+
+ getAllRequest.onsuccess = function (event: any) {
+ const paths = event.target.result as { path: string }[];
+ paths.forEach(item => {
+ const sidebarItem = document.querySelector(`a[href="${item.path}"]`);
+ if (sidebarItem) {
+ const iconContainer = sidebarItem.querySelector('div');
+ if (iconContainer) {
+ iconContainer.innerHTML = '';
+ }
+ }
+ });
+ };
+
+ getAllRequest.onerror = function (event: any) {
+ console.error("Error retrieving all paths:", event.target.errorCode);
+ };
+ };
+ }, [currentPath]);
+
+ return null;
+};
+
+export default IndexedDBComponent;
+