Skip to content

Commit 595ebd6

Browse files
Add layout for articles and standardize author bylines (#498)
- Add article.html layout for documentation articles - Move existing authors byline code to authors.html include - Replace byline code in post.html with new include - Use new include in article.html layout - Remove authors code from existing articles - Have articles use new article layout - Remove unneeded draft printing style from existing articles - Consolidate author byline CSS - Remove redundant article tag from page.html - Resolves #378
1 parent 886396f commit 595ebd6

File tree

7 files changed

+72
-189
lines changed

7 files changed

+72
-189
lines changed

_includes/authors.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="authors">
2+
{% for page_author in include.authors %}
3+
{% assign author = site.data.authors[page_author] %}
4+
{% if author.name %}
5+
<div class="byline">
6+
{% if author.gravatar %}
7+
<img src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=64&d=mp" alt="{{ author.name }}"/>
8+
{% elsif author.github %}
9+
<img src="https://www.github.com/{{ author.github }}.png?size=64" alt="{{ author.name }}"/>
10+
{% else %}
11+
<img src="https://www.gravatar.com/avatar/dummy?s=64&d=mp&f=y" alt="{{ author.name }}"/>
12+
{% endif %}
13+
<span class="author">
14+
{% if author.github %}
15+
<a href="https://github.com/{{ author.github }}/" rel="nofollow" title="{{ author.name }} (@{{ author.github}}) on GitHub">{{ author.name }}</a>
16+
{% elsif author.twitter %}
17+
<a href="https://twitter.com/{{ author.twitter }}/" rel="nofollow" title="{{ author.name }} (@{{ author.twitter}}) on Twitter">{{ author.name }}</a>
18+
{% else %}
19+
{{ author.name }}
20+
{% endif %}
21+
</span>
22+
</div>
23+
{% if page.about %}
24+
{% assign about = page.about %}
25+
{% elsif author.about %}
26+
{% assign about = author.about %}
27+
{% endif %}
28+
{% if about %}
29+
<div class="about">{{ about }}</div>
30+
{% endif %}
31+
{% endif %}
32+
{% endfor %}
33+
</div>

_layouts/article.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: page
3+
---
4+
{{ content }}
5+
<hr>
6+
<p>Contributed by</p>
7+
{% include authors.html authors=page.author %}

_layouts/page.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
layout: default
33
---
44

5-
<article class="page">
65
<header>
76
<h1>{{ page.title }}</h1>
87
</header>
9-
10-
{{ content }}
11-
</article>
8+
{{ content }}

_layouts/post.html

+1-32
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,7 @@
77
<h1>{{ page.title }}</h1>
88

99
<time pubdate datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: "%B %-d, %Y" }}</time>
10-
{% for page_author in page.author %}
11-
{% assign author = site.data.authors[page_author] %}
12-
{% if author.name %}
13-
<div class="byline">
14-
{% if author.gravatar %}
15-
<img src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=64&d=mp" alt="{{ author.name }}"/>
16-
{% elsif author.github %}
17-
<img src="https://www.github.com/{{ author.github }}.png?size=64" alt="{{ author.name }}"/>
18-
{% else %}
19-
<img src="https://www.gravatar.com/avatar/dummy?s=64&d=mp&f=y" alt="{{ author.name }}"/>
20-
{% endif %}
21-
22-
<span class="author">
23-
{% if author.github %}
24-
<a href="https://github.com/{{ author.github }}/" rel="nofollow" title="{{ author.name }} (@{{ author.github}}) on GitHub">{{ author.name }}</a>
25-
{% elsif author.twitter %}
26-
<a href="https://twitter.com/{{ author.twitter }}/" rel="nofollow" title="{{ author.name }} (@{{ author.twitter}}) on Twitter">{{ author.name }}</a>
27-
{% else %}
28-
{{ author.name }}
29-
{% endif %}
30-
</span>
31-
</div>
32-
{% if page.about %}
33-
{% assign about = page.about %}
34-
{% elsif author.about %}
35-
{% assign about = author.about %}
36-
{% endif %}
37-
{% if about %}
38-
<div class="about">{{ about }}</div>
39-
{% endif %}
40-
{% endif %}
41-
{% endfor %}
10+
{% include authors.html authors=page.author %}
4211
</header>
4312

4413
{{ content }}

assets/stylesheets/_screen.scss

+28-56
Original file line numberDiff line numberDiff line change
@@ -487,36 +487,6 @@ article {
487487
padding-bottom: 0.125em;
488488
}
489489

490-
.byline {
491-
font-size: 14px;
492-
margin-bottom: 1em;
493-
494-
img {
495-
width: 32px;
496-
height: 32px;
497-
border-radius: 50%;
498-
border: 1px var(--color-fill-gray) solid;
499-
position: absolute;
500-
margin-right: 0.25em;
501-
margin-top: -6px;
502-
}
503-
504-
span {
505-
padding-left: 42px;
506-
}
507-
}
508-
509-
.about {
510-
float: none;
511-
clear: both;
512-
font-size: 14px;
513-
font-weight: 400;
514-
color: var(--color-figure-gray-tertiary);
515-
border-left: 1px var(--color-figure-gray-tertiary) solid;
516-
margin: 23px 3em 23px 0;
517-
padding: 4px 0 4px 10px;
518-
}
519-
520490
time {
521491
display: block;
522492
text-transform: uppercase;
@@ -1097,32 +1067,34 @@ article {
10971067
text-align: center;
10981068
}
10991069

1100-
.article-byline {
1101-
font-size: 14px;
1102-
margin-bottom: 1em;
1103-
1104-
img {
1105-
width: 32px;
1106-
height: 32px;
1107-
border-radius: 50%;
1108-
border: 1px var(--color-fill-gray) solid;
1109-
position: absolute;
1110-
margin-right: 0.25em;
1111-
margin-top: -6px;
1070+
.authors {
1071+
.byline {
1072+
font-size: 14px;
1073+
margin-bottom: 1em;
1074+
1075+
img {
1076+
width: 32px;
1077+
height: 32px;
1078+
border-radius: 50%;
1079+
border: 1px var(--color-fill-gray) solid;
1080+
position: absolute;
1081+
margin-right: 0.25em;
1082+
margin-top: -6px;
1083+
}
1084+
1085+
span {
1086+
padding-left: 42px;
1087+
}
11121088
}
1113-
1114-
span {
1115-
padding-left: 42px;
1089+
1090+
.about {
1091+
float: none;
1092+
clear: both;
1093+
font-size: 14px;
1094+
font-weight: 400;
1095+
color: var(--color-figure-gray-tertiary);
1096+
border-left: 1px var(--color-figure-gray-tertiary) solid;
1097+
margin: 23px 3em 23px 0;
1098+
padding: 4px 0 4px 10px;
11161099
}
11171100
}
1118-
1119-
.article-about {
1120-
float: none;
1121-
clear: both;
1122-
font-size: 14px;
1123-
font-weight: 400;
1124-
color: var(--color-figure-gray-tertiary);
1125-
border-left: 1px var(--color-figure-gray-tertiary) solid;
1126-
margin: 23px 3em 23px 0;
1127-
padding: 4px 0 4px 10px;
1128-
}

documentation/articles/value-and-reference-types.md

+1-48
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: page
2+
layout: article
33
date: 2023-04-29 12:00:00
44
title: Value And Reference Types In Swift
55
author: [jamesdempsey]
@@ -133,50 +133,3 @@ This means a struct can contain an array of structs, maybe a dictionary of key v
133133
### Conclusion
134134
Understanding what value types and reference types are and the differences in how they behave is an important part of learning Swift and being able to reason about your code. The choice between the two often comes down to a choice between declaring a type as a `struct` or a `class`. You can learn more about structures and class in the [Structures and Classes](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/classesandstructures) chapter of *The Swift Programming Language*.
135135

136-
<style>
137-
@media only print {
138-
nav { display: none; }
139-
140-
article header h1::after {
141-
content: "DRAFT POST for Swift.org";
142-
display: block;
143-
font-size: 1.75rem;
144-
margin-top: .5em;
145-
color: crimson;
146-
font-weight: 600;
147-
}
148-
}
149-
</style>
150-
151-
<hr>
152-
Contributed by
153-
{% for page_author in page.author %}
154-
{% assign author = site.data.authors[page_author] %}
155-
{% if author.name %}
156-
<div class="article-byline">
157-
{% if author.gravatar %}
158-
<img src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=64&d=mp" alt="{{ author.name }}"/>
159-
{% else %}
160-
<img src="https://www.gravatar.com/avatar/dummy?s=64&d=mp&f=y" alt="{{ author.name }}"/>
161-
{% endif %}
162-
163-
<span class="author">
164-
{% if author.twitter %}
165-
<a href="https://twitter.com/{{ author.twitter }}/" rel="nofollow" title="{{ author.name }} (@{{ author.twitter}}) on Twitter">{{ author.name }}</a>
166-
{% elsif author.github %}
167-
<a href="https://github.com/{{ author.github }}/" rel="nofollow" title="{{ author.name }} (@{{ author.github}}) on GitHub">{{ author.name }}</a>
168-
{% else %}
169-
{{ author.name }}
170-
{% endif %}
171-
</span>
172-
</div>
173-
{% if page.about %}
174-
{% assign about = page.about %}
175-
{% elsif author.about %}
176-
{% assign about = author.about %}
177-
{% endif %}
178-
{% if about %}
179-
<div class="article-about">{{ about }}</div>
180-
{% endif %}
181-
{% endif %}
182-
{% endfor %}

documentation/articles/wrapping-c-cpp-library-in-swift.md

+1-49
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: page
2+
layout: article
33
date: 2023-11-08 12:00:00
44
title: Wrapping C/C++ Library in Swift
55
author: [etcwilde, ktoso, yim-lee]
@@ -352,51 +352,3 @@ public struct WriteOptions: ~Copyable {
352352

353353
The downside of non-copyable types is that currently they cannot be used in all contexts. For example in Swift 5.9 it is not possible to store a non-copyable type as a field, or pass them through closures (as the closure could be used many times, which would break the uniqueness that a non-copyable type needs to guarantee). The upside is that, unlike classes, no reference counting is performed on non-copyable types.
354354

355-
356-
<style>
357-
@media only print {
358-
nav { display: none; }
359-
360-
article header h1::after {
361-
content: "DRAFT POST for Swift.org";
362-
display: block;
363-
font-size: 1.75rem;
364-
margin-top: .5em;
365-
color: crimson;
366-
font-weight: 600;
367-
}
368-
}
369-
</style>
370-
371-
<hr>
372-
Contributed by
373-
{% for page_author in page.author %}
374-
{% assign author = site.data.authors[page_author] %}
375-
{% if author.name %}
376-
<div class="article-byline">
377-
{% if author.gravatar %}
378-
<img src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=64&d=mp" alt="{{ author.name }}"/>
379-
{% else %}
380-
<img src="https://www.gravatar.com/avatar/dummy?s=64&d=mp&f=y" alt="{{ author.name }}"/>
381-
{% endif %}
382-
383-
<span class="author">
384-
{% if author.twitter %}
385-
<a href="https://twitter.com/{{ author.twitter }}/" rel="nofollow" title="{{ author.name }} (@{{ author.twitter}}) on Twitter">{{ author.name }}</a>
386-
{% elsif author.github %}
387-
<a href="https://github.com/{{ author.github }}/" rel="nofollow" title="{{ author.name }} (@{{ author.github}}) on GitHub">{{ author.name }}</a>
388-
{% else %}
389-
{{ author.name }}
390-
{% endif %}
391-
</span>
392-
</div>
393-
{% if page.about %}
394-
{% assign about = page.about %}
395-
{% elsif author.about %}
396-
{% assign about = author.about %}
397-
{% endif %}
398-
{% if about %}
399-
<div class="article-about">{{ about }}</div>
400-
{% endif %}
401-
{% endif %}
402-
{% endfor %}

0 commit comments

Comments
 (0)