Jekyll中的参数化路由
我正在使用jekyll编码我的静态站点,我希望内部路由参数的行为。 例如, 我的路由可以是showinfo/:id
,其中ID是可变的,并且可以由JS使用来获取特定于提供的id
提供的数据。
下面的页面片段:
---
layout: showProfile
title: Show Profile Info
permalink: user/:id
language: en
display-title: "false"
list: exclude
---
## User Profile
虽然我认为这可以正常工作,但实际上却没有。 它仅显示链接的HTML页面,如果我转到路由:“用户/:ID”,相反,我想作为参数式路由来工作,并显示该页面,如果我提供了以下内容:user/123e4567-e89b -12D3-A456-426614174000
I am using jekyll to code my static site, I want the behaviour of route params inside there.
e.g.,
My route could be showInfo/:id
where id is variable and can be used by the JS to fetch some data specific to the id
provided.
The page snippet below:
---
layout: showProfile
title: Show Profile Info
permalink: user/:id
language: en
display-title: "false"
list: exclude
---
## User Profile
While I thought this to work, it actually doesn't.
It only shows the HTML page linked, if I go to the route: "user/:id", instead I wanted to work it as a paramterised route and show the page if I provide anything like: user/123e4567-e89b-12d3-a456-426614174000
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Jekyll将您的用户解释为字符串。我不确定哪些可变存储您的userId,也许尝试
{{userId}}
,用相关变量名称将用户ID代替。无论如何,您可以按照此处所述在全球设置永久链接结构 https://jekylllrb.com/jekyllrb.com/docs/docs/docs/permalinks/permalinks/我建议你从那里开始
jekyll is interpreting your user:/id as a string. I am not sure what variable stores your userids, maybe trying
{{ userid }}
, substituting userid with the relevant variable name. In any case you can set the permalink structure globally as described here https://jekyllrb.com/docs/permalinks/I suggest you start from there