简体   繁体   中英

How to read .yaml file in Github repository and publish content to Github page

I'm trying to set up a Github page from my enterprise private repository. There is a yaml file containing metadata of a list of application in the repository including application name, description, and miscellaneous. I only want to publish the name and description to the Github page and later I would create a search bar to find the available application name in the repository. The Github page is backed by a index.html file inside docs folder in my repository. Is there any solution for me to achieve that?

Github Pages serves only static files, but you can use Jekyll to generate those static files based on your data. To do that, place your YAML file in _data and then generate your HTML with Liquid templates, as described here . General information about using Jekyll with Github Pages is available here .

For the search bar, you'd need to use client-side JavaScript. Just group the element for each application with a class so that you can query them with JS, then show or hide them based on the searched term(s). You could also generate static JSON file that contains all information with Liquid from your data and then load and process that client-side with JS. Finally, you could serve the YAML file itself to the client and load it using js-yaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM