remix-run / remix-website

327 stars 74 forks source link

fix: Fixed broken urls in READMEs #212

Closed AlemTuzlak closed 6 months ago

AlemTuzlak commented 6 months ago

Fixes #211

This will fix the broken URL's in resources.

I added "ES2022" as a lib which I'm not sure if this is okay, if not this can also be done with good old replace.

brookslybrand commented 6 months ago

Hmm, yeah I'm a little worried about this approach. If there are every code samples that use a relative path this is going to break those examples 😕

I don't know if you looked into octokit at all to see if it has APIs for resolving the relative links, I would maybe do a little research there before trying to implement something ourselves.

If we do take our own find-and-replace approach, I think this is definitely something we should provide some tests for, since I'm sure we'll run into bugs as we go. Don't want to play bug wack-a-mole.

AlemTuzlak commented 6 months ago

After checking the docs here: https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-a-repository-readme

I tried using json and raw, after trying both they return relative links instead of the absolute ones. I think that ocktokit does not support these kind of replacements at the moment.

I've enhanced the function to use a regex instead that finds the img attribute and runs the replacement, also added a bunch of tests for all cases I could think of. Let me know what you think @brookslybrand