Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add javascript library to Octopress posts?

For different posts (generated through rake new_post[my_post]), I want to add a javascript function that is to be only included in that post, and nowhere else on the blog.

I can do this by hand-editing the public/my_post/index.html file but then every time I do a rake generate, I will have to do this again.

Is there a built in way to make this happen in Octopress?

Cheers

like image 985
Idr Avatar asked Jun 10 '12 00:06

Idr


1 Answers

In 2.1 you will be able to inject per page/post JavaScript or CSS assets into the header by setting some vars in the yaml front matter.

Currently you can simply insert a link or script tag inside of the post or page itself and it will be loaded in place. Example:

<script type="text/javascript" src="/path/to/file.js"></script>
<link rel="stylesheet" type="text/css" href="/path/to/file.css">
like image 75
Brandon Mathis Avatar answered Nov 07 '22 22:11

Brandon Mathis