You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a fairly common feature request. E.g. someone is using a frontmatter field in markdown to link to a file then wants to query that file to get public link to the file.
When this field is queried, the graphql resolver should copy the file to public/static with the hash of the file added to its file name (similar to what we do with images) and return the new path.
The text was updated successfully, but these errors were encountered:
Is there a way to get publicURL within a transformer plugin? I have links to relative path files in the content (org-mode), I tried to get publicURL from file nodes, but got nothing. I assume it's not ready at that point ( in extend-node-type). I saw the implementation in gatsby-remark-copy-linked-files, it's good to not having to rewrite something similar, since gatsby-source-filesystem is already doing it.
Had a look at this #3669 , the way gatsby-transformer-sharp was implemented is a easier way for me. but it is a little concerning, since it hard code the publicURL in there. If the original one (in filesystem) changed, it will break.
publicURL is field with resolver which means it will generate value (and copy file to build directory) on demand when queried and not really accessible with js code. You should propably look into refactoring that code into separate function and export it from gatsby-source-filesystem as @KyleAMathews suggested.
This is a fairly common feature request. E.g. someone is using a frontmatter field in markdown to link to a file then wants to query that file to get public link to the file.
To do this, we'd need gatsby-source-filesystem to extend the default File schema to add a
publicURL
field https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-filesystem/src/gatsby-node.jsThis would use https://www.gatsbyjs.org/docs/node-apis/#setFieldsOnGraphQLNodeType
When this field is queried, the graphql resolver should copy the file to
public/static
with the hash of the file added to its file name (similar to what we do with images) and return the new path.The text was updated successfully, but these errors were encountered: