Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/layouts/ReferenceItemLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,12 @@ const descriptionParts = description.split(
entry.data.file && entry.data.line &&(
<div class="my-xl">
<div class="text-body [&_a]:text-type-magenta-dark [&_a]:!decoration-type-magenta-dark my-lg">
Notice any errors or typos? <a href ="https://github.com/processing/p5.js/issues">Please let us know</a>. Please feel free to edit
This page is generated from the comments in
<a
href={`https://github.com/processing/p5.js/blob/v${p5Version}/${entry.data.file}#L${entry.data.line}`}
>
{entry.data.file}
</a>
and open a pull request!
</a>. Feel free to edit it and submit a pull request!
</div>
</div>
)
Expand Down
8 changes: 7 additions & 1 deletion src/scripts/builders/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { sanitizeName } from "../utils";
import path from "path";
import { load } from "cheerio";
import he from "he";
import { p5Version } from "../../globals/p5-version";

/* Base path for the content directory */
const prefix = "./src/content/reference/en/";
Expand Down Expand Up @@ -290,14 +291,19 @@ const convertToMDX = async (
);

try {
// Add YAML comment to the frontmatter
const comment = `# This file was auto-generated. Please do not edit it manually!\n# To make changes, edit the comments in the corresponding source file:\n# https://github.com/processing/p5.js/blob/v${p5Version}/${doc.file.replace(/\\/g, '/')}#L${doc.line}`;

// Convert the frontmatter to a string
const frontmatter = matter.stringify("", frontMatterArgs);
const frontmatterWithComment = frontmatter.replace('---\n', `---\n${comment}\n`);

// Stores the body of the MDX file
const markdownContent = `# ${sanitizeName(doc.name)}\n`;
// Convert the markdown content to MDX
const mdxContent = remark().use(remarkMDX).processSync(markdownContent);
// Return the full MDX file as a string
return `${frontmatter}\n${mdxContent.toString()}`;
return `${frontmatterWithComment}\n${mdxContent.toString()}`;
} catch (err) {
console.error(`Error converting ${doc.name} to MDX: ${err}`);
return;
Expand Down