Skip to content

Commit 0b02252

Browse files
pages and tag generator plugin.
1 parent 0ef0207 commit 0b02252

File tree

19 files changed

+445
-39
lines changed

19 files changed

+445
-39
lines changed

_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ url: "https://nhsdigital.github.io" # the base hostname & protocol for your site
3030
twitter_username: jekyllrb
3131
github_username: jekyll
3232

33+
plugins_dir: _plugins
34+
#plugins:
35+
#- tags
36+
37+
safe: false
3338

3439
collections:
3540
safs:

_includes/prev_next/set_prev_next.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
{%- assign prev_site_order = site_order -%}
2424
{%- assign prev_url = query_page.url | relative_url -%}
2525
{%- assign prev_name = query_page.title -%}
26+
{%- if query_page.description -%}{%- assign prev_name = prev_name | append: ": " | append: query_page.description -%} {%- endif -%}
27+
2628
{%- elsif site_order > page_site_order and site_order < next_site_order -%}
2729
{%- assign next_site_order = site_order -%}
2830
{%- assign next_url = query_page.url | relative_url -%}
2931
{%- assign next_name = query_page.title -%}
3032

33+
{%- if query_page.description -%}{%- assign next_name = next_name | append: ": " | append: query_page.description -%} {%- endif -%}
34+
3135
{%- endif -%}
3236
{%- endfor -%}

_includes/saf.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
{%- if page.description -%}
44
<h1>{{ page.title }}: {{ page.description }}</a></h1>
55
<p><a href="{{ saf_dimension.url | relative_url }}">{{ saf_dimension.title }}</a></p>
6+
67
{%- else -%}
78
<h1>{{ page.title }}: <a href="{{ saf_dimension.url | relative_url }}">{{ saf_dimension.title }}</a> </h1>
89
{%- endif -%}
10+
11+
<p>{%- include prev_next/prev_next.md -%}</p>
912
{% include saf_content.html summary_only=false saf=page %}

_includes/tags.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,26 @@
22
{%- assign site_saf_dimensions = site.saf_dimensions -%}
33
{%- assign site_safs = site.safs -%}
44

5-
{% assign site_pages = site_pages_only | concat: site_saf_dimensions | concat: site_safs %}
5+
{% assign site_pages_all = site_pages_only | concat: site_saf_dimensions | concat: site_safs %}
6+
{% assign site_pages = site_safs %}
7+
8+
69

710
{% assign alldocs = site_pages %}
811

912
{% assign alltags = alldocs | map: 'tags' | join: ',' | split: ',' | where_exp: "item", "item != ''" | group_by_exp: "item", "item" %}
1013

14+
{% assign alltags = alltags | sort_natural: "size" | reverse %}
15+
1116
{%- for tag in alltags -%}
12-
<h3> {{tag.name}}: {{tag.size}}</h3>
17+
18+
{%- assign tag_path = "tags/" | append: tag.name -%}
19+
<h3> <a href="{{tag_path | relative_url}}"> {{tag.name}}</a>: {{tag.size}}</h3>
1320

1421
<ul>
1522
{%- for doc in site_pages -%}
1623
{%- if doc.tags contains tag.name -%}
17-
<li><a href="{{doc.url | relative_url}}">{{doc.title}}</a></li>
24+
<li><a href="{{doc.url | relative_url}}">{{doc.title}}{%- if doc.description -%}: {{doc.description}}{%- endif -%}</a></li>
1825
{%- endif -%}
1926
{%- endfor -%}
2027
</ul>

_layouts/saf.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
nhsnotify-side-nav__item--current
3131
{% endif %}
3232
">
33-
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: saf.url }}">{{ saf.title }}</a>
33+
{%- assign title = saf.title -%}
34+
{%- if saf.description -%}{%- assign title = title | append: ": " | append: saf.description -%} {%- endif -%}
35+
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: saf.url }}">{{ title }}</a>
36+
3437
</li>
3538
{% endfor %}
3639

_layouts/safs.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
nhsnotify-side-nav__item--current
5353
{% endif %}
5454
">
55-
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: saf.url }}">{{ saf.title }}</a>
55+
56+
{%- assign title = saf.title -%}
57+
{%- if saf.description -%}{%- assign title = title | append: ": " | append: saf.description -%} {%- endif -%}
58+
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: saf.url }}">{{ title }}</a>
59+
60+
5661
</li>
5762
{% endfor %}
5863
{% endfor %}

_plugins/tags.rb

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
module SamplePlugin
2+
class CategoryPageGenerator < Jekyll::Generator
3+
safe true
4+
5+
def generate(site)
6+
safs = site.collections['safs']
7+
saftags = safs.docs.map { |saf| saf.data['tags'] }
8+
flat = saftags.flatten
9+
10+
groups = flat.group_by{ |doc| doc }.map {|k,v| [k, v.length]}
11+
12+
sorted_groups = groups.sort_by {|k, v| [-v, k]}
13+
hashed_sorted_groups = sorted_groups.to_h
14+
15+
counter = 4.2
16+
hashed_sorted_groups.each do |group, count|
17+
site.pages << CategoryPage.new(site, group, count, counter)
18+
counter += 0.01
19+
20+
end
21+
22+
end
23+
end
24+
25+
# Subclass of `Jekyll::Page` with custom method definitions.
26+
class CategoryPage < Jekyll::Page
27+
def initialize(site, group, count, counter)
28+
#puts group
29+
@site = site # the current site instance.
30+
@base = site.source # path to the source directory.
31+
@dir = "tags"
32+
33+
# All pages have the same filename, so define attributes straight away.
34+
@basename = group # filename without the extension.
35+
@ext = '.html' # the extension.
36+
@name = group + '.html' # basically @basename + @ext.
37+
38+
@excerpt = nil
39+
40+
safs = site.collections['safs'].docs.map {|saf| saf.data['title']}
41+
42+
@data = {
43+
'linked_docs' => "",
44+
"layout" => "page",
45+
"title" => group,
46+
"nav_order" => counter,
47+
"tag_name" => group,
48+
"tag_count" => count,
49+
"safs" => safs,
50+
}
51+
@content = "<div>" + group + ": " + count.to_s + "</div>"
52+
53+
@content += "<div><ul>"
54+
site.collections['safs'].docs.each do |saf|
55+
if saf.data['tags'].include? group
56+
@content += "<li><a href=\"..#{saf.url}\">#{saf.data['title']}</a></li>"
57+
end
58+
end
59+
@content += "</ul></div>"
60+
end
61+
62+
# Placeholders that are used in constructing page URL.
63+
def url_placeholders
64+
{
65+
:path => @dir,
66+
:category => @dir,
67+
:basename => basename,
68+
:output_ext => output_ext,
69+
}
70+
end
71+
end
72+
end

_safs/dm/dm02.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
---
22
title: DM02
33
dimension: decisions
4-
tags: []
4+
tags: [spend,finops]
55
nav_order: 2.22
6-
---
76

8-
Relevant spend control and associated CDDO & Service Design related guidance **MUST** be followed whilst developing the solution **AND MUST** be evidenced for service design & spend control reviews
7+
description: Spend Control
8+
9+
requirement: |
10+
Relevant spend control and associated CDDO & Service Design related guidance **MUST** be followed whilst developing the solution and **MUST** be evidenced for service design & spend control reviews
11+
12+
more_info: |
13+
asd
14+
asd
15+
**asdasd**
16+
- asd
17+
- asd
18+
19+
asadasd
20+
21+
examples:
22+
- title: Example 01 - Working with big data
23+
content: |
24+
Something
25+
26+
technology:
27+
- title: Grafana
28+
content: |
29+
Using Grafana
30+
31+
further_reading:
32+
- title: Google
33+
content: |
34+
google.com
35+
url: https://www.google.com
36+
---

_safs/dm/dm03.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
---
22
title: DM03
33
dimension: decisions
4-
tags: []
4+
tags: [risks,issues,vibibility,ownership]
55
nav_order: 2.23
6-
---
76

8-
Architecture risks and issues **MUST** be managed effectively with the appropriate level of visibility and ownership
7+
description: Risk Management
8+
9+
requirement: |
10+
Architecture risks and issues **MUST** be managed effectively with the appropriate level of visibility and ownership
11+
12+
more_info: |
13+
asd
14+
asd
15+
**asdasd**
16+
- asd
17+
- asd
18+
19+
asadasd
20+
21+
examples:
22+
- title: Example 01 - Working with big data
23+
content: |
24+
Something
25+
26+
technology:
27+
- title: Grafana
28+
content: |
29+
Using Grafana
30+
31+
further_reading:
32+
- title: Google
33+
content: |
34+
google.com
35+
url: https://www.google.com
36+
---

_safs/dm/dm04.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
---
22
title: DM04
33
dimension: decisions
4-
tags: []
4+
tags: [involvement]
55
nav_order: 2.24
6-
---
76

8-
There **MUST** be effective and commensurate stakeholder involvement with respects to solution design and architecture decisions.
7+
description: Stakeholder Involvement
8+
9+
requirement: |
10+
There **MUST** be effective and commensurate stakeholder involvement with respects to solution design and architecture decisions.
11+
12+
more_info: |
13+
asd
14+
asd
15+
**asdasd**
16+
- asd
17+
- asd
18+
19+
asadasd
20+
21+
examples:
22+
- title: Example 01 - Working with big data
23+
content: |
24+
Something
25+
26+
technology:
27+
- title: Grafana
28+
content: |
29+
Using Grafana
30+
31+
further_reading:
32+
- title: Google
33+
content: |
34+
google.com
35+
url: https://www.google.com
36+
---

0 commit comments

Comments
 (0)