1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 04:45:22 -04:00

Google AMP support & switch to NPM builds (#14)

This commit is contained in:
Jake Jarvis 2019-11-19 15:23:16 -05:00 committed by GitHub
parent d42a00247f
commit d6ad47c57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 463 additions and 136 deletions

21
.editorconfig Normal file
View File

@ -0,0 +1,21 @@
# http://editorconfig.org
# this file is the top-most editorconfig file
root = true
# all files
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
# site content
[*.md]
trim_trailing_whitespace = false
# Hugo templates
[*.html]
insert_final_newline = false

3
.gitattributes vendored
View File

@ -1 +1,2 @@
misc/** filter=lfs diff=lfs merge=lfs -text
# Set default behavior to automatically normalize line endings.
* text=auto eol=lf

4
.gitignore vendored
View File

@ -2,4 +2,8 @@ public/
builds/
resources/
node_modules/
package-lock.json
yarn.lock
.DS_Store

View File

@ -1,7 +1,7 @@
{
"ignoredFiles": [
"misc/*",
"*.svg"
"*.svg",
"**/logo.*"
],
"aggressiveCompression": "false"
}

View File

@ -1,13 +1,26 @@
# Custom Hugo Extended fork, pre-built on GitHub Package Registry:
# https://hub.docker.com/r/jakejarvis/hugo-custom
# https://github.com/jakejarvis/hugo-custom/blob/master/Dockerfile
#
# Usage:
# docker build -t jarv.is:develop -f Dockerfile .
# docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop
# ...then open http://localhost:1313 for the live-refresh server.
FROM jakejarvis/hugo-custom:latest
FROM alpine:latest
ENV HUGO_VERSION 0.59.1
# remove/comment the following line completely to build with vanilla Hugo:
ENV HUGO_EXTENDED 1
# only install libc6-compat & libstdc++ if we're building extended Hugo
# https://gitlab.com/yaegashi/hugo/commit/22f0d5cbd6114210ba7835468facbdee60609aa2
RUN apk update && \
apk add --no-cache ca-certificates ${HUGO_EXTENDED:+libc6-compat libstdc++} && \
update-ca-certificates && \
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_EXTENDED:+extended_}${HUGO_VERSION}_Linux-64bit.tar.gz && \
wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt && \
grep hugo_${HUGO_EXTENDED:+extended_}${HUGO_VERSION}_Linux-64bit.tar.gz hugo_${HUGO_VERSION}_checksums.txt | sha256sum -c && \
tar xf hugo_${HUGO_EXTENDED:+extended_}${HUGO_VERSION}_Linux-64bit.tar.gz && \
mv ./hugo /usr/bin && \
chmod +x /usr/bin/hugo && \
rm -rf hugo_*
# verify everything's OK
RUN /usr/bin/hugo version

View File

@ -1,6 +1,6 @@
# 🏡  [jarv.is](https://jarv.is/)
[![Netlify Status](https://api.netlify.com/api/v1/badges/a7403a53-fd9d-44c0-a708-a84d9fc1454d/deploy-status)](https://app.netlify.com/sites/jakejarvis/deploys) [![GitHub repo size](https://img.shields.io/github/repo-size/jakejarvis/jarv.is)](https://github.com/jakejarvis/jarv.is) [![License](https://img.shields.io/github/license/jakejarvis/jarv.is?color=red)](LICENSE.md)
[![Netlify Status](https://api.netlify.com/api/v1/badges/a7403a53-fd9d-44c0-a708-a84d9fc1454d/deploy-status)](https://app.netlify.com/sites/jakejarvis/deploys) [![View website](https://img.shields.io/badge/view%20site-jarv.is-green)](https://jarv.is/) [![Hugo v0.59.1](https://img.shields.io/badge/hugo-v0.59.1-orange)](https://github.com/gohugoio/hugo) [![GitHub repo size](https://img.shields.io/github/repo-size/jakejarvis/jarv.is)](https://github.com/jakejarvis/jarv.is) [![License](https://img.shields.io/github/license/jakejarvis/jarv.is?color=red)](LICENSE.md) [![Twitter Follow](https://img.shields.io/twitter/follow/jakejarvis?label=Follow&style=social)](https://twitter.com/intent/user?screen_name=jakejarvis)
Personal website of [@jakejarvis](https://github.com/jakejarvis), created and deployed using the following:
@ -13,9 +13,9 @@ I keep an ongoing list of [blog post ideas](https://github.com/jakejarvis/jarv.i
## Running a local testing server with Docker
This site runs a [custom version](https://github.com/jakejarvis/hugo-custom) of [Hugo Extended](https://github.com/gohugoio/hugo) with a few (very opinionated) changes. To ensure consistency, the [`Dockerfile`](Dockerfile) in this repository will pull my Hugo [fork](https://github.com/jakejarvis/hugo-custom) (forked from `v0.53-DEV`, [gohugo/hugo@`a28865c`](https://github.com/gohugoio/hugo/tree/a28865cfc3e296cf0ddd0bd6c1368fcdb2154d0f) and pre-built on [Docker Hub](https://hub.docker.com/r/jakejarvis/hugo-custom) and [GitHub Package Registry](https://github.com/jakejarvis/hugo-custom/packages)) and run a live testing server.
This site is built with [Hugo extended](https://github.com/gohugoio/hugo). To ensure consistency and compatibility, the [`Dockerfile`](Dockerfile) in this repository will download and verify the Hugo binary ([v0.59.1](https://github.com/gohugoio/hugo/releases/tag/v0.59.1)) and run a live testing server.
Run [`./scripts/docker-server.sh`](scripts/docker-server.sh) from the root of this repository, or execute these Docker commands:
#### Usage:
```bash
docker build -t jarv.is:develop -f Dockerfile .
@ -31,4 +31,4 @@ docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop
Site content (everything in [`content/notes`](content/notes/)) is published under the [Creative Commons Attribution 4.0 International License](LICENSE.md) (CC-BY-4.0), which means that you can copy, redistribute, remix, transform, and build upon the content for any purpose as long as you give appropriate credit.
All code in this repository (like my [Hugo theme](layouts/)) is published under the [MIT license](https://opensource.org/licenses/MIT), except the customized Hugo fork in the [`Dockerfile`](Dockerfile) which retains Hugo's [original Apache-2.0 license](https://github.com/gohugoio/hugo/blob/master/LICENSE).
All code in this repository (like my [Hugo theme](layouts/)) is published under the [MIT license](https://opensource.org/licenses/MIT).

View File

@ -234,7 +234,7 @@ body#notes {
left: 0;
width: 100%;
height: 100%;
border: none;
border: 0;
display: inline-block;
}
}
@ -244,6 +244,10 @@ body#notes {
display: block;
}
iframe {
border: 0;
}
code {
// https://markdotto.com/2018/02/07/github-system-fonts/
font-family: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", "Courier", monospace;

View File

@ -37,12 +37,19 @@ disableAliases = true
[outputs]
home = ["HTML", "RSS", "MANIFEST", "REDIRECTS", "HEADERS"]
section = ["HTML"]
page = ["HTML", "AMP"]
[mediaTypes]
[mediaTypes."text/netlify"]
delimiter = ""
delimiter = ""
[outputFormats]
[outputFormats.AMP]
mediaType = "text/html"
basename = "amp"
path = "."
permalinkable = true
isHTML = true
[outputFormats.MANIFEST]
mediaType = "application/json"
baseName = "manifest"
@ -65,13 +72,13 @@ disableAliases = true
# options for resampling filters:
# https://github.com/disintegration/imaging#image-resizing
resampleFilter = "Linear"
quality = 100
quality = 75
[blackfriday]
hrefTargetBlank = true
nofollowLinks = true
noreferrerLinks = true
noopenerLinks = true # requires custom fork w/ custom blackfriday: https://github.com/jakejarvis/hugo/tree/noopener
# noopenerLinks = true # requires custom fork w/ custom blackfriday: https://github.com/jakejarvis/hugo/tree/noopener
plainIDAnchors = true
fractions = false

4
content/notes/_index.md Normal file
View File

@ -0,0 +1,4 @@
---
title: "Notes"
description: "Recent posts by Jake Jarvis."
---

View File

@ -31,7 +31,7 @@ I'm a _huge_ sucker for Kate McKinnon's spot-on impression of Warren on Saturday
Although the designer who selected this GIF likely had _thousands_ of choices when searching "[Bernie finger wagging GIF](https://www.google.com/search?q=Bernie+finger+wagging+GIF&tbm=isch&tbs=itp:animated)," the text beside it is well-written and funny — even though we both know putting a page at [berniesanders.com/zxcliaosid](https://berniesanders.com/zxcliaosid/) probably won't be a top priority of a President Sanders.
{{< video mp4="images/sanders.mp4" webm="images/sanders.webm" autoplay="1" loop="1" nocontrols="1" >}}
{{< video mp4="images/sanders.mp4" height="346" webm="images/sanders.webm" autoplay="1" loop="1" nocontrols="1" >}}
---
@ -47,7 +47,7 @@ Uncle Joe has a nice and simple 404 page. I like it, along with the Ray-Bans and
A ballsy move, considering Beto's infamous [DUI arrest](https://www.politifact.com/texas/statements/2019/mar/14/club-growth/beto-orourke-arrested-dwi-flee-scene/) in the '90s — but still a clever ask for a donation and a great use of a GIF, even if it's left over from his Senate campaign.
{{< video mp4="images/orourke.mp4" webm="images/orourke.webm" autoplay="1" loop="1" nocontrols="1" >}}
{{< video mp4="images/orourke.mp4" height="467" webm="images/orourke.webm" autoplay="1" loop="1" nocontrols="1" >}}
---
@ -55,7 +55,7 @@ A ballsy move, considering Beto's infamous [DUI arrest](https://www.politifact.c
Another clean and simple page with a top-notch GIF. It injected some emotion into visiting [kamalaharris.com/alskdjf](https://kamalaharris.com/alskdjf).
{{< video mp4="images/harris.mp4" webm="images/harris.webm" autoplay="1" loop="1" nocontrols="1" >}}
{{< video mp4="images/harris.mp4" height="512" webm="images/harris.webm" autoplay="1" loop="1" nocontrols="1" >}}
---

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Privacy Policy</title>
</head>
<body>
<p>We do not share personal information with third-parties nor do we store information we collect about your visit to this blog for use other than to analyze content performance through the use of cookies, which you can turn off at any time by modifying your Internet browser's settings. We are not responsible for the republishing of the content found on this blog on other Web sites or media without our permission. This privacy policy is subject to change without notice.</p>
<p><a href="{{ .Site.BaseURL }}">Return home.</a></p>
</body>
</html>

View File

@ -0,0 +1,178 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
<script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script>
<title>{{ .Title }} &ndash; {{ .Site.Title }}</title>
{{ with .OutputFormats.Get "html" }}<link rel="canonical" href="{{ .Permalink }}">{{ end }}
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
{{ hugo.Generator }}
<meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta name="author" content="{{ .Site.Author.name }}">
{{ partial "open-graph.html" . }}
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<style amp-custom>
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
background: #ffffff;
color: #222222;
}
a {
color: #0e6dc2;
}
hr {
width: 60%;
margin: 0.75em auto;
border: 1px solid #dddddd;
}
blockquote {
border-left: 5px solid #0e6dc2;
margin-left: 0.5em;
padding-left: 1em;
}
article {
font-size: 1rem;
line-height: 1.8rem;
padding: 0 20px;
}
h1.title {
text-align: center;
font-size: 2.2rem;
line-height: 3rem;
margin-top: 1rem;
margin-bottom: 0.25rem;
}
p.meta {
text-align: center;
margin: 0.25rem;
color: #777777;
}
p.meta a {
text-decoration: none;
color: #444444;
}
p.center, p.image, p.caption, p.video {
text-align: center;
}
header {
width: 100%;
border-bottom: 1px solid #bbbbbb;
}
nav {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 30px;
}
nav a {
text-decoration: none;
}
nav a#logo {
display: flex;
align-items: center;
color: #333333;
padding: 10px 0;
}
nav a#logo svg {
height: 45px;
width: 30px;
}
nav a#logo span {
margin-left: 16px;
font-size: 1.5rem;
font-weight: 500;
}
nav ul {
list-style: none;
display: flex;
align-items: center;
font-size: 1.5em;
line-height: 1;
padding: 0;
}
nav ul li {
width: 60px;
text-align: right;
}
footer {
width: 100%;
padding: 20px;
border-top: 1px solid #bbbbbb;
color: #555;
}
footer a {
text-decoration: none;
}
footer a.back-to-top {
position: absolute;
right: 20px;
}
code {
font-family: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", "Courier", monospace;
font-size: 0.9em;
padding: 0.2em;
background: #f4f4f4;
border: 1px solid #dddddd;
}
pre code {
display: block;
padding: 1em 1.5em;
margin: 1.4em 0;
line-height: 1.6;
border-left: 3px solid #0e6dc2;
max-width: 100%;
overflow-x: scroll;
page-break-inside: avoid;
object-fit: scale-down;
}
div.highlight span.k, div.highlight span.kc, div.highlight span.kd, div.highlight span.kp, div.highlight span.kr, div.highlight span.kt, div.highlight span.no { color: #03748a; }
div.highlight span.n, div.highlight span.bp, div.highlight span.nb, div.highlight span.ni, div.highlight span.fm, div.highlight span.nl, div.highlight span.nn, div.highlight span.py, div.highlight span.nv, div.highlight span.vc, div.highlight span.vg, div.highlight span.vi, div.highlight span.vm, div.highlight span.p { color: #111111; }
div.highlight span.na, div.highlight span.nc, div.highlight span.nd, div.highlight span.ne, div.highlight span.nf, div.highlight span.nx { color: #489c44; }
div.highlight span.err, div.highlight span.nt, div.highlight span.o, div.highlight span.ow, div.highlight span.kn { color: #e8003d; }
div.highlight span.l, div.highlight span.se, div.highlight span.m, div.highlight span.mb, div.highlight span.mf, div.highlight span.mh, div.highlight span.mi, div.highlight span.il, div.highlight span.mo { color: #8145ec; }
div.highlight span.ld, div.highlight span.s, div.highlight span.sa, div.highlight span.sb, div.highlight span.sc, div.highlight span.dl, div.highlight span.sd, div.highlight span.s2, div.highlight span.sh, div.highlight span.si, div.highlight span.sx, div.highlight span.sr, div.highlight span.s1, div.highlight span.ss { color: #c17005; }
div.highlight span.c, div.highlight span.ch, div.highlight span.cm, div.highlight span.c1, div.highlight span.cs, div.highlight span.cp, div.highlight span.cpf { color: #6b6859; }
div.highlight span.ge { font-style: italic; }
div.highlight span.gs { font-weight: bold; }
</style>
<link rel="icon" href="{{ "favicon-192.png" | absURL }}" sizes="192x192">
<link rel="icon" href="{{ "favicon-48.png" | absURL }}" sizes="48x48">
<link rel="icon" href="{{ "favicon-32.png" | absURL }}" sizes="32x32">
<link rel="icon" href="{{ "favicon-16.png" | absURL }}" sizes="16x16">
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}">
<link rel="alternate" type="application/rss+xml" href="{{ "index.xml" | absURL }}" title="{{ .Site.Title }} (RSS)">
<link rel="manifest" href="{{ "manifest.json" | absURL }}">
{{ partial "schema.html" . }}
</head>
<body>
<header>
<nav>
<a id="logo" href="{{ .Site.BaseURL }}" title="{{ .Site.Title }}">
{{ partial "logo.html" . }}
<span id="name">{{ .Site.Title }}</span>
</a>
<ul>
<li><a href="{{ .Site.BaseURL }}" title="Home">&#x1F3E0;</a></li>
<li><a href="{{ "notes/" | absURL }}" title="Notes">&#x1F4DD;</a></li>
<li><a href="&#x6D;&#x61;&#x69;&#x6C;&#x74;&#x6F;&#x3A;&#x6A;&#x61;&#x6B;&#x65;&#x40;&#x6A;&#x61;&#x72;&#x76;&#x2E;&#x69;&#x73;" title="Email Me">&#x1F48C;</a></li>
</ul>
</nav>
</header>
<article>
<h1 class="title">{{ .Title }}</h1>
<p class="meta">by <a class="author" href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a> on <a class="date" href="{{ .Permalink }}">{{ .Date.Format "January 2, 2006" }}</a></p>
{{ .Content }}
</article>
<footer>
Content by <a href="{{ .Site.BaseURL }}">{{ .Site.Author.name }}</a>, licensed under <a href="https://creativecommons.org/licenses/by/4.0/" title="Creative Commons Attribution 4.0 International" target="_blank" rel="noopener noreferrer nofollow">CC-BY-4.0</a>.
<a class="back-to-top" href="#top">↑ Back to top.</a>
</footer>
</body>
</html>
{{"<!--" | safeHTML}} {{ hugo.Environment }} {{"-->" | safeHTML}}
{{"<!--" | safeHTML}} {{ hugo.Version }} {{"-->" | safeHTML}}

View File

@ -0,0 +1,2 @@
<div id="commento"></div>
<script src="https://comments.jarv.is/js/commento.js"></script>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
{{"<!--\n ,,, ,,,\n ;\" ^; ;\" \",\n ; s$$$$$s ;\n , ss$$$$$$$ss ,\"\n ;$$$$$$$$$$$$$$$$\n $$$$$$$$$$$$$$$$$$ Hello, human. :)\n $$$$$\"\"\"$$$\"\"\"$$$$$$\n $$$$$ p\"$$$\"q $$$$$ https://jarv.is/humans.txt\n $$$$ .$$$$$. $$$$\n $$$$$$$$$$$$$$$$$\n \"$$$$\"*\"$$$$\"\n \"$$.$$\"\n-->" | safeHTML}}
<html lang="en">
<head>
@ -8,32 +8,7 @@
<meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta name="author" content="{{ .Site.Author.name }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="{{ .Title }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:type" content="{{ if .IsHome }}website{{ else }}article{{ end }}">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta property="og:image" content="{{ if .Params.image }}{{ .Permalink }}images/{{ .Params.image }}{{ else }}{{ "me.jpg" | absURL }}{{ end }}">
{{- if .IsPage }}
{{- if not .PublishDate.IsZero }}
<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTMLAttr }}">
{{- else if not .Date.IsZero }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTMLAttr }}">
{{- end }}
{{- with .Site.Author.facebook }}
<meta property="article:author" content="https://www.facebook.com/{{ . }}">{{ end }}
{{- with .Params.tags }}{{ range . }}
<meta property="article:tag" content="{{ . }}">{{ end }}{{ end }}
{{- end }}
<meta property="fb:admins" content="{{ .Site.Author.facebook_id }}">
<meta property="fb:app_id" content="{{ .Site.Params.facebook_app_id }}">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="{{ .Site.Params.domain }}">
<meta name="twitter:site" content="{{ .Site.Author.twitter }}">
<meta name="twitter:creator" content="{{ .Site.Author.twitter }}">
<meta name="twitter:dnt" content="on">
<meta name="twitter:widgets:csp" content="on">
{{ partial "open-graph.html" . }}
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<meta name="apple-mobile-web-app-title" content="{{ .Site.Title }}">
@ -49,6 +24,9 @@
<link rel="icon" href="{{ "favicon-16.png" | absURL }}" sizes="16x16">
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}">
<link rel="canonical" href="{{ .Permalink }}">
{{- if and (eq .Type "notes") (eq .Kind "page") }}{{ with .OutputFormats.Get "amp" }}
<link rel="amphtml" href="{{ .Permalink }}">
{{- end }}{{ end }}
<link rel="alternate" type="application/rss+xml" href="{{ "index.xml" | absURL }}" title="{{ .Site.Title }} (RSS)">
<link rel="author" href="{{ "humans.txt" | absURL }}">
</head>

View File

@ -0,0 +1,26 @@
<meta property="og:title" content="{{ .Title }}">
<meta property="og:site_name" content="{{ .Site.Title }}">
<meta property="og:type" content="{{ if .IsHome }}website{{ else }}article{{ end }}">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }}">
<meta property="og:image" content="{{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me.jpg" | absURL }}{{ end }}">
{{- if .IsPage }}
{{- if not .PublishDate.IsZero }}
<meta property="article:published_time" content="{{ .PublishDate.Format "2006-01-02T15:04:05-07:00" | safeHTMLAttr }}">
{{- else if not .Date.IsZero }}
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTMLAttr }}">
{{- end }}
{{- with .Site.Author.facebook }}
<meta property="article:author" content="https://www.facebook.com/{{ . }}">{{ end }}
{{- with .Params.tags }}{{ range . }}
<meta property="article:tag" content="{{ . }}">{{ end }}{{ end }}
{{- end }}
<meta property="fb:admins" content="{{ .Site.Author.facebook_id }}">
<meta property="fb:app_id" content="{{ .Site.Params.facebook_app_id }}">
<meta name="twitter:card" content="summary">
<meta name="twitter:domain" content="{{ .Site.Params.domain }}">
<meta name="twitter:site" content="{{ .Site.Author.twitter }}">
<meta name="twitter:creator" content="{{ .Site.Author.twitter }}">
<meta name="twitter:dnt" content="on">
<meta name="twitter:widgets:csp" content="on">

View File

@ -0,0 +1,38 @@
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"mainEntityOfPage": {{ with .OutputFormats.Get "html" }}{{ .Permalink }}{{ end }},
"headline": {{ .Title }},
"datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }},
"dateModified": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }},
"description": {{ if .Description }}{{ .Description }}{{ else }}{{ .Site.Params.description }}{{ end }},
"keywords": "{{ with .Params.tags }}{{ range $index, $tag := . }}{{ if gt $index 0 }}, {{ end }}{{ $tag }}{{ end }}{{ end }}",
"author": {
"@type": "Person",
"name": {{ .Site.Author.name }},
"url": {{ .Site.BaseURL }},
"image": {
"@type": "ImageObject",
"url": {{ "me.jpg" | absURL }},
"width": 320,
"height": 320
}
},
"publisher": {
"@type": "Organization",
"name": {{ .Site.Author.name }},
"url": {{ .Site.BaseURL }},
"logo": {
"@type": "ImageObject",
"url": {{ "favicon-512.png" | absURL }},
"width": 512,
"height": 512
}
},
"image": {
"@type": "ImageObject",
"url": {{ if .Params.image }}{{ (printf "%s%s%s" (.OutputFormats.Get "html").Permalink "images/" .Params.image ) }}{{ else }}{{ "me.jpg" | absURL }}{{ end }}
}
}
</script>

View File

@ -0,0 +1,7 @@
<amp-iframe
layout="responsive"
width="1200"
height="{{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}"
scrolling="no"
src="https://codepen.io/{{ .Get "username" }}/embed/{{ .Get "id" }}/?height={{ if .Get "height" }}{{ .Get "height" }}{{ else }}500{{ end }}&amp;theme-id=light&amp;default-tab={{ .Get "left-tab" }}{{ if .Get "right-tab" }},{{ .Get "right-tab" }}{{ end }}">
</amp-iframe>

View File

@ -0,0 +1 @@
<p class="center"><a href="https://github.com/{{ .Get "username" }}/{{ .Get "repo" }}" target="_blank" rel="noopener noreferrer nofollow">View on GitHub</a></p>

View File

@ -0,0 +1,40 @@
{{- $original := .Page.Resources.GetMatch (.Get "src") -}}
{{- .Scratch.Set "image" $original -}}
<!-- TODO: automatically pull max-width of page -->
{{- $maxWidth := 910 -}}
{{- $setWidth := 0 -}}
{{- if .Get "width" -}}
{{- $setWidth = (int (.Get "width")) -}}
{{- $retinaWidth := (mul $setWidth 2) -}}
{{- if gt $original.Width $retinaWidth -}}
{{- $finalWidth := (printf "%dx" $retinaWidth ) -}}
{{- .Scratch.Set "image" ($original.Resize $finalWidth) -}}
{{- end -}}
{{- else -}}
{{- $setWidth = $maxWidth -}}
{{- if gt $original.Width 1820 -}}
{{- .Scratch.Set "image" ($original.Resize "1820x") -}}
{{- end -}}
{{- end -}}
{{- $image := .Scratch.Get "image" -}}
{{- $origRatio := (div (float $image.Height) $image.Width) -}}
{{- $displayWidth := $setWidth -}}
{{- $displayHeight := (math.Ceil (mul $origRatio $setWidth)) -}}
<p class="image">
<amp-img
alt="{{ .Get "alt" }}"
src="{{ $image.Permalink }}"
width="{{ $displayWidth }}"
height="{{ $displayHeight }}"
layout="intrinsic"
>
</amp-img>
</p>
{{- with (.Get "caption") }}<p class="caption"><em>{{ . }}</em></p>{{ end -}}

View File

@ -7,7 +7,7 @@
{{- $maxWidth := 910 -}}
{{- $setWidth := 0 -}}
{{- if .Get "width" }}
{{- if .Get "width" -}}
{{- $setWidth = (int (.Get "width")) -}}
{{- $retinaWidth := (mul $setWidth 2) -}}
@ -24,7 +24,7 @@
{{- $image := .Scratch.Get "image" -}}
{{- $origRatio := (div (float $image.Height) $image.Width) }}
{{- $origRatio := (div (float $image.Height) $image.Width) -}}
{{- $displayWidth := $setWidth -}}
{{- $displayHeight := (math.Ceil (mul $origRatio $setWidth)) -}}

View File

@ -0,0 +1,9 @@
<p class="center">
<amp-twitter
width="375"
height="472"
layout="responsive"
data-tweetid="{{ index .Params 0 }}"
>
</amp-twitter>
</p>

View File

@ -0,0 +1,23 @@
{{- $video_webm := .Page.Resources.GetMatch (.Get "webm") -}}
{{- $video_mp4 := .Page.Resources.GetMatch (.Get "mp4") -}}
{{- $video_ogg := .Page.Resources.GetMatch (.Get "ogg") -}}
{{- $img_poster := .Page.Resources.GetMatch (.Get "poster") -}}
<p class="video">
<amp-video
layout="responsive"
width="{{ if .Get "width" }}{{ .Get "width" }}{{ else }}910{{ end }}"
height="{{ if .Get "height" }}{{ .Get "height" }}{{ else }}600{{ end }}"
{{- if .Get "poster" }} poster="{{ $img_poster.Permalink }}"{{ end }}
{{- if .Get "autoplay" }} autoplay{{ end }}
{{- if .Get "loop" }} loop{{ end }}
{{- if ne (.Get "nocontrols") "1" }} controls{{ end }}>
{{ if .Get "webm" }}<source src="{{ $video_webm.Permalink }}" type="video/webm">{{ end }}
{{ if .Get "mp4" }}<source src="{{ $video_mp4.Permalink }}" type="video/mp4">{{ end }}
{{ if .Get "ogg" }}<source src="{{ $video_ogg.Permalink }}" type="video/ogg">{{ end }}
<div fallback>
Your browser does not support HTML5 video. <a href="{{ $video_mp4.Permalink }}">Load the .mp4 video directly.</a>
</div>
</amp-video>
</p>

View File

@ -0,0 +1,8 @@
<p class="center">
<amp-youtube
data-videoid="{{ index .Params 0 }}"
layout="responsive"
width="480"
height="270"
></amp-youtube>
</p>

Binary file not shown.

View File

@ -1,8 +1,19 @@
# netlify.sh downloads Hugo fork and builds the site independently.
[build]
command = "./scripts/netlify-build.sh"
command = "npm run build"
publish = "public"
[context.production.environment]
HUGO_VERSION = "0.59.1"
HUGO_ENV = "production"
[context.deploy-preview]
command = "npm run build:preview"
publish = "public"
[context.deploy-preview.environment]
HUGO_VERSION = "0.59.1"
HUGO_ENV = "development"
# The most important headers and redirects are specified in the _headers and
# _redirects files generated by Hugo. These are additional custom rules.

38
package.json Normal file
View File

@ -0,0 +1,38 @@
{
"name": "jarv.is",
"version": "1.0.0",
"homepage": "https://jarv.is/",
"license": "MIT",
"private": true,
"author": {
"name": "Jake Jarvis",
"email": "jake@jarv.is",
"url": "https://github.com/jakejarvis"
},
"scripts": {
"build": "npm run hugo:build && npm run optimize",
"build:preview": "npm run hugo:build-dev && npm run optimize",
"hugo:build": "hugo --gc --cleanDestinationDir --verbose",
"hugo:build-dev": "HUGO_ENV=development hugo -e development -b $DEPLOY_PRIME_URL --gc --cleanDestinationDir --buildDrafts --buildFuture --verbose",
"hugo:serve": "hugo server --buildDrafts --buildFuture --port 1313 --bind=0.0.0.0 --verbose",
"docker:serve": "docker build -t jarv.is:develop -f Dockerfile . ; docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop",
"netlify:serve": "netlify dev --command 'npm run hugo:serve'",
"optimize": "npm run optimize:img",
"optimize:img": "find public/ -type d -exec imagemin {}/* --plugin=jpegoptim --plugin=pngquant --plugin=optipng --plugin=svgo --plugin=gifsicle --out-dir={} \\;",
"test": "hugo version; hugo env"
},
"dependencies": {},
"devDependencies": {
"imagemin-cli": "^5.0.0",
"imagemin-gifsicle": "^6.0.1",
"imagemin-jpegoptim": "^6.0.0",
"imagemin-optipng": "^7.1.0",
"imagemin-pngquant": "^8.0.0",
"imagemin-svgo": "^7.0.0",
"netlify-cli": "^2.21.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jakejarvis/jarv.is.git"
}
}

View File

@ -1,9 +0,0 @@
#!/bin/bash
# Make sure you run this script from the root of the site repository.
echo "Pull latest Docker image..."
docker pull jakejarvis/hugo-custom:latest
echo "Building Hugo from image..."
docker run -v $(pwd):/src jakejarvis/hugo-custom:latest --gc --cleanDestinationDir --verbose

View File

@ -1,13 +0,0 @@
#!/bin/bash
# Make sure you run this script from the root of the site repository.
echo "Pull latest base image..."
docker pull jakejarvis/hugo-custom:latest
echo "Building Docker image..."
docker build -t jarv.is:develop -f Dockerfile .
echo "Starting live Hugo server..."
echo "Will go live at: http://localhost:1313"
docker run -v $(pwd):/src -p 1313:1313 jarv.is:develop

View File

@ -1,52 +0,0 @@
#!/bin/bash
# only designed to run on Netlify's build image
# https://github.com/netlify/build-image
set -euo pipefail
BINDIR=$HOME/jj-bin
mkdir -p $BINDIR
# download latest forked Hugo extended binary
# https://github.com/jakejarvis/hugo-custom/releases
echo "Downloading Hugo..."
curl -sS -L https://github.com/jakejarvis/hugo-custom/releases/latest/download/hugo-extended -o $BINDIR/hugo-extended
chmod +x $BINDIR/hugo-extended
# download jpegoptim binary
echo "Downloading jpegoptim..."
curl -sS -L https://github.com/imagemin/jpegoptim-bin/raw/master/vendor/linux/jpegoptim -o $BINDIR/jpegoptim
chmod +x $BINDIR/jpegoptim
# download pngquant binary
echo "Downloading pngquant..."
curl -sS -L https://github.com/imagemin/pngquant-bin/raw/master/vendor/linux/x64/pngquant -o $BINDIR/pngquant
chmod +x $BINDIR/pngquant
# download optipng binary
echo "Downloading optipng..."
curl -sS -L https://github.com/imagemin/optipng-bin/raw/master/vendor/linux/x64/optipng -o $BINDIR/optipng
chmod +x $BINDIR/optipng
# make sure everything's OK
echo "Is Hugo ready?"
$BINDIR/hugo-extended version
# build Hugo site
echo "Building site..."
$BINDIR/hugo-extended --gc --cleanDestinationDir --verbose
# optimize images in publish directory
echo "Optimizing JPEGs..."
find ./public -iname "*.jp*" -print0 | xargs -0 $BINDIR/jpegoptim --max=80 --strip-all --quiet
echo "Optimizing PNGs..."
find ./public -iname "*.png" -print0 | xargs -0 $BINDIR/pngquant --quality=50-70 --speed 3 --ext=.png --force
find ./public -iname "*.png" -print0 | xargs -0 $BINDIR/optipng -o1 -force -strip all -quiet --
# remove binaries (kinda unsafe, but doesn't really matter b/c it's docker)
echo "Cleaning up binaries..."
rm -rf $BINDIR
echo "All done!"
exit 0