Skip to content

Commit d9c336f

Browse files
authored
add custom popular heading to landing pages (#19147)
1 parent 6187dc4 commit d9c336f

4 files changed

Lines changed: 30 additions & 5 deletions

File tree

content/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ For a layout named `layouts/article.html`, the value would be `article`.
155155
- Type: `Object`.
156156
- Optional.
157157

158+
The list of popular links are the links displayed on the landing page under the title "Popular." Alternately, you can customize the title "Popular" by setting the `featuredLinks.popularHeading` property to a new string.
159+
158160
Example:
159161

160162
```yaml
@@ -163,6 +165,10 @@ featuredLinks:
163165
- /path/to/page
164166
guides:
165167
- /guides/example
168+
popular:
169+
- /path/to/popular/article1
170+
- /path/to/popular/article2
171+
popularHeading: An alternate heading to Popular
166172
```
167173

168174
### `showMiniToc`

includes/code-examples.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ <h2 class="mb-2 font-mktg h1" id="code-examples"><a href="#code-examples">{% dat
99
{% render code-example-card for productCodeExamples as example %}
1010
</div>
1111

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>
12+
{% if productCodeExamples.length > 6 %}
13+
<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>
14+
{% endif %}
1315

1416
<div class="js-filter-card-no-results d-none py-4 text-center color-text-secondary font-mktg">
1517
<div class="mb-3">{% octicon "search" width="24" %}</div>

layouts/product-landing.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ <h4 class="link-with-intro-title mb-1">{{ link.title }}<span class="Bump-link-sy
7171
</ul>
7272
</div>
7373

74+
{% if featuredLinks.popular %}
7475
<div class="col-12 col-lg-{% if page.changelog %}4{% else %}6{% endif %} mb-4 mb-lg-0">
7576
<div class="featured-links-heading mb-4 d-flex flex-items-baseline">
76-
<h3 class="f4 text-normal text-mono text-uppercase color-text-secondary" id="popular"><a href="#popular">{% data ui.toc.popular_articles %}</a></h3>
77+
<h3 class="f4 text-normal text-mono text-uppercase color-text-secondary" id="popular"><a href="#popular">{% if page.featuredLinks.popularHeading %}{{ page.featuredLinks.popularHeading }}{% else %}{% data ui.toc.popular_articles %}{% endif %}</a></h3>
7778
</div>
7879
<ul class="list-style-none">
7980
{% for link in featuredLinks.popular %}
@@ -85,6 +86,7 @@ <h2 class="link-with-intro-title f5">{{ link.title }}<span class="Bump-link-symb
8586
{% endfor %}
8687
</ul>
8788
</div>
89+
{% endif %}
8890

8991
{% if page.changelog %}
9092
<div class="col-12 col-lg-4 mb-4 mb-lg-0">

lib/frontmatter.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ const schema = {
7474
},
7575
featuredLinks: {
7676
type: 'object',
77-
additionalProperties: false,
78-
patternProperties: {
79-
'^[a-zA-Z-_]+$': {
77+
properties: {
78+
gettingStarted: {
79+
type: 'array',
80+
items: { type: 'string' }
81+
},
82+
guides: {
8083
type: 'array',
8184
items: { type: 'string' }
85+
},
86+
guideCards: {
87+
type: 'array',
88+
items: { type: 'string' }
89+
},
90+
popular: {
91+
type: 'array',
92+
items: { type: 'string' }
93+
},
94+
// allows you to use an alternate heading for the popular column
95+
popularHeading: {
96+
type: 'string'
8297
}
8398
}
8499
},

0 commit comments

Comments
 (0)