@netfoundry/docusaurus-theme 0.1.0
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/css/theme.css +15 -0
- package/package.json +45 -0
- package/src/index.ts +46 -0
- package/src/options.ts +95 -0
- package/theme/Layout/index.tsx +74 -0
package/css/theme.css
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NetFoundry Docusaurus Theme - Combined Styles
|
|
3
|
+
*
|
|
4
|
+
* This file is automatically loaded by the theme via getClientModules().
|
|
5
|
+
* It imports all necessary CSS from @netfoundry/docusaurus-shared.
|
|
6
|
+
*
|
|
7
|
+
* Consuming projects no longer need to manually add these imports
|
|
8
|
+
* to their custom.css files.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* Core theme CSS with variables and layout */
|
|
12
|
+
@import "@netfoundry/docusaurus-shared/index.css";
|
|
13
|
+
|
|
14
|
+
/* Legacy design system variables and comprehensive styling */
|
|
15
|
+
@import "@netfoundry/docusaurus-shared/css/legacy.css";
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@netfoundry/docusaurus-theme",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NetFoundry Docusaurus theme with shared layout, footer, and styling",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"types": "src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"theme",
|
|
10
|
+
"css"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "echo 'No build needed - theme uses source files directly'"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@docusaurus/core": "^3",
|
|
20
|
+
"@docusaurus/theme-classic": "^3",
|
|
21
|
+
"@docusaurus/theme-common": "^3",
|
|
22
|
+
"react": "^18 || ^19",
|
|
23
|
+
"react-dom": "^18 || ^19"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@netfoundry/docusaurus-shared": "^0.1.1",
|
|
27
|
+
"clsx": "^2.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@docusaurus/types": "^3",
|
|
31
|
+
"typescript": "^5"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/netfoundry/docusaurus-shared.git",
|
|
36
|
+
"directory": "lib/packages/docusaurus-theme"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"docusaurus",
|
|
40
|
+
"docusaurus-theme",
|
|
41
|
+
"netfoundry",
|
|
42
|
+
"openziti"
|
|
43
|
+
],
|
|
44
|
+
"license": "Apache-2.0"
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LoadContext, Plugin } from '@docusaurus/types';
|
|
2
|
+
import type { NetFoundryThemeOptions } from './options';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
export default function themeNetFoundry(
|
|
6
|
+
context: LoadContext,
|
|
7
|
+
options: NetFoundryThemeOptions = {}
|
|
8
|
+
): Plugin {
|
|
9
|
+
return {
|
|
10
|
+
name: '@netfoundry/docusaurus-theme',
|
|
11
|
+
|
|
12
|
+
// Register theme component overrides
|
|
13
|
+
getThemePath() {
|
|
14
|
+
return path.resolve(__dirname, '../theme');
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// For TypeScript development
|
|
18
|
+
getTypeScriptThemePath() {
|
|
19
|
+
return path.resolve(__dirname, '../theme');
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// Automatically inject CSS
|
|
23
|
+
getClientModules() {
|
|
24
|
+
const modules: string[] = [
|
|
25
|
+
require.resolve('../css/theme.css'),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Add custom CSS if specified in options
|
|
29
|
+
if (options.customCss) {
|
|
30
|
+
const customCssArray = Array.isArray(options.customCss)
|
|
31
|
+
? options.customCss
|
|
32
|
+
: [options.customCss];
|
|
33
|
+
modules.push(...customCssArray);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return modules;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Re-export types for consumers (types are safe to export at config time)
|
|
42
|
+
export type { NetFoundryThemeOptions, NetFoundryThemeConfig } from './options';
|
|
43
|
+
|
|
44
|
+
// NOTE: UI components (defaultNetFoundryFooterProps, defaultSocialProps, etc.)
|
|
45
|
+
// should be imported directly from '@netfoundry/docusaurus-shared/ui' in client code,
|
|
46
|
+
// not from this theme entry point, as this file runs at Node.js config time.
|
package/src/options.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Social media link configuration for the footer
|
|
5
|
+
*/
|
|
6
|
+
export interface SocialProps {
|
|
7
|
+
githubUrl?: string;
|
|
8
|
+
twitterUrl?: string;
|
|
9
|
+
linkedInUrl?: string;
|
|
10
|
+
youtubeUrl?: string;
|
|
11
|
+
facebookUrl?: string;
|
|
12
|
+
instagramUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Footer configuration for the theme
|
|
17
|
+
*/
|
|
18
|
+
export interface FooterConfig {
|
|
19
|
+
/** Description text shown in the footer */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Social media links */
|
|
22
|
+
socialProps?: SocialProps;
|
|
23
|
+
/** Documentation section links (as ReactNode for JSX support) */
|
|
24
|
+
documentationLinks?: ReactNode[];
|
|
25
|
+
/** Community section links */
|
|
26
|
+
communityLinks?: ReactNode[];
|
|
27
|
+
/** Resources section links */
|
|
28
|
+
resourceLinks?: ReactNode[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Star banner configuration
|
|
33
|
+
*/
|
|
34
|
+
export interface StarBannerConfig {
|
|
35
|
+
/** GitHub repository URL */
|
|
36
|
+
repoUrl: string;
|
|
37
|
+
/** Label text for the star button */
|
|
38
|
+
label: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Options passed to the theme plugin in docusaurus.config.ts
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* themes: [
|
|
47
|
+
* ['@netfoundry/docusaurus-theme', {
|
|
48
|
+
* customCss: require.resolve('./src/css/custom.css'),
|
|
49
|
+
* }],
|
|
50
|
+
* ],
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export interface NetFoundryThemeOptions {
|
|
54
|
+
/** Custom CSS file path(s) to include */
|
|
55
|
+
customCss?: string | string[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Theme configuration in themeConfig.netfoundry
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* themeConfig: {
|
|
64
|
+
* netfoundry: {
|
|
65
|
+
* footer: {
|
|
66
|
+
* description: 'My site description',
|
|
67
|
+
* socialProps: {
|
|
68
|
+
* githubUrl: 'https://github.com/my-org/repo',
|
|
69
|
+
* },
|
|
70
|
+
* },
|
|
71
|
+
* starBanner: {
|
|
72
|
+
* repoUrl: 'https://github.com/my-org/repo',
|
|
73
|
+
* label: 'Star us on GitHub',
|
|
74
|
+
* },
|
|
75
|
+
* showStarBanner: true,
|
|
76
|
+
* },
|
|
77
|
+
* },
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export interface NetFoundryThemeConfig {
|
|
81
|
+
/** Footer configuration */
|
|
82
|
+
footer?: FooterConfig;
|
|
83
|
+
/** Star banner configuration */
|
|
84
|
+
starBanner?: StarBannerConfig;
|
|
85
|
+
/** Whether to show the star banner (default: false) */
|
|
86
|
+
showStarBanner?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Extended Docusaurus ThemeConfig with NetFoundry configuration
|
|
91
|
+
*/
|
|
92
|
+
export interface ThemeConfigWithNetFoundry {
|
|
93
|
+
netfoundry?: NetFoundryThemeConfig;
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
3
|
+
import {
|
|
4
|
+
NetFoundryLayout,
|
|
5
|
+
defaultNetFoundryFooterProps,
|
|
6
|
+
defaultSocialProps,
|
|
7
|
+
} from '@netfoundry/docusaurus-shared/ui';
|
|
8
|
+
import type { ThemeConfigWithNetFoundry } from '../../src/options';
|
|
9
|
+
|
|
10
|
+
export interface LayoutProps {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
noFooter?: boolean;
|
|
13
|
+
wrapperClassName?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* NetFoundry theme Layout component.
|
|
20
|
+
*
|
|
21
|
+
* This component wraps NetFoundryLayout and reads configuration from
|
|
22
|
+
* themeConfig.netfoundry in docusaurus.config.ts.
|
|
23
|
+
*
|
|
24
|
+
* To customize further, swizzle this component:
|
|
25
|
+
* npx docusaurus swizzle @netfoundry/docusaurus-theme Layout --wrap
|
|
26
|
+
*/
|
|
27
|
+
export default function Layout({
|
|
28
|
+
children,
|
|
29
|
+
noFooter,
|
|
30
|
+
wrapperClassName,
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
}: LayoutProps): ReactNode {
|
|
34
|
+
const { siteConfig } = useDocusaurusContext();
|
|
35
|
+
const themeConfig = siteConfig.themeConfig as ThemeConfigWithNetFoundry;
|
|
36
|
+
const nfConfig = themeConfig.netfoundry ?? {};
|
|
37
|
+
|
|
38
|
+
// Build footer props from config, falling back to defaults
|
|
39
|
+
const footerProps = noFooter
|
|
40
|
+
? undefined
|
|
41
|
+
: {
|
|
42
|
+
...defaultNetFoundryFooterProps(),
|
|
43
|
+
...nfConfig.footer,
|
|
44
|
+
socialProps: {
|
|
45
|
+
...defaultSocialProps,
|
|
46
|
+
...nfConfig.footer?.socialProps,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Build star props if enabled
|
|
51
|
+
const starProps =
|
|
52
|
+
nfConfig.showStarBanner && nfConfig.starBanner
|
|
53
|
+
? {
|
|
54
|
+
repoUrl: nfConfig.starBanner.repoUrl,
|
|
55
|
+
label: nfConfig.starBanner.label,
|
|
56
|
+
}
|
|
57
|
+
: undefined;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<NetFoundryLayout
|
|
61
|
+
title={title}
|
|
62
|
+
description={description}
|
|
63
|
+
className={wrapperClassName}
|
|
64
|
+
noFooter={noFooter}
|
|
65
|
+
footerProps={footerProps}
|
|
66
|
+
starProps={starProps}
|
|
67
|
+
meta={{
|
|
68
|
+
siteName: siteConfig.title,
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{children}
|
|
72
|
+
</NetFoundryLayout>
|
|
73
|
+
);
|
|
74
|
+
}
|