Skip to content

Instantly share code, notes, and snippets.

@rsxdalv
Created May 23, 2016 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsxdalv/0bbcf8d48a710e10f64f22276be1570e to your computer and use it in GitHub Desktop.
Save rsxdalv/0bbcf8d48a710e10f64f22276be1570e to your computer and use it in GitHub Desktop.
Hacky solution to import .md docs into a gh-page page (w/o front matter)
---
files:
- game/all/GET.md
- player/ranking/all/GET.md
- player/ranking/GET.md
- rotation/min/GET.md
- rotation/GET.md
- static/legends/id/GET.md
- static/realms/GET.md
- static/server/GET.md
- static/tiers/GET.md
- static/weapons/GET.md
- stats/tiers/GET.md
layout: default
title: Proposed Brawlhalla API
---
{% for file in page.files %}
{% capture my-include %}
{% include_relative {{file | prepend: 'proposed/'}}%}
{% endcapture %}
{{ my-include | strip | markdownify }}
{% endfor %}
@rsxdalv
Copy link
Author

rsxdalv commented May 23, 2016

Context: The repo is used for specs (proposed if you may care) that consist of markdown files describing those specs, keeping the relation between RESTful paths and their documentation simple and easy to navigate. But, in order to flatten and present the specs, using gh-pages jekyll seemed (hindsight - wasn't) optimal. So I created a page that pulls in the list of markdown files provided and outputs them to a landing page. Because I dislike boilerplate and lack of portability, I made it so that YAML FrontMatter would not be needed in headers of the spec files which are supposed to be viewable outside of this context.

Line: comment
2: In my current state, having an array of files is OK.
19. With the prepend, I am able to eliminate shared path
21: strip filter removes the additional whitespace that capture produces.
NB: The files need to be very well formatted markdown. Things like # Heading \n #Heading will not pass, only # Heading \n\n # Heading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment