英文:
Access and display a gitlab username on a private gitlab pages hosted website
问题
I built a static wiki website hosted by GitLab pages and requires that they log into their gitlab account before accessing the site. It uses Jekyll and some HTML templates to build the site pages from markdown files.
Some of the info on the site would be clearer to the users if I could display their gitlab usernames to them. I would have to indicate where it would be displayed on the markdown file.
Is there any way to set their gitlab username as a variable in html, liquid, or JavaScript that could be accessed from a markdown file?
Edit: I know it's static, but I've gotten the site to access to user's light/dark mode preferences using JavaScript. My naive understanding of JavaScript tells me getting their username should be doable.
英文:
I built a static wiki website hosted by GitLab pages and requires that they log into their gitlab account before accessing the site. It uses Jekyll and some HTML templates to build the site pages from markdown files.
Some of the info on the site would be clearer to the users if I could display their gitlab usernames to them. I would have to indicate where it would be displayed on the markdown file.
Is there any way to set their gitlab username as a variable in html, liquid, or JavaScript that could be accessed from a markdown file?
Edit: I know it's static, but I've gotten the site to access to user's light/dark mode preferences using JavaScript. My naive understanding of JavaScript tells me getting their username should be doable.
答案1
得分: 1
你可以调用GitLab API <your-gitlab.com>/api/v4/user
,这将返回当前登录用户的用户对象,包括用户名、用户ID和用户的电子邮件。
英文:
You can call the gitlab api <your-gitlab.com>/api/v4/user
this will return a user object of the currently logged in user with username, user-id the users email.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论