diff --git a/src/components/CodeEmbed/frame.tsx b/src/components/CodeEmbed/frame.tsx
index 514ddc7fbc..75c94ef235 100644
--- a/src/components/CodeEmbed/frame.tsx
+++ b/src/components/CodeEmbed/frame.tsx
@@ -146,7 +146,7 @@ export const CodeFrame = (props: CodeFrameProps) => {
return;
}
})();
- }, [props.jsCode, mounted]);
+ }, [props.jsCode, mounted,p5ScriptTag]);
return (
([]);
// Flattens the search index data
- const flattenData = (data: FuseResult
) => {
- const flatData: SearchResult[] = [];
- let flatId = 0;
- Object.entries(data).forEach(([category, entries]) => {
- Object.entries(entries).forEach(([title, docDetails]) => {
- // Since we are generating these links with Javascript and the
- // middleware doesn't prefix the locale automatically, we need to
- // do it manually here.
- const relativeUrl =
- currentLocale === defaultLocale
- ? docDetails.relativeUrl
- : `/${currentLocale}${docDetails.relativeUrl}`;
- docDetails.relativeUrl = relativeUrl;
- flatData.push({
- id: flatId++,
- category: category.replace("-fallback", ""),
- title,
- ...docDetails,
- });
- });
- });
-
- return flatData;
- };
+
// Read the search term from query params on first load
useEffect(() => {
@@ -80,6 +57,30 @@ const SearchProvider = ({
}
if (!searchTerm) return;
+ const flattenData = (data: FuseResult) => {
+ const flatData: SearchResult[] = [];
+ let flatId = 0;
+ Object.entries(data).forEach(([category, entries]) => {
+ Object.entries(entries).forEach(([title, docDetails]) => {
+ // Since we are generating these links with Javascript and the
+ // middleware doesn't prefix the locale automatically, we need to
+ // do it manually here.
+ const relativeUrl =
+ currentLocale === defaultLocale
+ ? docDetails.relativeUrl
+ : `/${currentLocale}${docDetails.relativeUrl}`;
+ docDetails.relativeUrl = relativeUrl;
+ flatData.push({
+ id: flatId++,
+ category: category.replace("-fallback", ""),
+ title,
+ ...docDetails,
+ });
+ });
+ });
+
+ return flatData;
+ };
let flatData;
diff --git a/src/pages/_utils-node.ts b/src/pages/_utils-node.ts
index e61170330d..063b96104f 100644
--- a/src/pages/_utils-node.ts
+++ b/src/pages/_utils-node.ts
@@ -75,7 +75,7 @@ export const rewriteRelativeLink = (url: string): string => {
!updatedUrl.endsWith('/') &&
!/(\.\w+)$/.exec(updatedUrl) &&
!updatedUrl.includes('?') &&
- !/#([\w\-]+)$/.exec(updatedUrl)
+ !/#([\w-]+)$/.exec(updatedUrl)
) {
updatedUrl += '/';
}
diff --git a/src/scripts/branchTest.ts b/src/scripts/branchTest.ts
index 601d11f76c..527b265138 100644
--- a/src/scripts/branchTest.ts
+++ b/src/scripts/branchTest.ts
@@ -26,7 +26,7 @@ currentEnv = currentEnv
.split('\n')
.filter((line: string) => !line.startsWith('P5_') && !line.startsWith('PUBLIC_P5_'))
.join('\n')
-writeFileSync(envFilePath, currentEnv + '\n' + envVars.join('\n'));
+writeFileSync(envFilePath, `${currentEnv }\n${ envVars.join('\n')}`);
// First delete the existing cloned p5 to make sure we clone fresh
const parsedP5Path = path.join(__dirname, "./parsers/in/p5.js/");
diff --git a/src/scripts/builders/contribute.ts b/src/scripts/builders/contribute.ts
index ced634d6b5..f99b72d626 100644
--- a/src/scripts/builders/contribute.ts
+++ b/src/scripts/builders/contribute.ts
@@ -259,9 +259,9 @@ const moveContentDirectory = async (
const buildContributorDocs = async () => {
console.log("Building contributor docs...");
- let latestRelease = p5Version;
+ let latestRelease:string = p5Version;
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
- latestRelease = 'v' + latestRelease;
+ latestRelease = `v${ latestRelease}`;
}
await cloneLibraryRepo(clonedRepoPath, docsRepoUrl, latestRelease);
diff --git a/src/scripts/builders/reference.ts b/src/scripts/builders/reference.ts
index d72954c418..cf724c9150 100644
--- a/src/scripts/builders/reference.ts
+++ b/src/scripts/builders/reference.ts
@@ -208,7 +208,7 @@ const correctRelativeLinksInDescription = (description: string | undefined) => {
!href.endsWith('/') &&
!/(\.\w+)$/.exec(href) &&
!href.includes('?') &&
- !/#([\w\-]+)$/.exec(href)
+ !/#([\w-]+)$/.exec(href)
) {
href += '/';
}
diff --git a/src/scripts/parsers/reference.ts b/src/scripts/parsers/reference.ts
index f49ae0bc21..c9b470c2be 100644
--- a/src/scripts/parsers/reference.ts
+++ b/src/scripts/parsers/reference.ts
@@ -22,9 +22,9 @@ const parsersOutPath = path.join(__dirname, "out");
*/
export const parseLibraryReference =
async (): Promise => {
- let latestRelease = p5Version;
+ let latestRelease:string = p5Version;
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
- latestRelease = 'v' + latestRelease;
+ latestRelease = `v${ latestRelease}`;
}
const useExternalP5Sound = !!process.env.P5_REPO_BRANCH ||
@@ -44,7 +44,7 @@ export const parseLibraryReference =
// If we're using a custom build of p5 instead of a public release, create
// a build and copy it to the specified path
if (process.env.PUBLIC_P5_LIBRARY_PATH) {
- await createP5Build('p5.js', '../../../public' + process.env.PUBLIC_P5_LIBRARY_PATH);
+ await createP5Build('p5.js', `../../../public${ process.env.PUBLIC_P5_LIBRARY_PATH}`);
}
// Copy the reference output so we can process it
@@ -67,7 +67,7 @@ export const parseLibraryReference =
// Fix p5.sound classes
for (const key in soundData.classes) {
- const newName = 'p5.' + soundData.classes[key].name;
+ const newName = `p5.${ soundData.classes[key].name}`;
const updated = {
...soundData.classes[key],
name: newName,
@@ -76,7 +76,7 @@ export const parseLibraryReference =
delete soundData.classes[key];
}
for (const item of soundData.classitems) {
- item.class = 'p5.' + item.class;
+ item.class = `p5.${ item.class}`;
}
result = await combineYuidocData(
diff --git a/src/scripts/utils.ts b/src/scripts/utils.ts
index f6aebd25c0..10a7825681 100644
--- a/src/scripts/utils.ts
+++ b/src/scripts/utils.ts
@@ -6,11 +6,11 @@ import { fileURLToPath } from "url";
import { rewriteRelativeLink } from "../pages/_utils-node";
import { p5Version } from "../globals/p5-version";
-let latestRelease = p5Version;
+let latestRelease:string = p5Version;
// If the latest release is a version number (e.g. 1.10.0) without a 'v'
// prefix, add the v prefix
if (/^\d+\.\d+\.\d+$/.exec(latestRelease)) {
- latestRelease = 'v' + latestRelease;
+ latestRelease = `v${ latestRelease}`;
}
export const p5RepoUrl = "https://github.com/processing/p5.js.git";
@@ -295,7 +295,7 @@ export const rewriteRelativeMdLinks = (markdownText: string): string => {
* 1. Text for the link
* 2. Link url (but not the .md extension at the end)
*/
- const regexPattern: RegExp = /(\!?)\[([^\]]+)\]\(([^\)]+)\)/g;
+ const regexPattern: RegExp = /(!?)\[([^\]]+)\]\(([^)]+)\)/g;
return markdownText.replace(regexPattern, (match, img, linkText, url: string) => {
// Don't convert images
if (img) return match;