@next-library/theme 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +0 -2
- package/dist/client.js.map +1 -1
- package/dist/components/layout/documentation-layout.d.ts +12 -0
- package/dist/components/layout/documentation-layout.d.ts.map +1 -0
- package/dist/components/layout/footer.d.ts +14 -0
- package/dist/components/layout/footer.d.ts.map +1 -0
- package/dist/components/layout/left-sidebar.d.ts +8 -0
- package/dist/components/layout/left-sidebar.d.ts.map +1 -0
- package/dist/components/layout/navigation-bar.d.ts +13 -0
- package/dist/components/layout/navigation-bar.d.ts.map +1 -0
- package/dist/components/layout/right-sidebar.d.ts +8 -0
- package/dist/components/layout/right-sidebar.d.ts.map +1 -0
- package/dist/components/layout/utils.d.ts +3 -0
- package/dist/components/layout/utils.d.ts.map +1 -0
- package/dist/components/markdown/copy-page-button.d.ts +22 -0
- package/dist/components/markdown/copy-page-button.d.ts.map +1 -0
- package/dist/components/markdown/fallback-locale-warning.d.ts +16 -0
- package/dist/components/markdown/fallback-locale-warning.d.ts.map +1 -0
- package/dist/components/markdown/markdown-renderer.d.ts +7 -0
- package/dist/components/markdown/markdown-renderer.d.ts.map +1 -0
- package/dist/components/markdown/page-header.d.ts +18 -0
- package/dist/components/markdown/page-header.d.ts.map +1 -0
- package/dist/components/navigation/main/breadcrumbs.d.ts +9 -0
- package/dist/components/navigation/main/breadcrumbs.d.ts.map +1 -0
- package/dist/components/navigation/main/folder-cards.d.ts +7 -0
- package/dist/components/navigation/main/folder-cards.d.ts.map +1 -0
- package/dist/components/navigation/navbar/banner.d.ts +9 -0
- package/dist/components/navigation/navbar/banner.d.ts.map +1 -0
- package/dist/components/navigation/navbar/github-link.d.ts +8 -0
- package/dist/components/navigation/navbar/github-link.d.ts.map +1 -0
- package/dist/components/navigation/navbar/github-star.d.ts +6 -0
- package/dist/components/navigation/navbar/github-star.d.ts.map +1 -0
- package/dist/components/navigation/navbar/language-switcher.d.ts +12 -0
- package/dist/components/navigation/navbar/language-switcher.d.ts.map +1 -0
- package/dist/components/navigation/navbar/logo.d.ts +9 -0
- package/dist/components/navigation/navbar/logo.d.ts.map +1 -0
- package/dist/components/navigation/navbar/mobile-menu.d.ts +12 -0
- package/dist/components/navigation/navbar/mobile-menu.d.ts.map +1 -0
- package/dist/components/navigation/navbar/search-bar.d.ts +8 -0
- package/dist/components/navigation/navbar/search-bar.d.ts.map +1 -0
- package/dist/components/navigation/navbar/theme-switcher.d.ts +2 -0
- package/dist/components/navigation/navbar/theme-switcher.d.ts.map +1 -0
- package/dist/components/navigation/navbar/top-categories.d.ts +12 -0
- package/dist/components/navigation/navbar/top-categories.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-left/level-elevator.d.ts +7 -0
- package/dist/components/navigation/sidebar-left/level-elevator.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-left/parent.d.ts +9 -0
- package/dist/components/navigation/sidebar-left/parent.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-left/sidebar.d.ts +13 -0
- package/dist/components/navigation/sidebar-left/sidebar.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-left/toolbox.d.ts +23 -0
- package/dist/components/navigation/sidebar-left/toolbox.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-right/github-contributors.d.ts +19 -0
- package/dist/components/navigation/sidebar-right/github-contributors.d.ts.map +1 -0
- package/dist/components/navigation/sidebar-right/table-of-contents.d.ts +12 -0
- package/dist/components/navigation/sidebar-right/table-of-contents.d.ts.map +1 -0
- package/dist/components/seo/structured-data.d.ts +10 -0
- package/dist/components/seo/structured-data.d.ts.map +1 -0
- package/dist/components/tracking/cookie-banner.d.ts +17 -0
- package/dist/components/tracking/cookie-banner.d.ts.map +1 -0
- package/dist/components/ui/anchor-link-handler.d.ts +7 -0
- package/dist/components/ui/anchor-link-handler.d.ts.map +1 -0
- package/dist/components/ui/avatar.d.ts +7 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb-toggle.d.ts +11 -0
- package/dist/components/ui/breadcrumb-toggle.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/collapsible.d.ts +7 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/drawer.d.ts +14 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/sheet.d.ts +14 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sidebar.d.ts +70 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/skeleton.d.ts +4 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/sticky-banner.d.ts +12 -0
- package/dist/components/ui/sticky-banner.d.ts.map +1 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -35
- package/dist/index.js.map +1 -1
- package/dist/lib/translations/hooks.d.ts +14 -0
- package/dist/lib/translations/hooks.d.ts.map +1 -0
- package/dist/lib/translations/index.d.ts +55 -0
- package/dist/lib/translations/index.d.ts.map +1 -0
- package/dist/lib/translations/locale-names.d.ts +10 -0
- package/dist/lib/translations/locale-names.d.ts.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +26 -32
- package/dist/server.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hooks for accessing translations
|
|
3
|
+
*/
|
|
4
|
+
import type { Locale } from '@next-library/core';
|
|
5
|
+
import { type ThemeTranslations } from './index';
|
|
6
|
+
/**
|
|
7
|
+
* Hook to get all translations for the current locale
|
|
8
|
+
*/
|
|
9
|
+
export declare function useTranslations(locale?: Locale): ThemeTranslations;
|
|
10
|
+
/**
|
|
11
|
+
* Hook to get a specific translation for the current locale
|
|
12
|
+
*/
|
|
13
|
+
export declare function useTranslation(locale?: Locale): (key: keyof ThemeTranslations) => string | undefined;
|
|
14
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/lib/translations/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAElE;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,MAAa,GAAG,iBAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,GAAE,MAAa,SAIpC,MAAM,iBAAiB,wBAGtC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translation system for theme components
|
|
3
|
+
*
|
|
4
|
+
* This module provides translations for all user-facing text in theme components.
|
|
5
|
+
* Components can use these translations based on the locale prop.
|
|
6
|
+
*/
|
|
7
|
+
import type { Locale } from '@next-library/core';
|
|
8
|
+
/**
|
|
9
|
+
* Translation keys for all theme components
|
|
10
|
+
*/
|
|
11
|
+
export interface ThemeTranslations {
|
|
12
|
+
copyPage: string;
|
|
13
|
+
copied: string;
|
|
14
|
+
openInChatGPT: string;
|
|
15
|
+
openInClaude: string;
|
|
16
|
+
askAboutThisPage: string;
|
|
17
|
+
copyPageDescription: string;
|
|
18
|
+
askQuestionsDescription: string;
|
|
19
|
+
chatGPTPrefix: string;
|
|
20
|
+
tableOfContents: string;
|
|
21
|
+
contributors: string;
|
|
22
|
+
goToDocsHome: string;
|
|
23
|
+
goBackTo: string;
|
|
24
|
+
goToPreviousPage: string;
|
|
25
|
+
goToNextPage: string;
|
|
26
|
+
noPreviousPage: string;
|
|
27
|
+
noNextPage: string;
|
|
28
|
+
cookieConsent: string;
|
|
29
|
+
cookieDescription: string;
|
|
30
|
+
cookieLearnMore: string;
|
|
31
|
+
accept: string;
|
|
32
|
+
decline: string;
|
|
33
|
+
goToHomePage: string;
|
|
34
|
+
home: string;
|
|
35
|
+
linkCopied: string;
|
|
36
|
+
copyLinkToSection: string;
|
|
37
|
+
search: string;
|
|
38
|
+
searchPlaceholder: string;
|
|
39
|
+
closeBanner: string;
|
|
40
|
+
fallbackLocaleWarning?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get translations for a specific locale
|
|
44
|
+
* Falls back to English if locale is not found
|
|
45
|
+
*/
|
|
46
|
+
export declare function getTranslations(locale?: Locale): ThemeTranslations;
|
|
47
|
+
/**
|
|
48
|
+
* Get a specific translation key for a locale
|
|
49
|
+
*/
|
|
50
|
+
export declare function getTranslation(locale: Locale, key: keyof ThemeTranslations): string;
|
|
51
|
+
/**
|
|
52
|
+
* Type-safe translation key helper
|
|
53
|
+
*/
|
|
54
|
+
export type TranslationKey = keyof ThemeTranslations;
|
|
55
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BAAiB,CAExE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,iBAAiB,GAC3B,MAAM,CAGR;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale name translations
|
|
3
|
+
* Maps locale codes to their names in different languages
|
|
4
|
+
*/
|
|
5
|
+
import type { Locale } from '@next-library/core';
|
|
6
|
+
/**
|
|
7
|
+
* Get the name of a locale in a specific target language
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLocaleNameInLanguage(locale: Locale, targetLanguage: Locale): string;
|
|
10
|
+
//# sourceMappingURL=locale-names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale-names.d.ts","sourceRoot":"","sources":["../../../src/lib/translations/locale-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAoiBjD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAGtF"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Components Export
|
|
3
|
+
*
|
|
4
|
+
* This file exports all server components that can be used in Next.js server components.
|
|
5
|
+
* Import from '@next-library/theme/server' to use server components.
|
|
6
|
+
*/
|
|
7
|
+
export { DocumentationLayout, type DocumentationLayoutProps } from './components/layout/documentation-layout';
|
|
8
|
+
export { NavigationBar } from './components/layout/navigation-bar';
|
|
9
|
+
export { LeftSidebar } from './components/layout/left-sidebar';
|
|
10
|
+
export { RightSidebar } from './components/layout/right-sidebar';
|
|
11
|
+
export { DocumentationFooter } from './components/layout/footer';
|
|
12
|
+
export { PageHeader } from './components/markdown/page-header';
|
|
13
|
+
export { FallbackLocaleWarning } from './components/markdown/fallback-locale-warning';
|
|
14
|
+
export { StructuredData } from './components/seo/structured-data';
|
|
15
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,mBAAmB,EAAE,KAAK,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AAC9G,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAMjE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAGtF,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React2, { Suspense } from 'react';
|
|
2
2
|
import { Logo, TopCategories, SearchBar, GithubLink, ThemeSwitcher, LanguageSwitcher, MobileMenu, GithubStar, Banner, CookieBanner, SidebarNavigation, GithubContributors, TableOfContents, CopyPageButton } from '@next-library/theme/client';
|
|
3
|
-
import {
|
|
3
|
+
import { getDirection, getTopCategories, getSupportedLocales, getLocaleConfig } from '@next-library/core';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import Link2 from 'next/link';
|
|
6
6
|
import Image from 'next/image';
|
|
@@ -13,30 +13,23 @@ function NavigationBar({
|
|
|
13
13
|
language = "en",
|
|
14
14
|
className = "",
|
|
15
15
|
pageData,
|
|
16
|
-
websiteTitle
|
|
16
|
+
websiteTitle,
|
|
17
|
+
contentTree,
|
|
18
|
+
repoUrl: repoUrlProp
|
|
17
19
|
}) {
|
|
18
|
-
const categories = getTopCategories(language);
|
|
19
20
|
const direction = getDirection(language);
|
|
20
|
-
const
|
|
21
|
+
const categories = contentTree ? getTopCategories(contentTree, language) : [];
|
|
22
|
+
const availableLocales = typeof window === "undefined" && contentTree ? getSupportedLocales(contentTree) : [];
|
|
21
23
|
const localeConfigs = typeof window === "undefined" ? availableLocales.map((locale) => ({
|
|
22
24
|
code: locale,
|
|
23
25
|
nativeName: getLocaleConfig(locale)?.nativeName || locale.toUpperCase()
|
|
24
26
|
})) : void 0;
|
|
25
|
-
let repoUrl;
|
|
26
|
-
if (typeof window === "undefined") {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
} catch {
|
|
33
|
-
}
|
|
34
|
-
if (!repoUrl) {
|
|
35
|
-
const githubUser = process.env.NEXT_PUBLIC_GITHUB_USER?.trim().replace(/^['"]|['"]$/g, "");
|
|
36
|
-
const githubRepo = process.env.NEXT_PUBLIC_GITHUB_REPO?.trim().replace(/^['"]|['"]$/g, "");
|
|
37
|
-
if (githubUser && githubRepo) {
|
|
38
|
-
repoUrl = `https://github.com/${githubUser}/${githubRepo}`;
|
|
39
|
-
}
|
|
27
|
+
let repoUrl = repoUrlProp;
|
|
28
|
+
if (!repoUrl && typeof window === "undefined") {
|
|
29
|
+
const githubUser = process.env.NEXT_PUBLIC_GITHUB_USER?.trim().replace(/^['"]|['"]$/g, "");
|
|
30
|
+
const githubRepo = process.env.NEXT_PUBLIC_GITHUB_REPO?.trim().replace(/^['"]|['"]$/g, "");
|
|
31
|
+
if (githubUser && githubRepo) {
|
|
32
|
+
repoUrl = `https://github.com/${githubUser}/${githubRepo}`;
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
35
|
return /* @__PURE__ */ jsx(
|
|
@@ -96,23 +89,24 @@ function DocumentationLayout(props) {
|
|
|
96
89
|
children,
|
|
97
90
|
language = "en",
|
|
98
91
|
bannerMessage = null,
|
|
99
|
-
websiteTitle
|
|
92
|
+
websiteTitle,
|
|
93
|
+
contentTree,
|
|
94
|
+
repoUrl
|
|
100
95
|
} = props;
|
|
101
96
|
const direction = getDirection(language);
|
|
102
|
-
|
|
103
|
-
if (!title && typeof window === "undefined") {
|
|
104
|
-
try {
|
|
105
|
-
const config = getConfig();
|
|
106
|
-
title = config?.website?.title;
|
|
107
|
-
} catch {
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (!title && typeof window === "undefined") {
|
|
111
|
-
title = process.env.NEXT_PUBLIC_WEBSITE_TITLE?.trim().replace(/^['"]|['"]$/g, "");
|
|
112
|
-
}
|
|
97
|
+
const title = websiteTitle || (typeof window === "undefined" ? process.env.NEXT_PUBLIC_WEBSITE_TITLE?.trim().replace(/^['"]|['"]$/g, "") : void 0);
|
|
113
98
|
return /* @__PURE__ */ jsxs("div", { className: "bg-background flex flex-col", dir: direction, children: [
|
|
114
99
|
bannerMessage && /* @__PURE__ */ jsx(Banner, { language, children: bannerMessage }),
|
|
115
|
-
/* @__PURE__ */ jsx(
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
101
|
+
NavigationBar,
|
|
102
|
+
{
|
|
103
|
+
language,
|
|
104
|
+
className: "hidden lg:block",
|
|
105
|
+
websiteTitle: title,
|
|
106
|
+
contentTree,
|
|
107
|
+
repoUrl
|
|
108
|
+
}
|
|
109
|
+
),
|
|
116
110
|
children,
|
|
117
111
|
/* @__PURE__ */ jsx(DocumentationFooter, {}),
|
|
118
112
|
/* @__PURE__ */ jsx(CookieBanner, { locale: language })
|