@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 +22 -0
- package/dist/components/layout/documentation-layout.d.ts +3 -1
- package/dist/components/layout/documentation-layout.d.ts.map +1 -1
- package/dist/components/layout/navigation-bar.d.ts +4 -2
- package/dist/components/layout/navigation-bar.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -33
- package/dist/index.js.map +1 -1
- package/dist/server.js +26 -32
- package/dist/server.js.map +1 -1
- package/package.json +21 -15
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 })
|