diff --git a/apps/docs/app/docs/[[...slug]]/page.tsx b/apps/docs/app/docs/[[...slug]]/page.tsx index b346c67153..0c37cbbb74 100644 --- a/apps/docs/app/docs/[[...slug]]/page.tsx +++ b/apps/docs/app/docs/[[...slug]]/page.tsx @@ -83,6 +83,7 @@ export default async function DocPage({params}: DocPageProps) { if (!doc) { notFound(); } + const editUrl = `${GITHUB_URL}/${REPO_NAME}/edit/${TAG}${CONTENT_PATH}${currentRoute?.path}`; return ( diff --git a/apps/docs/app/providers.tsx b/apps/docs/app/providers.tsx index 6f860a7780..883e376b94 100644 --- a/apps/docs/app/providers.tsx +++ b/apps/docs/app/providers.tsx @@ -18,26 +18,27 @@ export interface ProvidersProps { themeProps?: ThemeProviderProps; } -export function Providers({children, themeProps}: ProvidersProps) { - const router = useRouter(); - - const ProviderWrapper = ({children}: {children: ReactNode}) => { - useEffect(() => { - if (typeof window !== "undefined" && __PROD__) { - posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { - api_host: "/ingest", - person_profiles: "identified_only", - ui_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, - }); - } - }, []); - - if (__PROD__) { - return {children}; +const ProviderWrapper = ({children}: {children: ReactNode}) => { + useEffect(() => { + // Initialize PostHog only once when the app starts + if (typeof window !== "undefined" && __PROD__ && !posthog.isFeatureEnabled("capture")) { + posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { + api_host: "/ingest", + person_profiles: "identified_only", + ui_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, + }); } + }, []); + + if (__PROD__) { + return {children}; + } - return children; - }; + return children; +}; + +export function Providers({children, themeProps}: ProvidersProps) { + const router = useRouter(); return ( diff --git a/apps/docs/components/navbar.tsx b/apps/docs/components/navbar.tsx index bd8f9f52ac..9b8dd7f493 100644 --- a/apps/docs/components/navbar.tsx +++ b/apps/docs/components/navbar.tsx @@ -1,6 +1,6 @@ "use client"; -import {useRef, useState, FC, ReactNode, Key} from "react"; +import {useRef, useState, FC, ReactNode, Key, useMemo, useCallback} from "react"; import { link, Navbar as NextUINavbar, @@ -94,6 +94,31 @@ export const Navbar: FC = ({children, routes, mobileRoutes = [], sl "/docs/guide/upgrade-to-v2", ]; + const navLinkClasses = clsx( + link({color: "foreground"}), + "data-[active=true]:text-primary data-[active=true]:font-semibold", + ); + + const handleVersionChange = useCallback((key: Key) => { + if (key === "v1") { + const newWindow = window.open("https://v1.nextui.org", "_blank", "noopener,noreferrer"); + + if (newWindow) newWindow.opener = null; + } + }, []); + + const handlePressNavbarItem = useCallback( + (name: string, url: string) => { + posthog.capture("NavbarItem", { + name, + action: "press", + category: "navbar", + data: url, + }); + }, + [posthog], + ); + const searchButton = ( ); + const versionDropdown = useMemo(() => { + return ref.current ? ( + + + {isMounted && ( + + + + + + )} + + + v{currentVersion} + }> + v1.0.0 + + + + ) : ( +
+ ); + }, [ref.current, isMounted]); + if (pathname.includes("/examples")) { return null; } - const navLinkClasses = clsx( - link({color: "foreground"}), - "data-[active=true]:text-primary data-[active=true]:font-semibold", - ); - - const handleVersionChange = (key: Key) => { - if (key === "v1") { - const newWindow = window.open("https://v1.nextui.org", "_blank", "noopener,noreferrer"); - - if (newWindow) newWindow.opener = null; - } - }; - - const handlePressNavbarItem = (name: string, url: string) => { - posthog.capture("NavbarItem", { - name, - action: "press", - category: "navbar", - data: url, - }); - }; - return ( = ({children, routes, mobileRoutes = [], sl - {ref.current ? ( - - - {isMounted && ( - - - - - - )} - - - v{currentVersion} - }> - v1.0.0 - - - - ) : ( -
- )} + {versionDropdown} =14'} + lilconfig@3.1.3: + resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} + engines: {node: '>=14'} + lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -12723,8 +12727,8 @@ packages: resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} engines: {node: ^10 || ^12 || >=14} - posthog-js@1.184.1: - resolution: {integrity: sha512-q/1Kdard5SZnL2smrzeKcD+RuUi2PnbidiN4D3ThK20bNrhy5Z2heIy9SnRMvEiARY5lcQ7zxmDCAKPBKGSOtQ==} + posthog-js@1.197.0: + resolution: {integrity: sha512-tvzx47x/vn/XoDTrZsn2f1WbswuwnesDmihdMpbTuxHapfNH4Jp7aV3XCs6hT0Qujo4MNG3nB/kap33FpWatDA==} posthtml-parser@0.11.0: resolution: {integrity: sha512-QecJtfLekJbWVo/dMAA+OSwY79wpRmbqS5TeXvXSX+f0c6pW4/SE6inzZ2qkU7oAMCPqIDkZDvd/bQsSFUnKyw==} @@ -13947,6 +13951,11 @@ packages: engines: {node: '>=14.0.0'} hasBin: true + tailwindcss@3.4.16: + resolution: {integrity: sha512-TI4Cyx7gDiZ6r44ewaJmt0o6BrMCT5aK5e0rmJ/G9Xq3w7CX/5VXl/zIPEJZFUK5VEqwByyhqNPycPlvcK4ZNw==} + engines: {node: '>=14.0.0'} + hasBin: true + tapable@1.1.3: resolution: {integrity: sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==} engines: {node: '>=6'} @@ -17145,10 +17154,10 @@ snapshots: - acorn - supports-color - '@mdx-js/react@3.1.0(@types/react@18.3.12)(react@18.2.0)': + '@mdx-js/react@3.1.0(@types/react@18.3.16)(react@18.2.0)': dependencies: '@types/mdx': 2.0.13 - '@types/react': 18.3.12 + '@types/react': 18.3.16 react: 18.2.0 '@mischnic/json-sourcemap@0.1.1': @@ -19179,9 +19188,9 @@ snapshots: storybook: 8.4.5(prettier@3.3.3) ts-dedent: 2.2.0 - '@storybook/addon-docs@8.4.5(@types/react@18.3.12)(storybook@8.4.5(prettier@3.3.3))': + '@storybook/addon-docs@8.4.5(@types/react@18.3.16)(storybook@8.4.5(prettier@3.3.3))': dependencies: - '@mdx-js/react': 3.1.0(@types/react@18.3.12)(react@18.2.0) + '@mdx-js/react': 3.1.0(@types/react@18.3.16)(react@18.2.0) '@storybook/blocks': 8.4.5(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(storybook@8.4.5(prettier@3.3.3)) '@storybook/csf-plugin': 8.4.5(storybook@8.4.5(prettier@3.3.3)) '@storybook/react-dom-shim': 8.4.5(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(storybook@8.4.5(prettier@3.3.3)) @@ -19192,12 +19201,12 @@ snapshots: transitivePeerDependencies: - '@types/react' - '@storybook/addon-essentials@8.4.5(@types/react@18.3.12)(storybook@8.4.5(prettier@3.3.3))': + '@storybook/addon-essentials@8.4.5(@types/react@18.3.16)(storybook@8.4.5(prettier@3.3.3))': dependencies: '@storybook/addon-actions': 8.4.5(storybook@8.4.5(prettier@3.3.3)) '@storybook/addon-backgrounds': 8.4.5(storybook@8.4.5(prettier@3.3.3)) '@storybook/addon-controls': 8.4.5(storybook@8.4.5(prettier@3.3.3)) - '@storybook/addon-docs': 8.4.5(@types/react@18.3.12)(storybook@8.4.5(prettier@3.3.3)) + '@storybook/addon-docs': 8.4.5(@types/react@18.3.16)(storybook@8.4.5(prettier@3.3.3)) '@storybook/addon-highlight': 8.4.5(storybook@8.4.5(prettier@3.3.3)) '@storybook/addon-measure': 8.4.5(storybook@8.4.5(prettier@3.3.3)) '@storybook/addon-outline': 8.4.5(storybook@8.4.5(prettier@3.3.3)) @@ -19778,7 +19787,7 @@ snapshots: '@types/scheduler': 0.23.0 csstype: 3.1.3 - '@types/react@18.3.12': + '@types/react@18.3.16': dependencies: '@types/prop-types': 15.7.13 csstype: 3.1.3 @@ -24402,6 +24411,8 @@ snapshots: lilconfig@3.1.2: {} + lilconfig@3.1.3: {} + lines-and-columns@1.2.4: {} lint-staged@13.3.0(enquirer@2.4.1): @@ -26217,7 +26228,7 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - posthog-js@1.184.1: + posthog-js@1.197.0: dependencies: core-js: 3.39.0 fflate: 0.4.8 @@ -27728,6 +27739,11 @@ snapshots: tailwind-merge: 1.14.0 tailwindcss: 3.4.15(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@15.14.9)(typescript@4.9.5)) + tailwind-variants@0.1.20(tailwindcss@3.4.16(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@15.14.9)(typescript@4.9.5))): + dependencies: + tailwind-merge: 1.14.0 + tailwindcss: 3.4.16(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@15.14.9)(typescript@4.9.5)) + tailwindcss@3.4.14(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@20.2.5)(typescript@5.6.3)): dependencies: '@alloc/quick-lru': 5.2.0 @@ -27809,6 +27825,33 @@ snapshots: transitivePeerDependencies: - ts-node + tailwindcss@3.4.16(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@15.14.9)(typescript@4.9.5)): + dependencies: + '@alloc/quick-lru': 5.2.0 + arg: 5.0.2 + chokidar: 3.6.0 + didyoumean: 1.2.2 + dlv: 1.1.3 + fast-glob: 3.3.2 + glob-parent: 6.0.2 + is-glob: 4.0.3 + jiti: 1.21.6 + lilconfig: 3.1.3 + micromatch: 4.0.8 + normalize-path: 3.0.0 + object-hash: 3.0.0 + picocolors: 1.1.1 + postcss: 8.4.49 + postcss-import: 15.1.0(postcss@8.4.49) + postcss-js: 4.0.1(postcss@8.4.49) + postcss-load-config: 4.0.2(postcss@8.4.49)(ts-node@10.9.2(@swc/core@1.9.2(@swc/helpers@0.5.15))(@types/node@15.14.9)(typescript@4.9.5)) + postcss-nested: 6.2.0(postcss@8.4.49) + postcss-selector-parser: 6.1.2 + resolve: 1.22.8 + sucrase: 3.35.0 + transitivePeerDependencies: + - ts-node + tapable@1.1.3: {} tapable@2.2.1: {}