Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo sync #1284

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions includes/all-articles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct] %}
{% assign maxArticles = 10 %}

<div class="py-6">
<h2 class="font-mktg mb-4">All {{ product.title }} docs</h2>

<div class="d-flex gutter flex-wrap">
{% for category in product.categories %}
{% unless category[1].standalone %}
<div class="col-12 col-lg-4 mb-6 height-full">
<h4 class="mb-3"><a href="/{{ currentLanguage }}{{ category[1].href }}">{{ category[1].title }}</a></h4>

{% if category[1].maptopics %}
<ul class="list-style-none">
{% for maptopic in category[1].maptopics %}
{% unless maptopic[1].hidden %}
{% assign numArticles = maptopic[1].articles | obj_size %}
<li>
<a class="text-gray-dark" href="/{{ currentLanguage }}{{ maptopic[1].href }}">{{ maptopic[1].title }}</a>
<ul class="sidebar-articles my-2">
{% for article in maptopic[1].articles %}
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"><a href="/{{ currentLanguage }}{{ article[1].href }}">{{ article[1].title }}</a></li>
{% endfor %}
</ul>
{% if numArticles > maxArticles %}
<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>
{% endif %}
</li>
{% endunless %}
{% endfor %}
</ul>
{% else %}
<ul class="list-style-none">
{% assign numArticles = category[1].articles | obj_size %}
{% for article in category[1].articles %}
<li class="mb-3 {% if forloop.index > maxArticles %}d-none{% endif %}"><a href="/{{ currentLanguage }}{{ article[1].href }}">{{ article[1].title }}</a></li>
{% endfor %}
</ul>
{% if numArticles > maxArticles %}
<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>
{% endif %}
{% endif %}
</div>
{% endunless %}
{% endfor %}
</div>
</div>
18 changes: 18 additions & 0 deletions javascripts/all-articles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Handles the client-side events for `includes/all-articles.html`.
*/
export default function allArticles () {
const buttons = document.querySelectorAll('button.js-all-articles-show-more')

for (const btn of buttons) {
btn.addEventListener('click', evt => {
// Show all hidden links
const hiddenLinks = evt.currentTarget.parentElement.querySelectorAll('li.d-none')
for (const link of hiddenLinks) {
link.classList.remove('d-none')
}
// Remove the button, since we don't need it anymore
evt.currentTarget.parentElement.removeChild(evt.currentTarget)
})
}
}
2 changes: 2 additions & 0 deletions javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import copyCode from './copy-code'
import { fillCsrf } from './get-csrf'
import initializeEvents from './events'
import filterCodeExamples from './filter-code-examples'
import allArticles from './all-articles'

document.addEventListener('DOMContentLoaded', async () => {
displayPlatformSpecificContent()
Expand All @@ -34,4 +35,5 @@ document.addEventListener('DOMContentLoaded', async () => {
copyCode()
initializeEvents()
filterCodeExamples()
allArticles()
})
4 changes: 4 additions & 0 deletions layouts/product-landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ <h2 class="font-mktg h1 mb-2">Guides</h2>
</div>
{% endif %}

<div class="container-xl px-3 px-md-6 mt-6">
{% include all-articles %}
</div>

<div class="border-top">
{% include small-footer %}
</div>
Expand Down
11 changes: 11 additions & 0 deletions lib/render-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ for (const tag in tags) {
renderContent.liquid.registerTag(tag, ExtendedMarkdown)
}

renderContent.liquid.registerFilters({
/**
* Like the `size` filter, but specifically for
* getting the number of keys in an object
*/
obj_size: (input) => {
if (!input) return 0
return Object.keys(input).length
}
})

module.exports = renderContent