Skip to content

Commit 4023bce

Browse files
authored
chore(site): edit GitHub links from hyper contrib documents (#90)
Populate a new page field 'hyper_path' for copied contrib files. Conditionally link back to hyper if a 'hyper_path' is present, otherwise continue to reference hyperium.github.io (relevant for all collections besides contrib). Closes hyperium/hyper#3210
1 parent da1d0e4 commit 4023bce

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/contrib.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,25 @@ jobs:
3232
cp -a hyper/CONTRIBUTING.md hyper/docs/CONTRIBUTING.md
3333
3434
# Insert frontmatter borders, replace markdown header with
35-
# frontmatter title and insert layout: guide
35+
# frontmatter title and insert:
36+
# - layout: guide
37+
# - hyper_path: {path}
3638
- name: Convert doc titles to frontmatter
3739
run: |
3840
for f in hyper/docs/*.md; do
3941
sed -i -e '1i ---' \
4042
-e '1s/#/title:/' \
4143
-e '2i layout: guide' \
44+
-e "2i hyper_path: ${f:6}" \
4245
-e '2i ---' $f;
4346
done
4447
48+
# CONTRIBUTING.md is uniquely copied into the docs folder.
49+
# This adjustment links the correct source file.
50+
- name: Retain correct CONTRIBUTING.md path
51+
run: |
52+
sed -i -e '4s/docs\///' hyper/docs/CONTRIBUTING.md
53+
4554
# Use the hyper docs readme as the index page of contrib,
4655
# and insert permalink: /contrib/ in the frontmatter
4756
- name: Convert readme to index
@@ -71,8 +80,8 @@ jobs:
7180
continue
7281
fi
7382
74-
# lowercase filenames
75-
sed -i -e "s|${filename}|${filename,,}|g" $file;
83+
# lowercase filenames outside frontmatter
84+
sed -i -e "1,/^---$/!s|${filename}|${filename,,}|g" $file;
7685
7786
# match on the lowercased filename from here on
7887
lowercased=${filename,,}

_includes/footer.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
<div class="row">
44
<div class="col-sm-6 text-center text-sm-left text-muted">&copy; 2023 hyper</div>
55
<div class="col-sm-6 text-center text-sm-right">
6-
<a href="https://github.com/hyperium/hyperium.github.io/blob/master/{{ page.path }}">
7-
edit this page on github
8-
</a>
6+
{% if page.hyper_path %}
7+
<a href="https://github.com/hyperium/hyper/blob/master/{{ page.hyper_path }}">
8+
edit this page on github
9+
</a>
10+
{% else %}
11+
<a href="https://github.com/hyperium/hyperium.github.io/blob/master/{{ page.path }}">
12+
edit this page on github
13+
</a>
14+
{% endif %}
915
</div>
1016
</div>
1117
</div>

0 commit comments

Comments
 (0)