From b55c61b2caa6997185c55d202df49f16dbb1503a Mon Sep 17 00:00:00 2001 From: evelyn masso Date: Thu, 29 Feb 2024 09:48:33 -0800 Subject: [PATCH] use link rewriting in contribute docs build --- src/scripts/build-contribute.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scripts/build-contribute.ts b/src/scripts/build-contribute.ts index 3c89f8b762..80c8c56530 100644 --- a/src/scripts/build-contribute.ts +++ b/src/scripts/build-contribute.ts @@ -6,6 +6,7 @@ import { cloneLibraryRepo, fullPathFromDirent, readFile, + rewriteRelativeMdLinks, writeFile, } from "./utils"; import type { Dirent } from "fs"; @@ -60,14 +61,19 @@ const convertMdtoMdx = async ( // this means the read file failed for some reason if (contents === undefined) return; + const contentWithRewrittenLinks = rewriteRelativeImageLinks( + rewriteRelativeMdLinks(contents), + "images/contributor-docs", + ); + const newFilePath = path.join(destinationFolder, `${name}.mdx`); - const newContents = ` + const newFileContents = ` --- ${frontmatterObject ? YAML.stringify(frontmatterObject) : ""} --- - ${contents} + ${contentWithRewrittenLinks} `; - await writeFile(newFilePath, newContents); + await writeFile(newFilePath, newFileContents); return undefined; }; @@ -78,7 +84,7 @@ const convertMdtoMdx = async ( * @param dirPath path to the folder of assets */ const moveAssetsFolder = async (dirPath: string) => { - await cp(dirPath, path.join(repoRootPath, "public/contributor-docs"), { + await cp(dirPath, path.join(repoRootPath, "public/images/contributor-docs"), { recursive: true, }); };