@redocly/theme 0.1.13 → 0.1.14

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.
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ declare type CodeSampleProps = {
3
+ language: string;
4
+ highlighted: string;
5
+ rawContent: string;
6
+ };
7
+ export declare function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.CodeSample = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var react_1 = require("react");
17
+ var ClipboardService_1 = require("../../utils/ClipboardService");
18
+ var styled_1 = require("../../Markdown/CodeSample/styled");
19
+ function CodeSample(_a) {
20
+ var rawContent = _a.rawContent, highlighted = _a.highlighted, language = _a.language;
21
+ var langClassName = language ? "language-".concat(language) : '';
22
+ var _b = (0, react_1.useState)(false), isCopied = _b[0], setIsCopied = _b[1];
23
+ var copyCode = function (code) {
24
+ ClipboardService_1.ClipboardService.copyCustom(code);
25
+ setIsCopied(true);
26
+ setTimeout(function () { return setIsCopied(false); }, 1500);
27
+ };
28
+ return ((0, jsx_runtime_1.jsxs)(styled_1.Wrapper, __assign({ className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" }, { children: [(0, jsx_runtime_1.jsxs)(styled_1.CodeSampleButtonContainer, __assign({ onClick: function () { return copyCode(rawContent); } }, { children: [!isCopied && (0, jsx_runtime_1.jsx)(styled_1.CopyCodeButton, __assign({ title: "Copy the code snippet" }, { children: "Copy" })), isCopied && (0, jsx_runtime_1.jsx)(styled_1.DoneIndicator, { children: "Copied" })] })), (0, jsx_runtime_1.jsx)("pre", __assign({ className: langClassName }, { children: (0, jsx_runtime_1.jsx)("code", { className: langClassName, dangerouslySetInnerHTML: { __html: highlighted } }) }))] })));
29
+ }
30
+ exports.CodeSample = CodeSample;
@@ -0,0 +1,2 @@
1
+ export * from '../../Markdown/CodeSample/CodeSample';
2
+ export * from '../../Markdown/CodeSample/styled';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../../Markdown/CodeSample/CodeSample"), exports);
18
+ __exportStar(require("../../Markdown/CodeSample/styled"), exports);
@@ -0,0 +1,4 @@
1
+ export declare const CodeSampleButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const CopyCodeButton: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const DoneIndicator: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Wrapper = exports.DoneIndicator = exports.CopyCodeButton = exports.CodeSampleButtonContainer = void 0;
11
+ var styled_components_1 = __importDefault(require("styled-components"));
12
+ var _theme_1 = require("../../index.js");
13
+ exports.CodeSampleButtonContainer = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 12px;\n right: 5px;\n"], ["\n position: absolute;\n top: 12px;\n right: 5px;\n"])));
14
+ exports.CopyCodeButton = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0 5px;\n border-radius: 4px;\n display: none;\n &:hover {\n cursor: pointer;\n }\n"], ["\n padding: 0 5px;\n border-radius: 4px;\n display: none;\n &:hover {\n cursor: pointer;\n }\n"])));
15
+ exports.DoneIndicator = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0 5px;\n border-radius: 4px;\n cursor: default;\n"], ["\n padding: 0 5px;\n border-radius: 4px;\n cursor: default;\n"])));
16
+ exports.Wrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n overflow: auto;\n border-radius: 4px;\n position: relative;\n\n ", ",\n ", " {\n color: rgba(255, 255, 255, 0.15);\n }\n ", ":hover {\n color: white;\n outline: 1px solid white;\n }\n\n &:hover {\n ", " ", " {\n display: block;\n }\n }\n pre {\n white-space: var(--code-wrap);\n color: white;\n padding: 12px 14px 15px 14px;\n overflow-x: auto;\n line-height: normal;\n border-radius: 4px;\n font-family: var(--code-font-family);\n background-color: var(--code-block-preformatted-background-color);\n code {\n background-color: transparent;\n border: 0;\n padding: 0;\n color: white;\n &:before,\n &:after {\n content: none;\n }\n }\n }\n pre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n border: 0;\n border-radius: var(--global-border-radius);\n }\n code[class='language-text'] {\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n code[class*='language-'],\n pre[class*='language-'] {\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n word-wrap: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n .token.important,\n .token.bold {\n font-weight: bold;\n }\n .token.italic {\n font-style: italic;\n }\n .token.entity {\n cursor: help;\n }\n .token.punctuation {\n opacity: 0.7;\n }\n .namespace {\n opacity: 0.7;\n }\n\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: #999988;\n font-style: italic;\n }\n .token.namespace {\n opacity: 0.7;\n }\n .token.string,\n .token.attr-value {\n color: #e3116c;\n }\n .token.punctuation,\n .token.operator {\n color: #393a34; /* no highlight */\n }\n .token.entity,\n .token.url,\n .token.symbol,\n .token.number,\n .token.boolean,\n .token.variable,\n .token.constant,\n .token.property,\n .token.regex,\n .token.inserted {\n color: #36acaa;\n }\n .token.atrule,\n .token.keyword,\n .token.attr-name,\n .language-autohotkey .token.selector {\n color: #00a4db;\n }\n .token.function,\n .token.deleted,\n .language-autohotkey .token.tag {\n color: #9a050f;\n }\n .token.tag,\n .token.selector,\n .language-autohotkey .token.keyword {\n color: #00009f;\n }\n\n ", "\n }\n"], ["\n overflow: auto;\n border-radius: 4px;\n position: relative;\n\n ", ",\n ", " {\n color: rgba(255, 255, 255, 0.15);\n }\n ", ":hover {\n color: white;\n outline: 1px solid white;\n }\n\n &:hover {\n ", " ", " {\n display: block;\n }\n }\n pre {\n white-space: var(--code-wrap);\n color: white;\n padding: 12px 14px 15px 14px;\n overflow-x: auto;\n line-height: normal;\n border-radius: 4px;\n font-family: var(--code-font-family);\n background-color: var(--code-block-preformatted-background-color);\n code {\n background-color: transparent;\n border: 0;\n padding: 0;\n color: white;\n &:before,\n &:after {\n content: none;\n }\n }\n }\n pre[class*='language-'] {\n padding: 1em;\n margin: 0.5em 0;\n overflow: auto;\n border: 0;\n border-radius: var(--global-border-radius);\n }\n code[class='language-text'] {\n line-height: 1.2em;\n display: inline-flex;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n code[class*='language-'],\n pre[class*='language-'] {\n text-align: left;\n white-space: pre;\n word-spacing: normal;\n word-break: normal;\n word-wrap: normal;\n line-height: 1.5;\n -moz-tab-size: 4;\n -o-tab-size: 4;\n tab-size: 4;\n -webkit-hyphens: none;\n -moz-hyphens: none;\n -ms-hyphens: none;\n hyphens: none;\n .token.important,\n .token.bold {\n font-weight: bold;\n }\n .token.italic {\n font-style: italic;\n }\n .token.entity {\n cursor: help;\n }\n .token.punctuation {\n opacity: 0.7;\n }\n .namespace {\n opacity: 0.7;\n }\n\n .token.comment,\n .token.prolog,\n .token.doctype,\n .token.cdata {\n color: #999988;\n font-style: italic;\n }\n .token.namespace {\n opacity: 0.7;\n }\n .token.string,\n .token.attr-value {\n color: #e3116c;\n }\n .token.punctuation,\n .token.operator {\n color: #393a34; /* no highlight */\n }\n .token.entity,\n .token.url,\n .token.symbol,\n .token.number,\n .token.boolean,\n .token.variable,\n .token.constant,\n .token.property,\n .token.regex,\n .token.inserted {\n color: #36acaa;\n }\n .token.atrule,\n .token.keyword,\n .token.attr-name,\n .language-autohotkey .token.selector {\n color: #00a4db;\n }\n .token.function,\n .token.deleted,\n .language-autohotkey .token.tag {\n color: #9a050f;\n }\n .token.tag,\n .token.selector,\n .language-autohotkey .token.keyword {\n color: #00009f;\n }\n\n ", "\n }\n"])), exports.CopyCodeButton, exports.DoneIndicator, exports.CopyCodeButton, exports.CodeSampleButtonContainer, exports.CopyCodeButton, (0, _theme_1.generateCodeBlockTokens)());
17
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,3 +1,4 @@
1
+ export * from '../Markdown/CodeSample';
1
2
  export * from '../Markdown/Tabs';
2
3
  export * from '../Markdown/Admonition';
3
4
  export * from '../Markdown/ContentWrapper';
package/Markdown/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../Markdown/CodeSample"), exports);
17
18
  __exportStar(require("../Markdown/Tabs"), exports);
18
19
  __exportStar(require("../Markdown/Admonition"), exports);
19
20
  __exportStar(require("../Markdown/ContentWrapper"), exports);
@@ -16,7 +16,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
16
16
  var usePageData_1 = require("../mocks/hooks/usePageData");
17
17
  var ui_1 = require("../ui");
18
18
  function NextPageLink() {
19
- var nextPage = (0, usePageData_1.usePageData)().nextPage;
19
+ var nextPage = ((0, usePageData_1.usePageData)() || {}).nextPage;
20
20
  if (!nextPage) {
21
21
  return (0, jsx_runtime_1.jsx)("div", { children: "\u00A0" });
22
22
  }
@@ -16,7 +16,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
16
16
  var usePageData_1 = require("../mocks/hooks/usePageData");
17
17
  var ui_1 = require("../ui");
18
18
  function PreviousPageLink() {
19
- var prevPage = (0, usePageData_1.usePageData)().prevPage;
19
+ var prevPage = ((0, usePageData_1.usePageData)() || {}).prevPage;
20
20
  if (!prevPage) {
21
21
  return (0, jsx_runtime_1.jsx)("div", { children: "\u00A0" });
22
22
  }
@@ -36,7 +36,7 @@ function SearchItem(_a) {
36
36
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
37
37
  }
38
38
  }, [item.active]);
39
- return ((0, jsx_runtime_1.jsxs)(SearchLink, __assign({ to: item.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" }, { children: [item.httpVerb ? ((0, jsx_runtime_1.jsxs)(Operation, { children: [(0, jsx_runtime_1.jsx)(OperationBadge_1.OperationBadge, __assign({ type: item.httpVerb }, { children: item.httpVerb })), (0, utils_1.highlight)(item.pathName)] })) : null, (0, jsx_runtime_1.jsx)(Title, { children: (0, utils_1.highlight)(item.title) }), (0, jsx_runtime_1.jsx)(Description, { children: (0, utils_1.highlight)(item.text) }), ((_b = item.parameters) === null || _b === void 0 ? void 0 : _b.length) ? ((0, jsx_runtime_1.jsx)(Parameters_1.Parameters, { parameters: item.parameters })) : ((0, jsx_runtime_1.jsx)(Path, { children: (_c = item.path) === null || _c === void 0 ? void 0 : _c.join(' → ') }))] })));
39
+ return ((0, jsx_runtime_1.jsxs)(SearchLink, __assign({ to: item.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" }, { children: [item.httpVerb ? ((0, jsx_runtime_1.jsxs)(Operation, { children: [(0, jsx_runtime_1.jsx)(OperationBadge_1.OperationBadge, __assign({ type: item.httpVerb }, { children: item.httpVerb })), item.pathName ? (0, utils_1.highlight)(item.pathName) : null] })) : null, (0, jsx_runtime_1.jsx)(Title, { children: (0, utils_1.highlight)(item.title) }), (0, jsx_runtime_1.jsx)(Description, { children: (0, utils_1.highlight)(item.text) }), ((_b = item.parameters) === null || _b === void 0 ? void 0 : _b.length) ? ((0, jsx_runtime_1.jsx)(Parameters_1.Parameters, { parameters: item.parameters })) : ((0, jsx_runtime_1.jsx)(Path, { children: (_c = item.path) === null || _c === void 0 ? void 0 : _c.join(' → ') }))] })));
40
40
  }
41
41
  exports.SearchItem = SearchItem;
42
42
  var SearchLink = (0, styled_components_1.default)(Link_1.Link)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: block;\n text-decoration: none;\n padding: 8px 24px;\n transition: background-color 0.3s ease;\n outline: none;\n white-space: nowrap;\n color: var(--search-item-text-color);\n\n &:hover,\n &:focus {\n background-color: var(--search-item-active-background-color);\n }\n"], ["\n display: block;\n text-decoration: none;\n padding: 8px 24px;\n transition: background-color 0.3s ease;\n outline: none;\n white-space: nowrap;\n color: var(--search-item-text-color);\n\n &:hover,\n &:focus {\n background-color: var(--search-item-active-background-color);\n }\n"])));
@@ -2,4 +2,4 @@ import type { ResolvedNavLinkItem } from '@theme/types/portal';
2
2
  export declare function usePageData(): {
3
3
  prevPage: ResolvedNavLinkItem | null;
4
4
  nextPage: ResolvedNavLinkItem | null;
5
- };
5
+ } | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/theme",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Shared UI components",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -0,0 +1,39 @@
1
+ import React, { useState } from 'react';
2
+
3
+ import { ClipboardService } from '@theme/utils/ClipboardService';
4
+ import {
5
+ Wrapper,
6
+ DoneIndicator,
7
+ CopyCodeButton,
8
+ CodeSampleButtonContainer,
9
+ } from '@theme/Markdown/CodeSample/styled';
10
+
11
+ type CodeSampleProps = {
12
+ language: string;
13
+ highlighted: string;
14
+ rawContent: string;
15
+ };
16
+
17
+ export function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element {
18
+ const langClassName = language ? `language-${language}` : '';
19
+
20
+ const [isCopied, setIsCopied] = useState(false);
21
+
22
+ const copyCode = (code: string) => {
23
+ ClipboardService.copyCustom(code);
24
+ setIsCopied(true);
25
+ setTimeout(() => setIsCopied(false), 1500);
26
+ };
27
+
28
+ return (
29
+ <Wrapper className="code-sample" data-component-name="Markdown/CodeSample/CodeSample">
30
+ <CodeSampleButtonContainer onClick={() => copyCode(rawContent)}>
31
+ {!isCopied && <CopyCodeButton title="Copy the code snippet">Copy</CopyCodeButton>}
32
+ {isCopied && <DoneIndicator>Copied</DoneIndicator>}
33
+ </CodeSampleButtonContainer>
34
+ <pre className={langClassName}>
35
+ <code className={langClassName} dangerouslySetInnerHTML={{ __html: highlighted }} />
36
+ </pre>
37
+ </Wrapper>
38
+ );
39
+ }
@@ -0,0 +1,2 @@
1
+ export * from '@theme/Markdown/CodeSample/CodeSample';
2
+ export * from '@theme/Markdown/CodeSample/styled';
@@ -0,0 +1,159 @@
1
+ import styled from 'styled-components';
2
+
3
+ import { generateCodeBlockTokens } from '@theme';
4
+
5
+ export const CodeSampleButtonContainer = styled.div`
6
+ position: absolute;
7
+ top: 12px;
8
+ right: 5px;
9
+ `;
10
+
11
+ export const CopyCodeButton = styled.div`
12
+ padding: 0 5px;
13
+ border-radius: 4px;
14
+ display: none;
15
+ &:hover {
16
+ cursor: pointer;
17
+ }
18
+ `;
19
+
20
+ export const DoneIndicator = styled.div`
21
+ padding: 0 5px;
22
+ border-radius: 4px;
23
+ cursor: default;
24
+ `;
25
+
26
+ export const Wrapper = styled.div`
27
+ overflow: auto;
28
+ border-radius: 4px;
29
+ position: relative;
30
+
31
+ ${CopyCodeButton},
32
+ ${DoneIndicator} {
33
+ color: rgba(255, 255, 255, 0.15);
34
+ }
35
+ ${CopyCodeButton}:hover {
36
+ color: white;
37
+ outline: 1px solid white;
38
+ }
39
+
40
+ &:hover {
41
+ ${CodeSampleButtonContainer} ${CopyCodeButton} {
42
+ display: block;
43
+ }
44
+ }
45
+ pre {
46
+ white-space: var(--code-wrap);
47
+ color: white;
48
+ padding: 12px 14px 15px 14px;
49
+ overflow-x: auto;
50
+ line-height: normal;
51
+ border-radius: 4px;
52
+ font-family: var(--code-font-family);
53
+ background-color: var(--code-block-preformatted-background-color);
54
+ code {
55
+ background-color: transparent;
56
+ border: 0;
57
+ padding: 0;
58
+ color: white;
59
+ &:before,
60
+ &:after {
61
+ content: none;
62
+ }
63
+ }
64
+ }
65
+ pre[class*='language-'] {
66
+ padding: 1em;
67
+ margin: 0.5em 0;
68
+ overflow: auto;
69
+ border: 0;
70
+ border-radius: var(--global-border-radius);
71
+ }
72
+ code[class='language-text'] {
73
+ line-height: 1.2em;
74
+ display: inline-flex;
75
+ white-space: pre-wrap;
76
+ overflow-wrap: anywhere;
77
+ }
78
+ code[class*='language-'],
79
+ pre[class*='language-'] {
80
+ text-align: left;
81
+ white-space: pre;
82
+ word-spacing: normal;
83
+ word-break: normal;
84
+ word-wrap: normal;
85
+ line-height: 1.5;
86
+ -moz-tab-size: 4;
87
+ -o-tab-size: 4;
88
+ tab-size: 4;
89
+ -webkit-hyphens: none;
90
+ -moz-hyphens: none;
91
+ -ms-hyphens: none;
92
+ hyphens: none;
93
+ .token.important,
94
+ .token.bold {
95
+ font-weight: bold;
96
+ }
97
+ .token.italic {
98
+ font-style: italic;
99
+ }
100
+ .token.entity {
101
+ cursor: help;
102
+ }
103
+ .token.punctuation {
104
+ opacity: 0.7;
105
+ }
106
+ .namespace {
107
+ opacity: 0.7;
108
+ }
109
+
110
+ .token.comment,
111
+ .token.prolog,
112
+ .token.doctype,
113
+ .token.cdata {
114
+ color: #999988;
115
+ font-style: italic;
116
+ }
117
+ .token.namespace {
118
+ opacity: 0.7;
119
+ }
120
+ .token.string,
121
+ .token.attr-value {
122
+ color: #e3116c;
123
+ }
124
+ .token.punctuation,
125
+ .token.operator {
126
+ color: #393a34; /* no highlight */
127
+ }
128
+ .token.entity,
129
+ .token.url,
130
+ .token.symbol,
131
+ .token.number,
132
+ .token.boolean,
133
+ .token.variable,
134
+ .token.constant,
135
+ .token.property,
136
+ .token.regex,
137
+ .token.inserted {
138
+ color: #36acaa;
139
+ }
140
+ .token.atrule,
141
+ .token.keyword,
142
+ .token.attr-name,
143
+ .language-autohotkey .token.selector {
144
+ color: #00a4db;
145
+ }
146
+ .token.function,
147
+ .token.deleted,
148
+ .language-autohotkey .token.tag {
149
+ color: #9a050f;
150
+ }
151
+ .token.tag,
152
+ .token.selector,
153
+ .language-autohotkey .token.keyword {
154
+ color: #00009f;
155
+ }
156
+
157
+ ${generateCodeBlockTokens()}
158
+ }
159
+ `;
@@ -1,3 +1,4 @@
1
+ export * from '@theme/Markdown/CodeSample';
1
2
  export * from '@theme/Markdown/Tabs';
2
3
  export * from '@theme/Markdown/Admonition';
3
4
  export * from '@theme/Markdown/ContentWrapper';
@@ -5,11 +5,11 @@ import { usePageData } from '@portal/hooks/usePageData';
5
5
  import { Button } from '@theme/ui';
6
6
 
7
7
  interface NextPageType {
8
- nextPage: ResolvedNavLinkItem | null;
8
+ nextPage?: ResolvedNavLinkItem | null;
9
9
  }
10
10
 
11
11
  export function NextPageLink(): JSX.Element {
12
- const { nextPage }: NextPageType = usePageData();
12
+ const { nextPage }: NextPageType = usePageData() || {};
13
13
  if (!nextPage) {
14
14
  return <div>&nbsp;</div>;
15
15
  }
@@ -5,11 +5,11 @@ import { usePageData } from '@portal/hooks/usePageData';
5
5
  import { Button } from '@theme/ui';
6
6
 
7
7
  interface PreviousPageType {
8
- prevPage: ResolvedNavLinkItem | null;
8
+ prevPage?: ResolvedNavLinkItem | null;
9
9
  }
10
10
 
11
11
  export function PreviousPageLink(): JSX.Element {
12
- const { prevPage }: PreviousPageType = usePageData();
12
+ const { prevPage }: PreviousPageType = usePageData() || {};
13
13
  if (!prevPage) {
14
14
  return <div>&nbsp;</div>;
15
15
  }
@@ -25,7 +25,7 @@ export function SearchItem({ item }: SearchItemProps): JSX.Element {
25
25
  {item.httpVerb ? (
26
26
  <Operation>
27
27
  <OperationBadge type={item.httpVerb}>{item.httpVerb}</OperationBadge>
28
- {highlight(item.pathName)}
28
+ {item.pathName ? highlight(item.pathName) : null}
29
29
  </Operation>
30
30
  ) : null}
31
31
  <Title>{highlight(item.title)}</Title>
@@ -3,7 +3,7 @@ import type { ResolvedNavLinkItem } from '@theme/types/portal';
3
3
  export function usePageData(): {
4
4
  prevPage: ResolvedNavLinkItem | null;
5
5
  nextPage: ResolvedNavLinkItem | null;
6
- } {
6
+ } | null {
7
7
  return {
8
8
  prevPage: { label: 'Intro', type: 'link', link: '#prev' },
9
9
  nextPage: { label: 'FAQ', type: 'link', link: '#next' },