Skip to content

Commit

Permalink
Inline author data (linkerd#1898)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Porta <[email protected]>
  • Loading branch information
travisbeckham authored and Ivan Porta committed Dec 20, 2024
1 parent c4892cb commit d239079
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 65 deletions.
55 changes: 46 additions & 9 deletions linkerd.io/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Please do not put files in the `static` directory that are referenced on
linkerd.io. This directory is reserved for assets that are used as external
resources. If you need to add images for a page, please add them in the [page
bundle](https://gohugo.io/content-management/page-bundles/).
resources. If you need to add images for a page, please add them in the
[page bundle](https://gohugo.io/content-management/page-bundles/).

**Note:** Images in page bundles that have a width or height larger than 2400
pixels will be downsized.
Expand All @@ -27,9 +27,46 @@ date: # The date of your post in the format: `2024-01-01T00:00:00Z`
slug: # The URL slug for the page. Only set this param if you want to use a different slug than the title.
keywords: [] # An array of keywords are used to relate blog posts
params:
author: # The author id of the blog post. It must be an author from `data/authors.yaml`
author: # The author of the blog post
```
#### Assigning an author
There are 2 ways to assign an author to a blog post.
1. If the author has more than one blog post, the author data should be defined
in `data/authors.yaml`, then the author id can be set in the frontmatter
params. For example:

```yaml
params:
author: william
```

2. If the author is only going to have a single blog post, the author data can
be set inline if desired. For example:

```yaml
params:
author:
name: Author name
avatar: avatar.png
```

For inline author data, the avatar image can either be a page resource or a
remote image. To use a remote image, simply provide the full url to the image,
and Hugo will download and resize it when the site is published. For example:

```yaml
params:
author:
name: John Smith
avatar: https://example.com/avatars/john-smith.png
```

**Note:** If an author only has a single blog post, but there's a chance they
will have more in the future, please not use the inline method.

#### Cover, thumbnail, and feature images

To associate a cover, thumbnail, or feature image to a blog post, you do not
Expand All @@ -48,14 +85,14 @@ blog/

If a blog post is featured, by default, the cover image will be used on the blog
list page. If a cover image is not present, or you would like to use a different
image than the cover image, you can name it `feature` and place it in the
blog post folder.
image than the cover image, you can name it `feature` and place it in the blog
post folder.

If a thumbnail image is not present in the blog post folder, the thumbnail image
will be created from the cover image. By default, the thumbnail image will be
cropped and resized into a square. If you would like to maintaining the original
aspect ratio, you can set the `thumbnailProcess` frontmatter param to `fit`.
For example:
aspect ratio, you can set the `thumbnailProcess` frontmatter param to `fit`. For
example:

```yaml
params:
Expand Down Expand Up @@ -89,8 +126,8 @@ post is shared on social media. For example:
images: [social.png]
```

If the images array is empty, images with names matching `feature`, `cover`,
or `thumbnail` will be used in that order.
If the images array is empty, images with names matching `feature`, `cover`, or
`thumbnail` will be used in that order.

#### Markdown images

Expand Down
Binary file removed linkerd.io/assets/authors/courtney-gannon.jpg
Binary file not shown.
Binary file removed linkerd.io/assets/authors/george-miranda.jpg
Binary file not shown.
Binary file removed linkerd.io/assets/authors/jennifer-lankford.png
Binary file not shown.
Binary file removed linkerd.io/assets/authors/mohsen-rezaei.jpg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ description: |-
What if you could develop your applications alongside the very infrastructure they rely on in production?
keywords: [linkerd, tilt, nginx, orbstack, kubernetes, development]
params:
author: chris-campbell
author:
name: Chris Campbell, Linkerd Ambassador
avatar: chris-campbell.png
email: [email protected]
showCover: true
images: [social.png] # Open graph image
---
Expand Down
43 changes: 0 additions & 43 deletions linkerd.io/data/authors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ alex:
avatar: authors/alex-leong.jpg
email: [email protected]
name: Alex Leong
andrew:
email: [email protected]
name: Andrew Seigner
carol:
email: [email protected]
name: Carol Scott
Expand All @@ -20,38 +17,17 @@ charles:
avatar: authors/charles-pretzer.jpg
email: [email protected]
name: Charles Pretzer
chris-campbell:
avatar: authors/chris-campbell.png
email: [email protected]
name: Chris Campbell, Linkerd Ambassador
community:
email: [email protected]
name: Contributor
courtney:
avatar: authors/courtney-gannon.jpg
email: [email protected]
name: Courtney Gannon
dennis:
email: [email protected]
name: Dennis Adjei-Baah
eliza:
avatar: authors/eliza-weisman.jpg
email: [email protected]
name: Eliza Weisman
eren:
email: [email protected]
name: Eren
flynn:
avatar: authors/flynn.png
email: [email protected]
name: Flynn
franzi:
email: [email protected]
name: Franzi
gmiranda23:
avatar: authors/george-miranda.jpg
email: [email protected]
name: George Miranda
ivan:
avatar: authors/ivan-sim.jpg
email: [email protected]
Expand All @@ -60,13 +36,6 @@ jason:
avatar: authors/jason-morgan.png
email: [email protected]
name: Jason Morgan
jenlankford:
avatar: authors/jennifer-lankford.png
email: [email protected]
name: Jennifer Lankford
joe-fourkitchens:
email: [email protected]
name: Joe Tower (FourKitchens)
kiersten:
email: [email protected]
name: Kiersten Gaffney
Expand All @@ -82,21 +51,9 @@ matei:
name: Matei David
firstName: Matei
lastName: Matei David
mohsen:
avatar: authors/mohsen-rezaei.jpg
name: Mohsen Rezaei
oliver:
email: [email protected]
name: Oliver Gould
risha:
email: [email protected]
name: Risha Mars
sarah:
email: [email protected]
name: Sarah Brown
sterling:
email: [email protected]
name: Sterling White
steve:
avatar: authors/steve-jenson.jpg
email: [email protected]
Expand Down
48 changes: 37 additions & 11 deletions linkerd.io/layouts/blog/_meta-author.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
{{ $authorImg := "" }}
{{ $authorName := "" }}
{{ $authorRes := "" }}
{{ $authorImg := "" }}
{{ with .Params.author }}
{{ with index site.Data.authors . }}
{{ if (reflect.IsMap .) }}
{{/* Get author data from page params */}}
{{ $authorName = .name }}
{{ with .avatar }}
{{ with resources.GetMatch . }}
{{ with partial "utils/process-image" (dict
"res" .
"width" 96
"height" 96
"process" "fill center jpg q80 lanczos"
)}}
{{ $authorImg = .RelPermalink }}
{{ if hasPrefix . "http" }}
{{/* Avatar is a remote image */}}
{{ with resources.GetRemote . }}
{{ $authorRes = . }}
{{ else }}
{{ warnf "Unable to get remote resource %q" . }}
{{ end }}
{{ else }}
{{/* Otherwise avatar must be page resource */}}
{{ with $.Resources.GetMatch . }}
{{ $authorRes = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $authorName = .name }}
{{ else }}
{{/* Get author data from global data source */}}
{{ with index site.Data.authors . }}
{{ $authorName = .name }}
{{ with .avatar }}
{{/* Avatar must be global resource */}}
{{ with resources.GetMatch . }}
{{ $authorRes = . }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ with $authorRes }}
{{ with partial "utils/process-image" (dict
"res" .
"width" 96
"height" 96
"process" "fill center jpg q80 lanczos"
)}}
{{ $authorImg = .RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<div class="blog-post-meta">
Expand Down
6 changes: 6 additions & 0 deletions linkerd.io/layouts/blog/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@
<link>{{ .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with .Params.author }}
{{- if (reflect.IsMap .) }}
{{- /* Get author data from page params */}}
<author>{{ .name }}</author>
{{- else }}
{{- /* Get author data from global data source */}}
{{- with index site.Data.authors . }}
<author>{{ .name }}</author>
{{- end }}
{{- end }}
{{- end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | transform.XMLEscape | safeHTML }}</description>
</item>
Expand Down
8 changes: 7 additions & 1 deletion linkerd.io/layouts/partials/head-schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
{{ $scratch := newScratch }}
{{/* Get author name */}}
{{ with .Params.author }}
{{ with index site.Data.authors . }}
{{ if (reflect.IsMap .) }}
{{/* Get author data from page params */}}
{{ $scratch.Set "author" .name }}
{{ else }}
{{/* Get author data from global data source */}}
{{ with index site.Data.authors . }}
{{ $scratch.Set "author" .name }}
{{ end }}
{{ end }}
{{ end }}
{{/* Get cover image */}}
Expand Down
Binary file not shown.

0 comments on commit d239079

Please sign in to comment.