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

Obsolete? #43

Open
karlhorky opened this issue Sep 14, 2022 · 4 comments
Open

Obsolete? #43

karlhorky opened this issue Sep 14, 2022 · 4 comments
Assignees

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Sep 14, 2022

Hi @akabekobeko ! 👋 Hope you are well.

I have worked on a PR for gatsby-remark-copy-linked-files for a while now, and it finally got merged:

gatsbyjs/gatsby#36213

This allows for specifying a relative destination dir, which may make gatsby-remark-copy-relative-linked-files obsolete:

module.exports = {
  plugins: [
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          {
            resolve: `gatsby-remark-copy-linked-files`,
            options: {
              // save `src/pages/custom-folder/my-awesome-pdf.pdf` to `public/custom-folder/my-awesome-pdf.pdf`
              // Note: Import `path` to use this example https://nodejs.org/api/path.html
              destinationDir: f => `${path.dirname(path.relative(path.join(__dirname, `src`, `pages`), f.absolutePath))}/${f.name}`,
            },
          },
        ],
      },
    },
  ],
}

What are your thoughts on this?

Should gatsby-remark-copy-relative-linked-files be deprecated (along with a link to gatsby-remark-copy-linked-files)?

@akabekobeko akabekobeko self-assigned this Sep 14, 2022
@akabekobeko
Copy link
Owner

@karlhorky
gatsby-remark-copy-relative-linked-files is a plugin created to compensate for the missing behavior in gatsby-remark-copy-linked-files.

Therefore, gatsby-remark-copy-relative-linked-files may be deprecated if gatsby-remark-copy-linked-files has equivalent functionality.

Please let me know when a version of gatsby-remark-copy-linked-files is released that confirms the merged functionality. I would like to use that functionality too, so I will check the behavior.

@karlhorky
Copy link
Contributor Author

karlhorky commented Sep 17, 2022

Sure, will do! I imagine the new version 5.24.0 will be released within a week.

@karlhorky
Copy link
Contributor Author

karlhorky commented Oct 16, 2022

So gatsby-remark-copy-linked-files@5.24.0 does indeed have equivalent functionality (at least for our project).

However, there is an unusual bug with it right now, which makes it a bit more involved to configure:

{
  resolve: 'gatsby-remark-copy-linked-files',
  options: {
    destinationDir: (f: {
      name: string;
      hash: string;
      absolutePath: string;
    }) =>
      // Avoid errors when Gatsby calls function using this data:
      // { name: n, hash: h, absolutePath: a }
      // https://github.com/gatsbyjs/gatsby/pull/36213#issuecomment-1279789118
      !f.absolutePath.includes('/')
        ? `${f.hash}/${f.name}`
        : `${path.dirname(
            path.relative(
              path.join(__dirname, 'src', 'pages'),
              f.absolutePath,
            ),
          )}/${f.name}-${f.hash}`,
  },
},

So maybe it makes sense to wait until this is resolved and the ternary is no longer needed.

@HarshilShah
Copy link

Chiming in a bit here because I came here just to try out this package because I noticed it does have one feature that the official one doesn't: Support for source tags. For videos, responsive images, etc. the official plugin is woefully incomplete

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

3 participants