@portosaur/theme 0.5.1 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portosaur/theme",
3
- "version": "0.5.1",
3
+ "version": "0.6.3",
4
4
  "description": "Theme components for Portosaur - React components, static assets etc.",
5
5
  "license": "GPL-3.0-only",
6
6
  "author": "soymadip",
@@ -34,18 +34,24 @@
34
34
  "@easyops-cn/docusaurus-search-local": "^0.55.1",
35
35
  "@fontsource-variable/lexend": "^5.2.11",
36
36
  "@fontsource/alata": "^5.2.8",
37
- "@portosaur/core": "^0.5.1",
37
+ "@portosaur/core": "^0.6.3",
38
38
  "chalk": "^5.6.2",
39
39
  "clsx": "^2.1.1",
40
40
  "favicons": "^7.2.0",
41
41
  "framer-motion": "^12.38.0",
42
42
  "prism-react-renderer": "^2.4.1",
43
- "react": "^18.3.1",
44
- "react-dom": "^18.3.1",
45
43
  "react-icons": "^5.6.0",
46
44
  "react-pdf": "^10.4.1",
47
45
  "react-rnd": "^10.5.3",
48
46
  "react-slick": "^0.31.0",
49
47
  "slick-carousel": "^1.8.1"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=18.0.0",
51
+ "react-dom": ">=18.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "react": "^18.3.1",
55
+ "react-dom": "^18.3.1"
50
56
  }
51
57
  }
@@ -4,12 +4,34 @@ import { fileURLToPath } from "url";
4
4
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
5
 
6
6
  export default function themePlugin(_context, options) {
7
+ const themeDir = options.themeDir || path.resolve(__dirname, "../../theme");
8
+
7
9
  return {
8
10
  name: "portosaur-theme",
9
11
 
10
12
  // Registers Portosaur component overrides (swizzle targets).
13
+ // NOTE: Use @theme-init (not @theme-original) when importing the base
14
+ // Docusaurus component inside these overrides. @theme-original is
15
+ // overwritten by the alias system for plugin themes; @theme-init is not.
11
16
  getThemePath() {
12
- return options.themeDir || path.resolve(__dirname, "../../theme");
17
+ return themeDir;
18
+ },
19
+
20
+ // Adds the JSX/Babel loader for .jsx files in the theme directory.
21
+ // Required when the theme resolves outside node_modules (e.g. bun-link
22
+ // in development), where Docusaurus's default JS rule may not cover it.
23
+ configureWebpack(_config, isServer, utils) {
24
+ return {
25
+ module: {
26
+ rules: [
27
+ {
28
+ test: /\.jsx?$/,
29
+ include: [themeDir],
30
+ use: [utils.getJSLoader({ isServer })],
31
+ },
32
+ ],
33
+ },
34
+ };
13
35
  },
14
36
  };
15
37
  }
@@ -1,14 +1,14 @@
1
- import MDXComponents from "@theme-original/MDXComponents";
1
+ import MDXComponents from "@theme-init/MDXComponents";
2
2
  import Details from "@theme/Details";
3
3
  import Tabs from "@theme/Tabs";
4
4
  import TabItem from "@theme/TabItem";
5
- import { Pv, SrcPv } from "./components/Preview/index.jsx";
6
- import Tooltip from "./components/Tooltip/index.jsx";
7
- import TopicList from "./components/TopicList/index.jsx";
8
- import Indent from "./components/Indent/index.jsx";
5
+ import { Pv, SrcPv } from "./components/Preview";
6
+ import Tooltip from "./components/Tooltip";
7
+ import TopicList from "./components/TopicList";
8
+ import Indent from "./components/Indent";
9
9
 
10
10
  // Make useful Custom Components available by default
11
- const components = {
11
+ export default {
12
12
  ...MDXComponents,
13
13
  Pv,
14
14
  SrcPv,
@@ -19,5 +19,3 @@ const components = {
19
19
  Tooltip,
20
20
  Indent,
21
21
  };
22
-
23
- export default components;
@@ -1,9 +1,4 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useReducer,
5
- useCallback,
6
- } from "react";
1
+ import { createContext, useContext, useReducer, useCallback } from "react";
7
2
 
8
3
  const PreviewContext = createContext(null);
9
4
  const DEFAULT_SIZE = { width: 720, height: 400 };
@@ -19,6 +19,10 @@ export default function TopicList({
19
19
  // Fallback if not on a category page
20
20
  }
21
21
 
22
+ if (!items || items.length === 0) {
23
+ return null;
24
+ }
25
+
22
26
  return (
23
27
  <>
24
28
  <br />