Как настроить расположение содержимого на «inline» на GatsbyJS (чтобы отображать PDF в браузере, а не загружать его) - PullRequest
0 голосов
/ 11 июля 2019

Я создал сайт с GatsbyJS, и у меня есть ссылка на PDF-файл, который я предпочел бы открыть в браузере, а не загрузить.

Я попытался создать файл _headers в общедоступной папке (хакер, я знаю), и я попробовал gatsby-plugin-netlify, чтобы установить заголовки в gatsby-config.js, но я не уверен, как именно закодируй это. Последние три строки приведенного ниже кода, конечно, неверны.

plugins: [
    {
      resolve: `gatsby-plugin-netlify`,
      options: {
        headers: {}, // option to add more headers. `Link` headers are transformed by the below criteria
        allPageHeaders: [], // option to add headers for all pages. `Link` headers are transformed by the below criteria
        mergeSecurityHeaders: true, // boolean to turn off the default security headers
        mergeLinkHeaders: true, // boolean to turn off the default gatsby js headers
        mergeCachingHeaders: true, // boolean to turn off the default caching headers
        transformHeaders: (headers, path) => headers, // optional transform for manipulating headers under each path (e.g.sorting), etc.
        generateMatchPathRewrites: true, // boolean to turn off automatic creation of redirect rules for client only paths
        Content-Disposition: inline
        Content-Disposition: attachment
        Content-Disposition: attachment; filename="melbournewalks.pdf"
      },
    },
  ],
...