Skip to content

Commit a13817e

Browse files
authored
Merge pull request #18811 from github/move-html-into-include-files
Move HTML into include files
2 parents 98f4163 + e6b2aed commit a13817e

15 files changed

Lines changed: 60 additions & 48 deletions

File tree

content/actions/index.md

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,4 @@ versions:
4646
<!-- {% link_with_intro /creating-actions %} -->
4747
<!-- {% link_with_intro /using-github-hosted-runners %} -->
4848
<!-- {% link_with_intro /hosting-your-own-runners %} -->
49-
<!-- {% link_with_intro /reference %} -->
50-
51-
<!-- Code examples -->
52-
{% assign actionsCodeExamples = site.data.variables.action_code_examples %}
53-
{% if actionsCodeExamples %}
54-
<div class="my-6 pt-6">
55-
<h2 class="mb-2 font-mktg h1">Code examples</h2>
56-
57-
<div class="pr-lg-3 mb-5 mt-3">
58-
<input class="js-filter-card-filter input-lg py-2 px-3 col-12 col-lg-8 form-control" placeholder="Search code examples" type="search" autocomplete="off" aria-label="Search code examples"/>
59-
</div>
60-
61-
<div class="d-flex flex-wrap gutter">
62-
{% render code-example-card for actionsCodeExamples as example %}
63-
</div>
64-
65-
<button class="js-filter-card-show-more btn btn-outline float-right" data-js-filter-card-max="6">Show more {% octicon "arrow-right" %}</button>
66-
67-
<div class="js-filter-card-no-results d-none py-4 text-center color-text-secondary font-mktg">
68-
<div class="mb-3">{% octicon "search" width="24" %}</div>
69-
<h3 class="text-normal">Sorry, there is no result for <strong class="js-filter-card-value"></strong></h3>
70-
<p class="my-3 f4">It looks like we don't have an example that fits your filter.<br>Try another filter or add your code example</p>
71-
<a href="https://github.com/github/docs/blob/main/data/variables/action_code_examples.yml">Learn how to add a code example {% octicon "arrow-right" %}</a>
72-
</div>
73-
</div>
74-
{% endif %}
49+
<!-- {% link_with_intro /reference %} -->

content/discussions/index.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,3 @@ versions:
3434
<!-- {% link_with_intro /discussions-guides %} -->
3535
<!-- {% link_with_intro /collaborating-with-your-community-using-discussions %} -->
3636
<!-- {% link_with_intro /managing-discussions-for-your-community %} -->
37-
38-
<!-- Community examples -->
39-
{% assign discussionsCommunityExamples = site.data.variables.discussions_community_examples %}
40-
{% if discussionsCommunityExamples %}
41-
<div class="my-6 pt-6">
42-
<h2 class="mb-2 font-mktg h1">Communities using discussions</h2>
43-
44-
<div class="d-flex flex-wrap gutter">
45-
{% render discussions-community-card for discussionsCommunityExamples as example %}
46-
</div>
47-
{% if discussionsCommunityExamples.length > 6 %}
48-
<button class="js-filter-card-show-more btn btn-outline float-right" data-js-filter-card-max="6">Show more {% octicon "arrow-right" %}</button>
49-
{% endif %}
50-
<div class="js-filter-card-no-results d-none py-4 text-center color-text-secondary font-mktg">
51-
<div class="mb-3">{% octicon "search" width="24" %}</div>
52-
<h3 class="text-normal">Sorry, there is no result for <strong class="js-filter-card-value"></strong></h3>
53-
<p class="my-3 f4">It looks like we don't have an example that fits your filter.<br>Try another filter or add your code example</p>
54-
<a href="https://github.com/github/docs/blob/main/data/variables/discussions_community_examples.yml">Add your community {% octicon "arrow-right" %}</a>
55-
</div>
56-
</div>
57-
{% endif %}

data/ui.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ product_landing:
140140
quick_start: Quickstart
141141
reference_guides: Reference guides
142142
overview: Overview
143+
code_examples: Code examples
144+
search_code_examples: Search code examples
145+
show_more: Show more
146+
sorry: Sorry, there is no result for
147+
no_example: It looks like we don't have an example that fits your filter.
148+
try_another: Try another filter or add your code example.
149+
no_result: Sorry, there is no guide that match your filter.
150+
learn: Learn how to add a code example
151+
communities_using_discussions: Communities using discussions
152+
add_your_community: Add your community
143153
product_sublanding:
144154
start: Start
145155
start_path: Start path
@@ -149,7 +159,6 @@ product_sublanding:
149159
more_guides: more guides
150160
load_more: Load more guides
151161
all_guides: 'All {{ productMap[currentProduct].name }} guides'
152-
no_result: Sorry, there is no guide that match your filter.
153162
filters:
154163
type: Type
155164
topic: Topic

includes/code-examples.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="my-6 pt-6">
2+
<h2 class="mb-2 font-mktg h1">{% data ui.product_landing.code_examples %}</h2>
3+
4+
<div class="pr-lg-3 mb-5 mt-3">
5+
<input class="js-filter-card-filter input-lg py-2 px-3 col-12 col-lg-8 form-control" placeholder="{% data ui.product_landing.search_code_examples %}" type="search" autocomplete="off" aria-label="Search code examples"/>
6+
</div>
7+
8+
<div class="d-flex flex-wrap gutter">
9+
{% render code-example-card for productCodeExamples as example %}
10+
</div>
11+
12+
<button class="js-filter-card-show-more btn btn-outline float-right" data-js-filter-card-max="6">{% data ui.product_landing.show_more %} {% octicon "arrow-right" %}</button>
13+
14+
<div class="js-filter-card-no-results d-none py-4 text-center color-text-secondary font-mktg">
15+
<div class="mb-3">{% octicon "search" width="24" %}</div>
16+
<h3 class="text-normal">{% data ui.product_landing.sorry %} <strong class="js-filter-card-value"></strong></h3>
17+
<p class="my-3 f4">{% data ui.product_landing.no_result %}<br>{% data ui.product_landing.try_another %}</p>
18+
<a href="https://github.com/github/docs/blob/main/data/variables/actions_code_examples.yml">{% data ui.product_landing.learn %} {% octicon "arrow-right" %}</a>
19+
</div>
20+
</div>

includes/community-examples.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="my-6 pt-6">
2+
<h2 class="mb-2 font-mktg h1">{% data ui.product_landing.communities_using_discussions %}</h2>
3+
4+
<div class="d-flex flex-wrap gutter">
5+
{% render discussions-community-card for productCommunityExamples as example %}
6+
</div>
7+
{% if productCommunityExamples.length > 6 %}
8+
<button class="js-filter-card-show-more btn btn-outline float-right" data-js-filter-card-max="6">{% data ui.product_landing.show_more %} {% octicon "arrow-right" %}</button>
9+
{% endif %}
10+
<div class="js-filter-card-no-results d-none py-4 text-center color-text-secondary font-mktg">
11+
<div class="mb-3">{% octicon "search" width="24" %}</div>
12+
<h3 class="text-normal">{% data ui.product_landing.sorry %} <strong class="js-filter-card-value"></strong></h3>
13+
<p class="my-3 f4">{% data ui.product_landing.no_example %} <br>{% data ui.product_landing.try_another %}</p>
14+
<a href="https://github.com/github/docs/blob/main/data/variables/discussions_community_examples.yml">{% data ui.product_landing.add_your_community %} {% octicon "arrow-right" %}</a>
15+
</div>
16+
</div>

layouts/product-landing.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ <h4>{{ link.title }} <span class="Bump-link-symbol">→</span></h4>
117117
{% endif %}
118118
</div>
119119

120+
{% if productCodeExamples %}
121+
{% include code-examples %}
122+
{% endif %}
123+
124+
{% if productCommunityExamples %}
125+
{% include community-examples %}
126+
{% endif %}
127+
120128
{{ renderedPage }}
121129
</div>
122130

middleware/context.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ module.exports = async function contextualize (req, res, next) {
5151
req.context.siteTree = siteTree
5252
req.context.pages = pageMap
5353

54+
if (productMap[req.context.currentProduct]) {
55+
req.context.productCodeExamples = req.context.site.data.variables[`${productMap[req.context.currentProduct].id}_code_examples`]
56+
req.context.productCommunityExamples = req.context.site.data.variables[`${productMap[req.context.currentProduct].id}_community_examples`]
57+
}
58+
5459
// JS + CSS asset paths
5560
req.context.builtAssets = builtAssets
5661

translations/de-DE/data/variables/action_code_examples.yml renamed to translations/de-DE/data/variables/actions_code_examples.yml

File renamed without changes.

translations/es-ES/data/variables/action_code_examples.yml renamed to translations/es-ES/data/variables/actions_code_examples.yml

File renamed without changes.

0 commit comments

Comments
 (0)