File tree Expand file tree Collapse file tree
custom-plugins/json_articles Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- Random Articles Plugin For Pelican
1+ Json Articles Plugin For Pelican
22========================
33
44This plugin insert a variable called ` json_articles ` in the page context.
5- Only published articles are listed.
5+
6+ This variable contains all articles in a json format.
7+
8+
9+ In settings we can define the number of random_articles:
10+
11+ RANDOM_ARTICLES = 3
612
713
814Usage
915-----
1016
11- You can access all articles calling ` json_articles ` variable in your template.
17+ Add ` dynamic_random_articles.js ` in your template, in our case, just do that:
18+ <script src =" {{ SITEURL }}/theme/js/dynamic_random_articles.js " ></script >
19+
20+ In our sidebar.html was inserted:
21+
22+ div class="section articles-random">
23+ <h1 class="tagline">Não deixe de ver!</h1>
24+ <div id="random-articles"></div>
25+ </div>
26+
27+ We use ` articles-random ` class to hide it in mobile.
28+
29+ And then, we call the javascript function that render articles:
30+
31+ $(function(){
32+ show_random_articles($('#random-articles'), {{ json_articles }}, {{ RANDOM_ARTICLES }});
33+ });
34+
35+ Note that we pass a element to function, this element can be changed any time.
Original file line number Diff line number Diff line change 8282 } ) ;
8383
8484 $ ( function ( ) {
85- articles = { { json_articles } } ;
8685 show_random_articles ( $ ( '#random-articles' ) , { { json_articles } } , { { RANDOM_ARTICLES } } ) ;
8786 } ) ;
8887
You can’t perform that action at this time.
0 commit comments