I'm building a static website with Gatsby and I need to put some .txt or .pdf files on it, so that a visitor can download them. How can I do it?
I'm a newbie, and my GraphQL knowledge is really thin, I use it only to get some images to my components. My 'gatsby-config.js' contains this:
{
resolve: `gatsby-source-filesystem`,
options: {
name: `documents`,
path: `${__dirname}/src/documents`,
},
},
I tried something and on GraphiQL this seems to be valid code:
const data = useStaticQuery(graphql`
query {
document1: file(relativePath: {eq: "doc1.txt"}) {
id
}
}
`)
But I don't know how to make that 'document1' downloadable in JSX.