Skip to content

Commit 66797f3

Browse files
committed
separate learn block and use a variable instead of sample to avoid duplicates
1 parent c13806b commit 66797f3

2 files changed

Lines changed: 23 additions & 60 deletions

File tree

_includes/index/learn_block.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div class="image">
2+
{% assign guide = site.data.guides[include.index] %}
3+
<img class="image-headline" alt="{{ guide.image_alt_attribute }}"
4+
src="{{ guide.image }}"
5+
/>
6+
<span class="image-title">
7+
<span>
8+
<p><a href="{{ guide.guide_url }}">{{ guide.title }} by {{ guide.author }}</a></p>
9+
</span>
10+
<img alt="Made with CircuitPython Logo"
11+
src="{{ "assets/images/made_with_circuitpython.svg" |
12+
relative_url }}"
13+
/>
14+
</span>
15+
</div>

index.html

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,8 @@ <h1>The easiest way to program microcontrollers</h1>
1717
<a href="https://learn.adafruit.com/welcome-to-circuitpython">Get Started</a>
1818
</div>
1919
</div>
20-
<div class="image">
21-
{% assign guide = site.data.guides | sample %}
22-
<img class="image-headline" alt="{{ guide.image_alt_attribute }}"
23-
src="{{ guide.image }}"
24-
/>
25-
<span class="image-title">
26-
<span>
27-
<p><a href="{{ guide.guide_url }}">{{ guide.title }} by {{ guide.author }}</a></p>
28-
</span>
29-
<img alt="Made with CircuitPython Logo"
30-
src="{{ "assets/images/made_with_circuitpython.svg" |
31-
relative_url }}"
32-
/>
33-
</span>
34-
</div>
20+
{% assign learn_block_index = 0 %}
21+
{% include index/learn_block.html index=learn_block_index %}
3522
</div>
3623

3724
<div class="one-column-content">
@@ -96,21 +83,8 @@ <h3>Serial Console + REPL</h3>
9683
</div>
9784

9885
<div class="two-column-content">
99-
<div class="image">
100-
{% assign guide = site.data.guides | sample %}
101-
<img class="image-headline" alt="{{ guide.image_alt_attribute }}"
102-
src="{{ guide.image }}"
103-
/>
104-
<span class="image-title">
105-
<span>
106-
<p><a href="{{ guide.guide_url }}">{{ guide.title }} by {{ guide.author }}</a></p>
107-
</span>
108-
<img alt="Made with CircuitPython Logo"
109-
src="{{ "assets/images/made_with_circuitpython.svg" |
110-
relative_url }}"
111-
/>
112-
</span>
113-
</div>
86+
{% assign learn_block_index = learn_block_index | plus: 1 %}
87+
{% include index/learn_block.html index=learn_block_index %}
11488
<div class="text">
11589
<h2>Easily manage and use over 500+ Python libraries.</h2>
11690
<div class="tagline">
@@ -136,39 +110,13 @@ <h2>Supported by all of the best microcontrollers</h2>
136110
<a href="{{ "downloads" | relative_url }}">See them all</a>
137111
</div>
138112
</div>
139-
<div class="image">
140-
{% assign guide = site.data.guides | sample %}
141-
<img class="image-headline" alt="{{ guide.image_alt_attribute }}"
142-
src="{{ guide.image }}"
143-
/>
144-
<span class="image-title">
145-
<span>
146-
<p><a href="{{ guide.guide_url }}">{{ guide.title }} by {{ guide.author }}</a></p>
147-
</span>
148-
<img alt="Made with CircuitPython Logo"
149-
src="{{ "assets/images/made_with_circuitpython.svg" |
150-
relative_url }}"
151-
/>
152-
</span>
153-
</div>
113+
{% assign learn_block_index = learn_block_index | plus: 1 %}
114+
{% include index/learn_block.html index=learn_block_index %}
154115
</div>
155116

156117
<div class="two-column-content">
157-
<div class="image">
158-
{% assign guide = site.data.guides | sample %}
159-
<img class="image-headline" alt="{{ guide.image_alt_attribute }}"
160-
src="{{ guide.image }}"
161-
/>
162-
<span class="image-title">
163-
<span>
164-
<p><a href="{{ guide.guide_url }}">{{ guide.title }} by {{ guide.author }}</a></p>
165-
</span>
166-
<img alt="Made with CircuitPython Logo"
167-
src="{{ "assets/images/made_with_circuitpython.svg" |
168-
relative_url }}"
169-
/>
170-
</span>
171-
</div>
118+
{% assign learn_block_index = learn_block_index | plus: 1 %}
119+
{% include index/learn_block.html index=learn_block_index %}
172120
<div class="text">
173121
<h2>CircuitPython libraries on single board computers</h2>
174122
<div class="tagline">

0 commit comments

Comments
 (0)