echonesis commented on code in PR #297:
URL: https://github.com/apache/ozone-site/pull/297#discussion_r2749609518


##########
docusaurus.config.js:
##########
@@ -112,6 +112,59 @@ const config = {
 
       return result;
     },
+    /*
+    Validate internal markdown links to ensure they don't contain number 
prefixes or file extensions.
+    These can break when the ordering or format of the target page is updated.
+    Docusaurus can resolve links without these.
+    See https://docusaurus.io/docs/api/docusaurus-config#markdown for 
reference.
+    */
+    preprocessor: (/** @type {{filePath: string, fileContent: string}} */ 
params) => {
+      const {filePath, fileContent} = params;
+
+      // Validate internal links format
+      const internalLinkPattern = /\[([^\]]+)\]\(([^)]+\.md(?:#[^)]+)?)\)/g;
+      const numberPrefixPattern = /\/\d{2}-[^/]+/;

Review Comment:
   Good idea.  Updated the regex to use a negative lookbehind `(?<!!)` to 
exclude image links based on markdown syntax rather than file extensions.



##########
docusaurus.config.js:
##########
@@ -112,6 +112,59 @@ const config = {
 
       return result;
     },
+    /*
+    Validate internal markdown links to ensure they don't contain number 
prefixes or file extensions.
+    These can break when the ordering or format of the target page is updated.
+    Docusaurus can resolve links without these.
+    See https://docusaurus.io/docs/api/docusaurus-config#markdown for 
reference.
+    */
+    preprocessor: (/** @type {{filePath: string, fileContent: string}} */ 
params) => {
+      const {filePath, fileContent} = params;
+
+      // Validate internal links format
+      const internalLinkPattern = /\[([^\]]+)\]\(([^)]+\.md(?:#[^)]+)?)\)/g;

Review Comment:
   Good idea.  Updated the regex to use a negative lookbehind `(?<!!)` to 
exclude image links based on markdown syntax rather than file extensions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to