Skip to content

Commit 2e5594c

Browse files
committed
Indexes: add people index
make use of the newly linking syntax to create a new index for people and their relevant mentions in newsletters
1 parent 78bd0e6 commit 2e5594c

File tree

4 files changed

+155
-1
lines changed

4 files changed

+155
-1
lines changed

_config.yml

+8
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,18 @@ defaults:
6262
layout: topic
6363
permalink: /en/topics/:title/
6464
localizable: false
65+
- scope:
66+
path: "_people"
67+
values:
68+
layout: person
69+
permalink: /en/people/:title/
70+
localizable: false
6571

6672
collections:
6773
topics:
6874
output: true
75+
people:
76+
output: true
6977

7078
languages:
7179
- code: ja

_layouts/person.html

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
layout: post
3+
---
4+
{% capture newline %}
5+
{% endcapture %}
6+
{% capture /dev/null %}
7+
<!-- Get links for previous and next pages -->
8+
{% assign people_list = site.people | natural_sort: "title" %}
9+
{% capture first_link %}[{{people_list[0].title}}]({{people_list[0].url}}){% endcapture %}
10+
{% capture last_link %}[{{people_list[-1].title}}]({{people_list[-1].url}}){% endcapture %}
11+
{% for entry in people_list %}
12+
{% capture entry_link %}[{{entry.title}}]({{entry.url}}){% endcapture %}
13+
{% if prev_link %}
14+
{% assign next_link = entry_link %}
15+
{% break %}
16+
{% endif %}
17+
{% if entry.url == page.url %}
18+
{% assign prev_link = prev_entry | default: last_link %}
19+
{% endif %}
20+
{% assign prev_entry = entry_link %}
21+
{% endfor %}
22+
23+
<!-- Build list of primary sources -->
24+
{% for source in page.primary_sources %}
25+
{%- if source.link contains 'http://' or source.link contains 'https://' -%}
26+
{% capture reference %}[{{source.title}}]({{source.link}}){% endcapture %}
27+
{%- else -%}
28+
{% capture reference %}[{{source.title}}][{{source.link}}]{% endcapture %}
29+
{%- endif -%}
30+
{% capture primary_sources %}{{primary_sources}}{{newline}}- {{reference}}{% endcapture %}
31+
{% endfor %}
32+
33+
<!-- Build list of internal optech mentions -->
34+
{% assign references = '' %}
35+
{% for mention in page.optech_mentions %}
36+
{% if mention.feature == true %}
37+
{% assign bold = '{:.bold}' %}
38+
{% else %}
39+
{% assign bold='' %}
40+
{% endif %}
41+
{% include functions/get-mention-date.md %}
42+
{% capture references %}{{references}}{{date}}- [{{mention.title}}]({{mention.url}}){{bold}}ENDENTRY{% endcapture %}
43+
{% endfor %}
44+
45+
<!-- Build list of see also entries -->
46+
{% for source in page.see_also %}
47+
{%- if source.link contains 'http://' or source.link contains 'https://' -%}
48+
{% capture reference %}[{{source.title}}]({{source.link}}){% endcapture %}
49+
{%- else -%}
50+
{% capture reference %}[{{source.title}}][{{source.link}}]{% endcapture %}
51+
{%- endif -%}
52+
{% capture see_also %}{{see_also}}{{newline}}- {{reference}}{% endcapture %}
53+
{% endfor %}
54+
55+
<!-- Variable for use in links -->
56+
{% capture gh_base %}https://github.com/{{site.github_username}}/{{site.repository_name}}{% endcapture %}
57+
58+
{% endcapture %}
59+
60+
<!-- Actual page content -->
61+
{% capture content %}
62+
{% include references.md %}
63+
{{aliases}}
64+
65+
{{page.excerpt}}
66+
67+
{{page.content}}
68+
69+
{{notices | default: newline}}
70+
71+
{%- if page.optech_mentions and page.optech_mentions != '' -%}
72+
## Optech newsletter mentions
73+
74+
{% assign sorted_references = references | split: 'ENDENTRY' | sort | reverse %}
75+
{%- for reference in sorted_references -%}
76+
{%- assign current_ref_year = reference | slice: 0, 4 -%}
77+
{%- if current_ref_year != last_ref_year -%}
78+
{{newline}}{{newline}}**{{current_ref_year}}**
79+
{%- endif -%}
80+
{{newline}}{{reference | slice: 10, 9999999999 }}
81+
{%- assign last_ref_year = current_ref_year -%}
82+
{%- endfor -%}
83+
{% endif %}{{newline}}{{newline}}
84+
85+
{%- if page.see_also and page.see_also != '' -%}
86+
## See also
87+
88+
{{see_also}}
89+
{% endif %}
90+
91+
<br>{{newline}}{{newline}}
92+
<span class="float-left" markdown="1">**Previous Person:**<br>{{prev_link}}</span>
93+
<span class="float-right" markdown="1">**Next Person:**<br>{{next_link | default: first_link }}</span>
94+
95+
{:.center}
96+
[Edit page]({{gh_base}}/edit/master/{{page.path}})<br>
97+
[Report Issue]({{gh_base}}/issues/new?body={{'Source file: ' | append: page.path | url_escape }})
98+
{% endcapture %}{{ content | markdownify }}

_plugins/bidirectional_links_generator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def generate(site)
1616
# of all the pages
1717
pages_with_link_syntax = all_pages.select { |page| page.content.match(/\[\[.*?\]\]/) }
1818
# indexed pages are the only pages that newsletters might mention
19-
indexed_pages = site.collections["topics"].docs
19+
indexed_pages = site.collections["topics"].docs + site.collections["people"].docs
2020

2121
# Convert all Wiki/Roam-style double-bracket link syntax to plain HTML
2222
# anchor tag elements (<a>)

en/people.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: People
3+
permalink: /en/people/
4+
layout: page
5+
---
6+
{% capture raw_people_list %}
7+
{%- for person in site.people -%}
8+
<!--{% include functions/sort-rename.md name=topic.title %}-->[{{person.title}}]({{person.url}})ENDTOPIC
9+
{%- endfor -%}
10+
{% endcapture %}
11+
12+
{% assign people_list = raw_people_list | split: 'ENDTOPIC' | sort_natural %}
13+
{% assign number_of_people = site.people | size %}
14+
15+
<div class="center" markdown="1">
16+
{{number_of_people}} people
17+
18+
{:.center}
19+
{% assign previous_character = '' %}
20+
{% for entry in people_list %}
21+
{%- assign first_character = entry | remove_first: '<!--' | truncate: 1, '' | downcase -%}{%- comment -%}close html comment for syntax hilite -->{%- endcomment -%}
22+
{%- if first_character != previous_character -%}
23+
{%- if previous_character != nil -%}
24+
[{{first_character | upcase}}](#{{first_character}}){{' '}}
25+
{%- endif -%}
26+
{%- endif -%}
27+
{%- assign previous_character = first_character -%}
28+
{% endfor %}
29+
</div>
30+
31+
<div>{% comment %}<!-- enclosing in a div forces this to be interpreted
32+
as HTML rather than Markdown so indentation over 4 characters doesn't
33+
produce code blocks -->{% endcomment %}
34+
35+
{% assign previous_character = '' %}
36+
{% for entry in people_list %}
37+
{% assign first_character = entry | remove_first: '<!--' | truncate: 1, '' | downcase %}{%- comment -%}close html comment for syntax hilite -->{%- endcomment %}
38+
{% if first_character != previous_character %}
39+
{% if previous_character != '' %}</ul>{% endif %}
40+
<h3 id="{{first_character}}">{{first_character | upcase}}</h3>
41+
<ul>
42+
{% endif %}
43+
<li>{{entry | markdownify | remove: "<p>" | remove: "</p>" | strip }}</li>
44+
{% assign previous_character = first_character %}
45+
{% endfor %}
46+
</ul>
47+
48+
</div>

0 commit comments

Comments
 (0)