Skip to content

Commit eccd18a

Browse files
authored
repo sync
2 parents 41d90af + 7b31c08 commit eccd18a

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed

includes/all-articles.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct] %}
2+
{% assign maxArticles = 10 %}
3+
4+
<div class="py-6">
5+
<h2 class="font-mktg mb-4">All {{ product.title }} docs</h2>
6+
7+
<div class="d-flex gutter flex-wrap">
8+
{% for category in product.categories %}
9+
{% unless category[1].standalone %}
10+
<div class="col-12 col-lg-4 mb-6 height-full">
11+
<h4 class="mb-3"><a href="/{{ currentLanguage }}{{ category[1].href }}">{{ category[1].title }}</a></h4>
12+
13+
{% if category[1].maptopics %}
14+
<ul class="list-style-none">
15+
{% for maptopic in category[1].maptopics %}
16+
{% unless maptopic[1].hidden %}
17+
{% assign numArticles = maptopic[1].articles | obj_size %}
18+
<li>
19+
<a class="text-gray-dark" href="/{{ currentLanguage }}{{ maptopic[1].href }}">{{ maptopic[1].title }}</a>
20+
<ul class="sidebar-articles my-2">
21+
{% for article in maptopic[1].articles %}
22+
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"><a href="/{{ currentLanguage }}{{ article[1].href }}">{{ article[1].title }}</a></li>
23+
{% endfor %}
24+
</ul>
25+
{% if numArticles > maxArticles %}
26+
<button class="js-all-articles-show-more btn-link link-gray">Show {{ numArticles | minus: maxArticles }} more {% octicon "chevron-up" class="v-align-text-bottom" %}</button>
27+
{% endif %}
28+
</li>
29+
{% endunless %}
30+
{% endfor %}
31+
</ul>
32+
{% else %}
33+
<ul class="list-style-none">
34+
{% assign numArticles = category[1].articles | obj_size %}
35+
{% for article in category[1].articles %}
36+
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"><a href="/{{ currentLanguage }}{{ article[1].href }}">{{ article[1].title }}</a></li>
37+
{% endfor %}
38+
</ul>
39+
{% if numArticles > maxArticles %}
40+
<button class="js-all-articles-show-more btn-link link-gray">Show {{ numArticles | minus: maxArticles }} more {% octicon "chevron-up" class="v-align-text-bottom" %}</button>
41+
{% endif %}
42+
{% endif %}
43+
</div>
44+
{% endunless %}
45+
{% endfor %}
46+
</div>
47+
</div>

javascripts/all-articles.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Handles the client-side events for `includes/all-articles.html`.
3+
*/
4+
export default function allArticles () {
5+
const buttons = document.querySelectorAll('button.js-all-articles-show-more')
6+
7+
for (const btn of buttons) {
8+
btn.addEventListener('click', evt => {
9+
// Show all hidden links
10+
const hiddenLinks = evt.currentTarget.parentElement.querySelectorAll('li.d-none')
11+
for (const link of hiddenLinks) {
12+
link.classList.remove('d-none')
13+
}
14+
// Remove the button, since we don't need it anymore
15+
evt.currentTarget.parentElement.removeChild(evt.currentTarget)
16+
})
17+
}
18+
}

javascripts/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import copyCode from './copy-code'
1616
import { fillCsrf } from './get-csrf'
1717
import initializeEvents from './events'
1818
import filterCodeExamples from './filter-code-examples'
19+
import allArticles from './all-articles'
1920

2021
document.addEventListener('DOMContentLoaded', async () => {
2122
displayPlatformSpecificContent()
@@ -34,4 +35,5 @@ document.addEventListener('DOMContentLoaded', async () => {
3435
copyCode()
3536
initializeEvents()
3637
filterCodeExamples()
38+
allArticles()
3739
})

layouts/product-landing.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ <h2 class="font-mktg h1 mb-2">Guides</h2>
9898
</div>
9999
{% endif %}
100100

101+
<div class="container-xl px-3 px-md-6 mt-6">
102+
{% include all-articles %}
103+
</div>
104+
101105
<div class="border-top">
102106
{% include small-footer %}
103107
</div>

lib/render-content.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@ for (const tag in tags) {
1818
renderContent.liquid.registerTag(tag, ExtendedMarkdown)
1919
}
2020

21+
renderContent.liquid.registerFilters({
22+
/**
23+
* Like the `size` filter, but specifically for
24+
* getting the number of keys in an object
25+
*/
26+
obj_size: (input) => {
27+
if (!input) return 0
28+
return Object.keys(input).length
29+
}
30+
})
31+
2132
module.exports = renderContent

0 commit comments

Comments
 (0)