Gatsby: 路径重写

创建于 2016-08-10  ·  3评论  ·  资料来源: gatsbyjs/gatsby

对于某些页面,我想将路由器中的 URL 路径更改为不直接映射到文件系统上的路径。

例如:文件“blog/2015-01-01-post-title”中的一篇博客文章应该有一个路径“blog/post-title”。

我在哪里可以连接到路线构建过程来改变它?

最有用的评论

如果在某个时候为rewritePath添加一些文档会非常酷!

顺便说一句,您的博客似乎不再使用rewritePath 。 也许删除链接...

所有3条评论

好的,如果页面具有元数据字段“路径”,则 Gatsby 似乎会自动重写路径。

这真的应该在某处记录!

您还可以通过在 gatsby-node.js 中导出rewritePath以编程方式重写路径。 也没有记录: -

https://github.com/gatsbyjs/gatsby/blob/364a5496ce172e117cc9fc7b10bb1e338693c2ec/lib/utils/build-page/url-resolver.js#L11

以我的博客为例https://github.com/KyleAMathews/blog/blob/master/gatsby-node.js

如果在某个时候为rewritePath添加一些文档会非常酷!

顺便说一句,您的博客似乎不再使用rewritePath 。 也许删除链接...

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jaanhio picture jaanhio  ·  3评论

timbrandin picture timbrandin  ·  3评论

ghost picture ghost  ·  3评论

3CordGuy picture 3CordGuy  ·  3评论

rossPatton picture rossPatton  ·  3评论