Skip to content

Commit c2ca9bd

Browse files
authored
Merge pull request ResearchObject#479 from elichad/add-related-use-cases-to-blog
Add related use cases to blog posts
2 parents c3648af + fa905f2 commit c2ca9bd

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

docs/_blog/.template.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: "Template for RO-Crate blog posts"
33
author: ["Eli Chadwick"]
44
date: 2025-06-12
5+
related_pages:
6+
use_cases: [page_id1, page_id2] # should match items in pages/use_cases
57
---
68

79
This template assumes you have some familiarity with Git, GitHub, and Markdown.
@@ -18,6 +20,7 @@ If you don't have those skills, but you'd like to contribute a post, you can wri
1820
1. Add a `title` for the post. This will be used as the first heading on the rendered page.
1921
1. Add `author`s to the array, separated by commas, e.g. `["Person A", "Person B"].
2022
1. Change the `date` to the intended publication date in `yyyy-mm-dd` format. This should match the name of the folder.
23+
1. Update the `use_cases` list to include the IDs of any related [use case pages](https://www.researchobject.org/ro-crate/use_cases). To find the ID of a page, go to its [Markdown file](https://github.com/ResearchObject/ro-crate/tree/main/docs/pages/use_cases) and copy the `page_id` from its front matter. Use cases referenced in this list will automatically appear at the end of the blog post.
2124

2225
## Writing the post
2326

docs/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ defaults:
7777
values:
7878
layout: "post"
7979
sidebar: blog
80+
type: blog_posts
8081

8182
- scope:
8283
path: "pages/about"

docs/_includes/related_use_cases.html

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
<h2>Related use cases</h2>
22

33
<!-- find use cases that match this entry -->
4-
{% assign all_use_cases = site.pages | where:"type", "use_cases" %}
5-
{% assign matched_cases = "" | split: "," %} <!-- hack to initialise an empty array -->
6-
{% for case in all_use_cases %}
7-
{% if page.type == "domains" %}
8-
{% assign metadata = case.domains %}
9-
{% elsif page.type == "tasks" %}
10-
{% assign metadata = case.tasks %}
11-
{% elsif page.type == "roles" %}
12-
{% assign metadata = case.roles %}
13-
{% endif %}
14-
{% if metadata contains page.page_id %}
15-
{% assign matched_cases = matched_cases | push: case.page_id %}
16-
{% endif %}
17-
{% endfor %}
4+
{% if page.type == "blog_posts" %}
5+
<!-- for blog posts the related use cases are set directly -->
6+
{% assign matched_cases = page.related_pages.use_cases %}
7+
{% else %}
8+
<!-- for domains/tasks/roles (DTR), the cross-links are set on the use case pages, -->
9+
<!-- so search all use case pages for those which connect to the desired DTR -->
10+
{% assign all_use_cases = site.pages | where:"type", "use_cases" %}
11+
{% assign matched_cases = "" | split: "," %} <!-- hack to initialise an empty array -->
12+
{% for case in all_use_cases %}
13+
{% if page.type == "domains" %}
14+
{% assign metadata = case.domains %}
15+
{% elsif page.type == "tasks" %}
16+
{% assign metadata = case.tasks %}
17+
{% elsif page.type == "roles" %}
18+
{% assign metadata = case.roles %}
19+
{% endif %}
20+
{% if metadata contains page.page_id %}
21+
{% assign matched_cases = matched_cases | push: case.page_id %}
22+
{% endif %}
23+
{% endfor %}
24+
{% endif %}
1825

1926
{% if matched_cases.size == 0 %}
2027
<p>No use cases found.</p>

docs/_includes/section-navigation-tiles.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<div class="px-3 pb-3 d-flex justify-content-between align-items-center">
8888
<h3 class="card-title ml-3">{{current_page.title}}</h3>
8989
{%- if current_page.image %}
90-
<img alt="logo of {{current_page.title}}" src="assets/img/{{current_page.image }}" class="d-inline tile-img-sm">
90+
<img alt="logo of {{current_page.title}}" src="{{site.baseurl}}/assets/img/{{current_page.image }}" class="d-inline tile-img-sm">
9191
{%- endif %}
9292
{%- if current_page.icon %}
9393
<i class="fa fa-2x {{ current_page.icon }}"></i>
@@ -154,7 +154,7 @@ <h3 class="card-title ml-3">{{current_page.title}}</h3>
154154
{%- elsif filter_affiliation %}
155155
<a role="button" href="{{filter_affiliation.url}}" data-bs-toggle="tooltip" data-bs-original-title="{{affiliation}}" class="btn btn-sm bg-white hover-primary">
156156
{%- if filter_affiliation.image_url %}
157-
<img alt="logo of {{filter_affiliation.name}}" src="{{filter_affiliation.image_url | relative_url }}" class="d-inline affiliation-img-sm">
157+
<img alt="logo of {{filter_affiliation.name}}" src="{{site.baseurl}}/{{filter_affiliation.image_url | relative_url }}" class="d-inline affiliation-img-sm">
158158
{%- else %}
159159
{{filter_affiliation.name}}
160160
{%- endif %}

docs/_layouts/post.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ <h1>{{ page.title }}</h1>
88
<hr>
99

1010
{{ content }}
11+
12+
{% include related_use_cases.html %}

0 commit comments

Comments
 (0)