Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/_default/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ cta:
# Footer
footer_logo: "/images/colored-logo.png"
copyright_text: "© Neurodata Without Borders - All Rights Reserved"

# Search results and link previews, for pages that have no description or
# image of their own
description: "Neurodata Without Borders (NWB) is a data standard and software ecosystem for neurophysiology and behavioral data."
shareImage: "/images/share-card.jpg"
1 change: 1 addition & 0 deletions layouts/partials/essentials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{{ partial "essentials/metadata.html" . }}

{{/* Title */}}
<title>{{ if not .IsHome }}{{ .Title | plainify }} -{{ end }}{{ .Site.Title }}</title>
Expand Down
54 changes: 54 additions & 0 deletions layouts/partials/essentials/metadata.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{/*
Description and link preview tags.

The description is the first of these that is set: `description`, `summary`
(events) or `subtitle` (news) in the front matter, the start of the page
body, then `description` in config/_default/params.yaml.

The preview image is the page's `image` when it is a PNG or JPEG no wider
than 3.3:1. Wider logo strips lose most of their width when a preview crops
them, so those pages, like pages with a GIF or with no image, use
`shareImage` from the same file.
*/}}
{{ $title := site.Title }}
{{ if and .Title (not .IsHome) }}
{{ $title = .Title | plainify | htmlUnescape | replaceRE `\s+` " " }}
{{ end }}

{{ $description := .Params.description | default .Params.summary | default .Params.subtitle | default .Summary | default site.Params.description }}
{{ $description = $description | plainify | htmlUnescape | replaceRE `\s+` " " | truncate 200 }}
{{ $description = trim $description " " }}

{{ $image := site.Params.shareImage | absURL }}
{{ $largeImage := true }}
{{ with .Params.image }}
{{ if hasPrefix . "http" }}
{{ $image = . }}
{{ else }}
{{ $path := index (split . "#") 0 }}
{{ $file := printf "static%s" $path }}
{{ if and (findRE `(?i)\.(png|jpe?g)$` $path) (fileExists $file) }}
{{ $config := imageConfig $file }}
{{ $ratio := div (float $config.Width) $config.Height }}
{{ if le $ratio 3.3 }}
{{ $image = $path | absURL }}
{{ $largeImage = and (ge $ratio 1.5) (ge $config.Width 600) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

<meta name="description" content="{{ $description }}" />
<meta property="og:site_name" content="{{ site.Title }}" />
<meta property="og:title" content="{{ $title }}" />
<meta property="og:description" content="{{ $description }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:image" content="{{ $image }}" />
{{ if and .IsPage (eq .Section "news") }}
<meta property="og:type" content="article" />
{{ with .Date }}<meta property="article:published_time" content="{{ .Format "2006-01-02T15:04:05Z07:00" }}" />{{ end }}
{{ else }}
<meta property="og:type" content="website" />
{{ end }}
{{/* X reads the Open Graph tags above for everything except the card type. */}}
<meta name="twitter:card" content="{{ if $largeImage }}summary_large_image{{ else }}summary{{ end }}" />
Binary file added static/images/share-card.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading