chore: resolve broken and empty links across modelina documentation#2432
chore: resolve broken and empty links across modelina documentation#2432Ishita-190 wants to merge 7 commits intoasyncapi:masterfrom
Conversation
✅ Deploy Preview for modelina ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@jonaslagoni I've made the changes you requested in the other PR for this issue, please take a look and let me know if any other changes need to be made. |
Pull Request Test Coverage Report for Build 21903770163Details
💛 - Coveralls |
jonaslagoni
left a comment
There was a problem hiding this comment.
When using code agents, always make sure you review your PR first :P
Remove PR_DESCRIPTION.md
|
Ah that's embarrassing, I've removed it now. Thank you for pointing it out 😄 |
|
| // Use absolute links for anything relative and non-markdown related | ||
| content = content.replace(/\]\((\.(.*?))\)/g, '](https://github.com/asyncapi/modelina/blob/master/docs/.$2)'); | ||
| // Handle ../ links specifically to resolve them correctly to GitHub URLs | ||
| content = content.replace(/\]\(\.\.\/(.*?\.md[^)]*)\)/g, '](https://github.com/asyncapi/modelina/blob/master/docs/$1)'); |
There was a problem hiding this comment.
This is incorrect.. Relative links in majority of the case should work (if they are docs) relatively on the website too :)
There was a problem hiding this comment.
Working on it, could you please confirm if this works?
function prepareContent(content, currentRelativePath = '/docs/README.md') {
content = content.replace('<!-- toc is generated with GitHub Actions do not remove toc markers -->', '');
content = content.replace('<!-- toc -->', '');
content = content.replace('<!-- tocstop -->', '');
const normalizedCurrentPath = currentRelativePath.replace(/\\/g, '/');
const currentDir = path.posix.dirname(normalizedCurrentPath);
// Resolve relative links based on the current docs file path
content = content.replace(/\]\(((?:\.\.\/|\.\/)[^)]+)\)/g, (fullMatch, relPath) => {
const [, relativePathWithoutSuffix = relPath, suffix = ''] = relPath.match(/^([^?#]+)([?#].*)?$/) || [];
const resolvedPath = path.posix.normalize(path.posix.join(currentDir, relativePathWithoutSuffix));
if (/\.md$/i.test(relativePathWithoutSuffix)) {
const docsPath = resolvedPath
.replace(/\.md$/i, '')
.replace(/\/README$/i, '')
.toLowerCase();
return `](${docsPath || '/docs'}${suffix})`;
}
return `](https://github.com/asyncapi/modelina/blob/master${resolvedPath}${suffix})`;
});
content = content.replace(/\]\(\/docs\/(.*?)README(?:\.md)?([^)]*)\)/gi, (fullMatch, folderPath, suffix) => {
const normalizedFolderPath = folderPath.replace(/\/$/, '');
return `](/docs/${normalizedFolderPath}${suffix})`;
});
// Use correct example links
content = content.replace(/\]\((.*?)examples\/(.*?)\/?\)/g, '](/examples?selectedExample=$2)');
content = content.replace('/examples?selectedExample=integrate-with-react', 'https://github.com/asyncapi/modelina/tree/master/examples/integrate-with-react');
content = content.replace('/examples?selectedExample=integrate-with-next', 'https://github.com/asyncapi/modelina/tree/master/examples/integrate-with-next');
content = content.replace('/examples?selectedExample=integrate-with-maven', 'https://github.com/asyncapi/modelina/tree/master/examples/integrate-with-maven');
// Replace all references to local images for docs
content = content.replace(/"(.*?)\/img\/(.*?)"/g, '"/img/docs/$2"');
return content;
}


Fixes: #2408
A previous attempt to fix this issue (#2416) was blocked due to TypeScript errors in the netlify build preview
Description
Fixed all broken, empty, and outdated links throughout the Modelina documentation to improve user experience and navigation.
Changes Made
docs/champions.md- Fixed empty anchor links for "Versioning and maintenance" and "Reviewing a PR"docs/constraints/README.md- Fixed broken link to internal-model.mddocs/inputs/XSD.md- Fixed broken link to usage.mddocs/internal-model.md- Fixed empty anchor link, added missing "The Splitting of Meta Models" sectiondocs/languages/Java.md- Fixed broken integration.md linkdocs/languages/Rust.md- Added missing content sections, fixed table formatting, removed link functionality from empty linksdocs/other-tools.md- Fixed broken constrainer linkBroken input-processing.md links
Constants.tslinks missing /master/ in pathFiles affected: CSharp, Cplusplus, Dart, Go, Java, JavaScript, Python, Rust, TypeScript
docs/migrations/README.md- Updated migration links to absolute URLsdocs/migrations/version-0-to-1.md- FixedConstrainedMetaModel,ConstrainedObjectPropertyModel, andConstrainedEnumValueModellinksdocs/migrations/version-1-to-2.md- Fixed discriminator link and meta model linkChecklist
npm run lint).npm run test).