Reputation: 179
I am trying to include source code of a c program in my jekyll pages with download link.
I have searched jekyll documentation and also stackoverflow but nothing is working. Can anyone point out the right way to do this.
---
source: ["inf.c","find.c","error.c","stu.c","info.c"]
---
{% for c in page.source %}
<tr>
<th>
<a href="{{c}}">
{{c}}
</a>
</th>
</tr>
<tr>
<th>
{% highlight ruby %}
{% include {{page.permalink}}{{c}} %}
{% endhighlight %}
</th>
</tr>
{% endfor %}
Upvotes: 2
Views: 781
Reputation: 52829
Let's say that your code snippets a re stored in /code
folder as a.c
, b.c
and so on.
Your page code.html
can be like this one :
{% for c in page.source %}
{% capture filePath %}/code/{{c}}{% endcapture %}
<a href="{{filePath}}">{{c}}</a>
{% highlight c %}
{% include_relative {{ filePath }} %}
{% endhighlight %}
{% endfor %}
Upvotes: 2