diff --git a/dist/app.js b/dist/app.js index 4cad3e26..0dc4d42f 100644 --- a/dist/app.js +++ b/dist/app.js @@ -148,19 +148,19 @@ var mergeMDX = function (handoff) { return __awaiter(void 0, void 0, void 0, fun * @param id */ var transformMdx = function (src, dest, id) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var _a, _b, _c, _d, _e, _f, _g, _h; var content = fs_extra_1.default.readFileSync(src); - var _k = (0, gray_matter_1.default)(content), data = _k.data, body = _k.content; + var _j = (0, gray_matter_1.default)(content), data = _j.data, body = _j.content; var mdx = body; var title = (_a = data.title) !== null && _a !== void 0 ? _a : ''; var menu = (_b = data.menu) !== null && _b !== void 0 ? _b : ''; - var description = (_c = data.description.replace(/(\r\n|\n|\r)/gm, "")) !== null && _c !== void 0 ? _c : ''; - var metaDescription = (_d = data.metaDescription) !== null && _d !== void 0 ? _d : ''; - var metaTitle = (_e = data.metaTitle) !== null && _e !== void 0 ? _e : ''; - var weight = (_f = data.weight) !== null && _f !== void 0 ? _f : 0; - var image = (_g = data.image) !== null && _g !== void 0 ? _g : ''; - var menuTitle = (_h = data.menuTitle) !== null && _h !== void 0 ? _h : ''; - var enabled = (_j = data.enabled) !== null && _j !== void 0 ? _j : true; + var description = data.description ? data.description.replace(/(\r\n|\n|\r)/gm, "") : ''; + var metaDescription = (_c = data.metaDescription) !== null && _c !== void 0 ? _c : ''; + var metaTitle = (_d = data.metaTitle) !== null && _d !== void 0 ? _d : ''; + var weight = (_e = data.weight) !== null && _e !== void 0 ? _e : 0; + var image = (_f = data.image) !== null && _f !== void 0 ? _f : ''; + var menuTitle = (_g = data.menuTitle) !== null && _g !== void 0 ? _g : ''; + var enabled = (_h = data.enabled) !== null && _h !== void 0 ? _h : true; var wide = data.wide ? 'true' : 'false'; // mdx = "\n\n\n".concat(mdx, "\n\n\nimport {staticBuildMenu, getCurrentSection} from \"handoff-app/src/app/components/util\";\nimport { getClientConfig } from '@handoff/config';\nimport { getPreview } from \"handoff-app/src/app/components/util\";\n\nexport const getStaticProps = async () => {\n // get previews for components on this page\n const previews = getPreview();\n const menu = staticBuildMenu();\n const config = getClientConfig();\n return {\n props: {\n previews,\n menu,\n config,\n current: getCurrentSection(menu, \"/").concat(id, "\") ?? [],\n title: \"").concat(title, "\",\n description: \"").concat(description, "\",\n image: \"").concat(image, "\",\n },\n };\n};\n\nexport const preview = (name) => { \n return previews.components[name];\n};\n\nimport MarkdownLayout from \"handoff-app/src/app/components/MarkdownLayout\";\nexport default function Layout(props) {\n return (\n \n {props.children}\n \n );\n\n}"); diff --git a/dist/transformers/preview/index.js b/dist/transformers/preview/index.js index e46cfa76..ecb82730 100644 --- a/dist/transformers/preview/index.js +++ b/dist/transformers/preview/index.js @@ -147,7 +147,7 @@ function previewTransformer(handoff, documentationObject) { }); }))]; case 1: result = _a.sent(); - custom = path_1.default.resolve(handoff.workingPath, "integration/templates/custom"); + custom = path_1.default.resolve(handoff.workingPath, "integration/snippets"); publicPath = path_1.default.resolve(handoff.workingPath, "public"); if (!fs_extra_1.default.existsSync(custom)) return [3 /*break*/, 12]; files = fs_extra_1.default.readdirSync(custom); diff --git a/src/app.ts b/src/app.ts index 6f4ddb50..962aef3d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -97,7 +97,7 @@ const transformMdx = (src: string, dest: string, id: string) => { let mdx = body; const title = data.title ?? ''; const menu = data.menu ?? ''; - const description = data.description.replace(/(\r\n|\n|\r)/gm, "") ?? ''; + const description = data.description ? data.description.replace(/(\r\n|\n|\r)/gm, "") : ''; const metaDescription = data.metaDescription ?? ''; const metaTitle = data.metaTitle ?? ''; const weight = data.weight ?? 0; diff --git a/src/app/components/ComponentPreview.tsx b/src/app/components/ComponentPreview.tsx index bd76578d..03f8ed17 100644 --- a/src/app/components/ComponentPreview.tsx +++ b/src/app/components/ComponentPreview.tsx @@ -111,7 +111,7 @@ export const ComponentDisplay: React.FC<{ component: PreviewObject | undefined; ); }; -export const CustomComponentPreview: React.FC<{ +export const SnippetPreview: React.FC<{ preview?: PreviewObject; id: string; code: string; diff --git a/src/transformers/preview/index.ts b/src/transformers/preview/index.ts index 6f0caf7e..cdb4ba2d 100644 --- a/src/transformers/preview/index.ts +++ b/src/transformers/preview/index.ts @@ -112,7 +112,7 @@ export default async function previewTransformer(handoff: Handoff, documentation // Allow a user to create custom previews by putting templates in a custom folder // Iterate over the html files in that folder and render them as a preview - const custom = path.resolve(handoff.workingPath, `integration/templates/custom`); + const custom = path.resolve(handoff.workingPath, `integration/snippets`); const publicPath = path.resolve(handoff.workingPath, `public`); if (fs.existsSync(custom)) { const files = fs.readdirSync(custom);