Skip to content

Commit

Permalink
use link rewriting in contribute docs build
Browse files Browse the repository at this point in the history
  • Loading branch information
outofambit committed Feb 29, 2024
1 parent b24e1bd commit b55c61b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/scripts/build-contribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cloneLibraryRepo,
fullPathFromDirent,
readFile,
rewriteRelativeMdLinks,
writeFile,
} from "./utils";
import type { Dirent } from "fs";
Expand Down Expand Up @@ -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;
};
Expand All @@ -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,
});
};
Expand Down

0 comments on commit b55c61b

Please sign in to comment.