feature(public,docs): new public website and docs

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-11-13 21:15:46 +01:00
parent fc2a019e1d
commit a022cb4831
234 changed files with 9341 additions and 6154 deletions

View File

@@ -0,0 +1,37 @@
import { useEffect, useState } from 'react';
export function useIsDarkMode() {
const [isDarkMode, setIsDarkMode] = useState(() => {
if (typeof window === 'undefined') return false;
// Check localStorage first
const savedTheme = window.localStorage.getItem('theme');
if (savedTheme !== null) {
return savedTheme === 'dark';
}
// Fall back to system preference
return window.matchMedia('(prefers-color-scheme: dark)').matches;
});
useEffect(() => {
// Check if user prefers dark mode
const htmlElement = document.documentElement;
setIsDarkMode(htmlElement.classList.contains('dark'));
// Create observer to watch for class changes
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.attributeName === 'class') {
setIsDarkMode(htmlElement.classList.contains('dark'));
}
});
});
// Start observing class changes on html element
observer.observe(htmlElement, { attributes: true });
return () => observer.disconnect();
}, []);
return isDarkMode;
}

View File

@@ -0,0 +1,6 @@
export async function getGithubRepoInfo() {
const res = await fetch(
'https://api.github.com/repos/Openpanel-dev/openpanel',
);
return res.json();
}

25
apps/public/lib/source.ts Normal file
View File

@@ -0,0 +1,25 @@
import {
articleCollection,
articleMeta,
docs,
meta,
pageCollection,
pageMeta,
} from '@/.source';
import { loader } from 'fumadocs-core/source';
import { createMDXSource } from 'fumadocs-mdx';
export const source = loader({
baseUrl: '/docs',
source: createMDXSource(docs, meta),
});
export const articleSource = loader({
baseUrl: '/articles',
source: createMDXSource(articleCollection, articleMeta),
});
export const pageSource = loader({
baseUrl: '/',
source: createMDXSource(pageCollection, pageMeta),
});

6
apps/public/lib/utils.ts Normal file
View File

@@ -0,0 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}