Jekyll中的参数化路由

发布于 2025-01-30 19:58:06 字数 463 浏览 1 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花落人离去 2025-02-06 19:58:06

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文