Skip to content

Commit 6135e18

Browse files
authored
Merge pull request #8 from vsoch/add/tags
Adding tags syndication page and documentation for how to use it
2 parents c8da4ba + 6cc71f2 commit 6135e18

File tree

7 files changed

+38
-8
lines changed

7 files changed

+38
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Critical items to know are:
1414
- changed behaviour
1515

1616
## [master](https://github.com/vsoch/docsy-jekyll/tree/master)
17+
- tags page and option to link to it from post/docs tags (0.0.12)
1718
- adding search endpoint tags to docs (0.0.11)
1819
- adding site.url to config, making links in readme absolute (0.0.1)
1920
- start of theme (0.0.0)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.11
1+
0.0.12

_config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ color: "#30638e"
5555
# Build settings
5656
markdown: kramdown
5757

58-
# If you add tags to pages, you can link them to some external search
59-
# If you want to disable this, comment the URL.
60-
tag_search_endpoint: https://ask.cyberinfrastructure.org/search?q=
58+
# If you add tags to pages, define this variable to link them to some external search
59+
# If you want to link to tags locally on the site, leave this commented out
60+
# tag_search_endpoint: https://ask.cyberinfrastructure.org/search?q=
6161
tag_color: primary # danger, success, warning, primary, info, secondary
6262

6363
accentColor: red # purple, green, etc.

_data/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
children:
1616
- title: Quizzes
1717
url: "docs/extras/example-quiz"
18+
- title: Tags Page
19+
url: "tags"
1820
- title: "About"
1921
url: "about"
2022
- title: "News"

_docs/getting-started.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,7 @@ and then add them to the navigation by adding to the content of [_data/toc.yml](
353353

354354
#### Tags
355355

356-
If you include tags on a page, by default they won't link to anything. However,
357-
if you define a `tag_search_endpoint` url in your configuration file, by clicking
356+
If you include tags on a page, by default they will link to the [tags page]({{ site.url }}{{ site.baseurl }}/tags) on the site. However, if you define a `tag_search_endpoint` url in your configuration file, by clicking
358357
the tag, the user will be taken to this page to search for it. As an example,
359358
we define the current search endpoint to be Ask Cyberinfrastructure, and
360359
page tags link to a search on it:
@@ -375,4 +374,11 @@ tags:
375374
```
376375

377376
They are appended to the first h1 block, so generally your pages should have a header.
377+
If you comment out this variable, then each of your tags will link to it's appropriate
378+
spot on the tags page linked above.
379+
380+
```yaml
381+
#tag_search_endpoint: https://ask.cyberinfrastructure.org/search?q=
382+
tag_color: primary # danger, success, warning, primary, info, secondary
383+
```
378384

_includes/tags.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{% if site.tag_search_endpoint %}{% if page.tags %}<script>
2-
$('h1').first().append('<div>{% for tag in page.tags %}<span style="font-size:12px" class="badge badge-{{ site.tag_color }}"><a style="cursor:pointer; color:white" href="{{ site.tag_search_endpoint }}{{ tag }}">{{ tag }}</a></span>{% endfor %}</div>')</script>{% endif %}{% endif %}
1+
{% if page.tags %}<script>
2+
$('h1').first().append('<div>{% for tag in page.tags %}<span style="font-size:12px" class="badge badge-{{ site.tag_color }}"><a style="cursor:pointer; color:white" href="{% if site.tag_search_endpoint %}{{ site.tag_search_endpoint }}{{ tag }}{% else %}{{ site.url }}{{ site.baseurl }}/tags#{{ tag }} {% endif %}">{{ tag }}</a></span>{% endfor %}</div>')</script>{% endif %}

pages/tags.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Tags Index
3+
permalink: /tags/
4+
---
5+
6+
<h1 id="tags-index">Tags Index</h1>
7+
{% capture site_tags %}{% for tag in site.tags %}{% if tag %}{{ tag | first }}{% unless forloop.last %},{% endunless %}{% endif %}{% endfor %}{% endcapture %}{% assign docs_tags = "" %}{% for doc in site.docs %}{% assign ttags = doc.tags | join:',' | append:',' %}{% assign docs_tags = docs_tags | append:ttags %}{% endfor %}
8+
{% assign all_tags = site_tags | append:docs_tags %}{% assign tags_list = all_tags | split:',' | uniq | sort %}
9+
10+
{% for tag in tags_list %}{% if tag %}<h3 id="{{ tag | replace: '/', '-' }}" class="linked-section">{{ tag }}</h3>
11+
<div class="post-list" style="margin-bottom:40px">
12+
{% for post in site.tags[tag] %}<div class="tag-entry">
13+
<a href="{{- site.url -}}{{- post.url -}}">{{- post.title -}}</a>
14+
<time style="font-style:italic; float:right" datetime="{{- post.date | date_to_xmlschema -}}"> {{- post.date | date: "%B %d, %Y" -}}</time>
15+
</div>{%- endfor -%}
16+
{% for doc in site.docs %}{% if doc.tags contains tag %}
17+
<div class="tag-entry">
18+
<a href="{{- site.baseurl -}}{{- doc.url -}}">{{ doc.title }}</a>
19+
<time style="font-style:italic; float:right" datetime="{{- doc.date | date_to_xmlschema -}}"> {{- doc.date | date: "%B %d, %Y" -}}</time>
20+
</div>{% endif %}{% endfor %}
21+
</div>{% endif %}{%- endfor -%}

0 commit comments

Comments
 (0)