@next-library/theme 1.0.1 → 1.0.3

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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) FAKGROUP 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import { type Locale } from '@next-library/core';
2
+ import { type Locale, type ContentTree } from '@next-library/core';
3
3
  export interface DocumentationLayoutProps {
4
4
  children: React.ReactNode;
5
5
  language?: Locale;
6
6
  bannerMessage?: React.ReactNode | null;
7
7
  websiteTitle?: string | undefined;
8
+ contentTree?: ContentTree;
9
+ repoUrl?: string;
8
10
  }
9
11
  export declare function DocumentationLayout(props: DocumentationLayoutProps): import("react/jsx-runtime").JSX.Element;
10
12
  //# sourceMappingURL=documentation-layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentation-layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/documentation-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAsClE"}
1
+ {"version":3,"file":"documentation-layout.d.ts","sourceRoot":"","sources":["../../../src/components/layout/documentation-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CAmClE"}
@@ -1,11 +1,13 @@
1
- import { type Locale } from '@next-library/core';
1
+ import { type Locale, type ContentTree } from '@next-library/core';
2
2
  import type { PageData } from '@next-library/core';
3
3
  interface NavigationBarProps {
4
4
  language?: Locale;
5
5
  className?: string;
6
6
  pageData?: PageData;
7
7
  websiteTitle?: string;
8
+ contentTree?: ContentTree;
9
+ repoUrl?: string;
8
10
  }
9
- export declare function NavigationBar({ language, className, pageData, websiteTitle }: NavigationBarProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function NavigationBar({ language, className, pageData, websiteTitle, contentTree, repoUrl: repoUrlProp }: NavigationBarProps): import("react/jsx-runtime").JSX.Element;
10
12
  export {};
11
13
  //# sourceMappingURL=navigation-bar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigation-bar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/navigation-bar.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAmF,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClI,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAe,EACf,SAAc,EACd,QAAQ,EACR,YAAY,EACb,EAAE,kBAAkB,2CA+DpB"}
1
+ {"version":3,"file":"navigation-bar.d.ts","sourceRoot":"","sources":["../../../src/components/layout/navigation-bar.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAwE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzI,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAe,EACf,SAAc,EACd,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,OAAO,EAAE,WAAW,EACrB,EAAE,kBAAkB,2CAuDpB"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@
7
7
  */
8
8
  export * from './server';
9
9
  export * from './client';
10
- export { extractPageData, loadContentTree, getLocaleFromParams, extractLocaleFromPathname, type Locale, type PageData, } from '@next-library/core';
10
+ export { extractPageData, getLocaleFromParams, extractLocaleFromPathname, type Locale, type PageData, } from '@next-library/core';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,MAAM,EACX,KAAK,QAAQ,GACd,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,MAAM,EACX,KAAK,QAAQ,GACd,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as React8 from 'react';
2
2
  import React8__default, { Suspense, useState, useRef, useEffect, useCallback } from 'react';
3
3
  import { Logo, TopCategories, SearchBar, GithubLink, ThemeSwitcher, LanguageSwitcher, MobileMenu, GithubStar, Banner, CookieBanner, SidebarNavigation, GithubContributors, TableOfContents, CopyPageButton } from '@next-library/theme/client';
4
- import { getTopCategories, getDirection, getSupportedLocales, getLocaleConfig, getConfig } from '@next-library/core';
5
- export { extractLocaleFromPathname, extractPageData, getLocaleFromParams, loadContentTree } from '@next-library/core';
4
+ import { getDirection, getTopCategories, getSupportedLocales, getLocaleConfig } from '@next-library/core';
5
+ export { extractLocaleFromPathname, extractPageData, getLocaleFromParams } from '@next-library/core';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import Link2 from 'next/link';
8
8
  import Image from 'next/image';
@@ -40,30 +40,23 @@ function NavigationBar({
40
40
  language = "en",
41
41
  className = "",
42
42
  pageData,
43
- websiteTitle
43
+ websiteTitle,
44
+ contentTree,
45
+ repoUrl: repoUrlProp
44
46
  }) {
45
- const categories = getTopCategories(language);
46
47
  const direction = getDirection(language);
47
- const availableLocales = typeof window === "undefined" ? getSupportedLocales() : [];
48
+ const categories = contentTree ? getTopCategories(contentTree, language) : [];
49
+ const availableLocales = typeof window === "undefined" && contentTree ? getSupportedLocales(contentTree) : [];
48
50
  const localeConfigs = typeof window === "undefined" ? availableLocales.map((locale) => ({
49
51
  code: locale,
50
52
  nativeName: getLocaleConfig(locale)?.nativeName || locale.toUpperCase()
51
53
  })) : void 0;
52
- let repoUrl;
53
- if (typeof window === "undefined") {
54
- try {
55
- const config = getConfig();
56
- if (config?.github?.user && config?.github?.repo) {
57
- repoUrl = `https://github.com/${config.github.user}/${config.github.repo}`;
58
- }
59
- } catch {
60
- }
61
- if (!repoUrl) {
62
- const githubUser = process.env.NEXT_PUBLIC_GITHUB_USER?.trim().replace(/^['"]|['"]$/g, "");
63
- const githubRepo = process.env.NEXT_PUBLIC_GITHUB_REPO?.trim().replace(/^['"]|['"]$/g, "");
64
- if (githubUser && githubRepo) {
65
- repoUrl = `https://github.com/${githubUser}/${githubRepo}`;
66
- }
54
+ let repoUrl = repoUrlProp;
55
+ if (!repoUrl && typeof window === "undefined") {
56
+ const githubUser = process.env.NEXT_PUBLIC_GITHUB_USER?.trim().replace(/^['"]|['"]$/g, "");
57
+ const githubRepo = process.env.NEXT_PUBLIC_GITHUB_REPO?.trim().replace(/^['"]|['"]$/g, "");
58
+ if (githubUser && githubRepo) {
59
+ repoUrl = `https://github.com/${githubUser}/${githubRepo}`;
67
60
  }
68
61
  }
69
62
  return /* @__PURE__ */ jsx(
@@ -123,23 +116,24 @@ function DocumentationLayout(props) {
123
116
  children,
124
117
  language = "en",
125
118
  bannerMessage = null,
126
- websiteTitle = void 0
119
+ websiteTitle,
120
+ contentTree,
121
+ repoUrl
127
122
  } = props;
128
123
  const direction = getDirection(language);
129
- let title = websiteTitle;
130
- if (!title && typeof window === "undefined") {
131
- try {
132
- const config = getConfig();
133
- title = config?.website?.title;
134
- } catch {
135
- }
136
- }
137
- if (!title && typeof window === "undefined") {
138
- title = process.env.NEXT_PUBLIC_WEBSITE_TITLE?.trim().replace(/^['"]|['"]$/g, "");
139
- }
124
+ const title = websiteTitle || (typeof window === "undefined" ? process.env.NEXT_PUBLIC_WEBSITE_TITLE?.trim().replace(/^['"]|['"]$/g, "") : void 0);
140
125
  return /* @__PURE__ */ jsxs("div", { className: "bg-background flex flex-col", dir: direction, children: [
141
126
  bannerMessage && /* @__PURE__ */ jsx(Banner, { language, children: bannerMessage }),
142
- /* @__PURE__ */ jsx(NavigationBar, { language, className: "hidden lg:block", websiteTitle: title }),
127
+ /* @__PURE__ */ jsx(
128
+ NavigationBar,
129
+ {
130
+ language,
131
+ className: "hidden lg:block",
132
+ websiteTitle: title,
133
+ contentTree,
134
+ repoUrl
135
+ }
136
+ ),
143
137
  children,
144
138
  /* @__PURE__ */ jsx(DocumentationFooter, {}),
145
139
  /* @__PURE__ */ jsx(CookieBanner, { locale: language })