在没有 GraphQL 的情况下使用 gatsby-image?
Using gatsby-image without GraphQL?
不幸的是,我们使用的是 Gatsby,但放弃了它的许多功能,例如 GraphQL。我想仍然使用 gatsby-image。尽管我无法从调整大小的转换中获益,但我想获得其他好处,例如延迟加载和占位符。有没有办法通过只传递 url 而不是传递 GraphQL 查询的结果来做到这一点?
Gatsby docs 有一个关于上述 GraphQL 的页面。简而言之:不,gatsby-image
并非设计用于在 Gatsby 的 GraphQL 数据层之外工作 。虽然在没有 GraphQL 的情况下 可能 构建,但您将失去许多将 Gatsby 与其他替代方案区分开来的优势。引用:
It’s also possible to use an “unstructured data” approach in Gatsby sites, no GraphQL required. [...]
Working outside of the data layer [however] means foregoing the optimizations provided by transformer plugins, like:
gatsby-image
(speedy optimized images),
gatsby-transformer-sharp
(provides queryable fields for processing your images in a variety of ways including resizing, cropping, and creating responsive images),
- … the whole Gatsby ecosystem of official and community-created transformer plugins.
(强调)
希望对您有所帮助!
不幸的是,我们使用的是 Gatsby,但放弃了它的许多功能,例如 GraphQL。我想仍然使用 gatsby-image。尽管我无法从调整大小的转换中获益,但我想获得其他好处,例如延迟加载和占位符。有没有办法通过只传递 url 而不是传递 GraphQL 查询的结果来做到这一点?
Gatsby docs 有一个关于上述 GraphQL 的页面。简而言之:不,gatsby-image
并非设计用于在 Gatsby 的 GraphQL 数据层之外工作 。虽然在没有 GraphQL 的情况下 可能 构建,但您将失去许多将 Gatsby 与其他替代方案区分开来的优势。引用:
It’s also possible to use an “unstructured data” approach in Gatsby sites, no GraphQL required. [...]
Working outside of the data layer [however] means foregoing the optimizations provided by transformer plugins, like:
gatsby-image
(speedy optimized images),gatsby-transformer-sharp
(provides queryable fields for processing your images in a variety of ways including resizing, cropping, and creating responsive images),- … the whole Gatsby ecosystem of official and community-created transformer plugins.
(强调)
希望对您有所帮助!