forked from programminghistorian/ph-submissions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson-slug.html
29 lines (20 loc) · 1.2 KB
/
lesson-slug.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{% comment %}
This include takes a lesson page and returns the appropriate filename slug.
For en pages, the base url is used; for es pages, the assigned "redirect_from" value is used.
These slugs are used in several locations:
1. Generating lesson image links and URLs for en/es lesson index pages in _includes/lesson_describe.html
2. Finding the lesson avatar to display on the individual lesson page, generated by _layouts/lesson.html
3. Finding image paths for use within individual lesson and blog posts when using _includes/figure.html
Note that this inlude defaults to using the current "page" as its environment. This is great when generating slugs for the current page being generated.
However, when generating lesson links/avatars via _includes/lesson_describe.html for the lesson index pages, we need to explicitly pass lesson objects in a loop.
{% endcomment %}
{% if include.lesson %}
{% assign lessonobj = include.lesson %}
{% else %}
{% assign lessonobj = page %}
{% endif %}
{% if lessonobj.lang == 'en' %}
{% assign slug = lessonobj.url | remove_first: '/lessons/' | remove_first: '.html' %}
{% else %}
{% assign slug = lessonobj.redirect_from | remove_first:'/es/lessons/' %}
{% endif %}