Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to files shown as broken #10

Open
joeplaa opened this issue Dec 10, 2020 · 5 comments
Open

Links to files shown as broken #10

joeplaa opened this issue Dec 10, 2020 · 5 comments

Comments

@joeplaa
Copy link

joeplaa commented Dec 10, 2020

Hi,

I'm building a blog in which I'm also embedding file downloads using the gatsby-remark-copy-linked-files plugin. This plugin catches the relative links to the file [eenmanszaak-of-bv.xlsx](../../assets/eenmanszaak-of-bv.xlsx), copies the file to the public folder (/assets/) and updates the link in html.

Now your plugin also catches these links and shows them as broken. I tried excluding the assets folder but still all of them are shown as broken.

Folder structure:

|--content
|  |--assets
|  |  |--welke-rechtsvorm.mdx
|  |--eenmanszaak-of-bv.xlsx
|  |  |--welke-rechtsvorm.mdx
|--gatsby-config.js 

gatsby-config.js:

{
  resolve: `gatsby-remark-copy-linked-files`,
  options: {
    destinationDir: `assets`,
    ignoreFileExtensions: [`png`, `jpg`, `jpeg`, `bmp`, `tiff`],
  },
},
{
  resolve: 'gatsby-remark-check-links',
  options: {
    exceptions: [
      '/assets/'
    ]
  }
}

Console output:

warning 1 broken links found on /welke-rechtsvorm/
warning  63:114  ../../assets/eenmanszaak-of-bv.xlsx

Question:
Have I misconfigured the exceptions? Or is this a limitation of your plugin? If so can you add this functionality?

@CollierCZ
Copy link

I think that exceptions only takes exact matches. You're expecting it to handle directories, but it seems to be checking the list against the specific path. I think you have to add the specific generated path to the file (if you're using gatsby-remark-copy-linked-files, that'll probably include a randomly generated ID string).

@joeplaa
Copy link
Author

joeplaa commented Dec 16, 2020

@CollierCZ Yeah, I thought something like that should be the case after seeing that a relative link to another .mdx file in the same directory wasn't checked. As I ended up making a dedicated downloads page, I now link to the files directly using a custom component instead of gatsby-remark-copy-linked-files. So in a way this problem has solved itself for my use-case.

However, it still seems to be a problem if you want to use the gatsby-remark-copy-linked-files plugin.

@CollierCZ
Copy link

You can add the file and run a develop build and then copy the generated link into exceptions. It's worked for us so far.

@joeplaa
Copy link
Author

joeplaa commented Jan 7, 2021

That could be an acceptable workaround if you don't have many downloads and you don't use automated testing and building, but it still is a workaround. So I can imagine you don't want to go in and copy links every time you prepare a build.

@CollierCZ
Copy link

CollierCZ commented Jan 8, 2021

We've found the IDs stay constant across builds. You only have to do it once when you add the file. The remaining builds work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants