@eventcatalog/core 2.13.2 → 2.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.13.3
4
+
5
+ ### Patch Changes
6
+
7
+ - b893559: fix(core): fixed issue with styling of schema files
8
+
3
9
  ## 2.13.2
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.13.2",
9
+ "version": "2.13.3",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -0,0 +1,32 @@
1
+ ---
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { Code } from 'astro-expressive-code/components';
5
+
6
+ interface Props {
7
+ file?: string;
8
+ catalog: {
9
+ filePath: string;
10
+ };
11
+ title?: string;
12
+ }
13
+
14
+ const { file = 'schema.json', catalog, title } = Astro.props;
15
+
16
+ let code: string | null = null;
17
+
18
+ const exists = fs.existsSync(path.join(catalog.filePath, file));
19
+ if (exists) {
20
+ code = fs.readFileSync(path.join(catalog.filePath, file), 'utf-8');
21
+ }
22
+ ---
23
+
24
+ {
25
+ code ? (
26
+ <div class="not-prose max-w-4xl overflow-x-auto">
27
+ <Code code={code} title={title || file} lang="json" />
28
+ </div>
29
+ ) : (
30
+ <div class="italic">Tried to load schema from {path.join(catalog.filePath, file)}, but no schema can be found</div>
31
+ )
32
+ }
@@ -1,5 +1,5 @@
1
1
  // React components
2
- import Schema from '@components/MDX/Schema';
2
+ import Schema from '@components/MDX/Schema.astro';
3
3
  import File from '@components/MDX/File';
4
4
  import Accordion from '@components/MDX/Accordion/Accordion.astro';
5
5
  import AccordionGroup from '@components/MDX/Accordion/AccordionGroup.astro';
@@ -16,6 +16,7 @@ import ChannelInformation from '@components/MDX/ChannelInformation/ChannelInform
16
16
  // Portals: required for server/client components
17
17
  import NodeGraphPortal from '@components/MDX/NodeGraph/NodeGraphPortal';
18
18
  import SchemaViewerPortal from '@components/MDX/SchemaViewer/SchemaViewerPortal';
19
+ import { jsx } from 'astro/jsx-runtime';
19
20
 
20
21
  const components = (props: any) => {
21
22
  return {
@@ -33,7 +34,7 @@ const components = (props: any) => {
33
34
  NodeGraph: (mdxProp: any) => NodeGraphPortal({ ...props.data, ...mdxProp }),
34
35
  ChannelInformation: (mdxProp: any) => ChannelInformation({ ...props.data, ...mdxProp }),
35
36
  SchemaViewer: (mdxProp: any) => SchemaViewerPortal({ ...props.data, ...mdxProp }),
36
- Schema: (mdxProp: any) => Schema({ ...props, ...mdxProp }),
37
+ Schema: (mdxProp: any) => jsx(Schema, { ...props, ...mdxProp }),
37
38
  };
38
39
  };
39
40
 
@@ -1,45 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- const Schema = ({ file = 'schema.json', catalog, title }: any) => {
5
- try {
6
- const exists = fs.existsSync(path.join(catalog.filePath, file));
7
-
8
- if (exists) {
9
- const text = fs.readFileSync(path.join(catalog.filePath, file), 'utf-8');
10
- return (
11
- <div className="not-prose max-w-4xl overflow-x-auto">
12
- <pre className="expressive-code" data-language="json">
13
- <figure className="frame has-title">
14
- <figcaption className="header">
15
- {title && <span className="title">{title}</span>}
16
- {!title && <span className="title">{file}</span>}
17
- </figcaption>
18
- <pre data-language="js">
19
- <code>
20
- <div className="ec-line">
21
- <div className="code">{text}</div>
22
- </div>
23
- </code>
24
- </pre>
25
- <div className="copy">
26
- <button title="Copy to clipboard" data-copied="Copied!" data-code={text}>
27
- <div></div>
28
- </button>
29
- </div>
30
- </figure>
31
- </pre>
32
- </div>
33
- );
34
- } else {
35
- return (
36
- <div className="italic">Tried to load schema from {path.join(catalog.filePath, file)}, but no schema can be found</div>
37
- );
38
- }
39
- } catch (error) {
40
- console.log('Failed to load schema file', error);
41
- return null;
42
- }
43
- };
44
-
45
- export default Schema;