site data, twitter/opengraph headers
This commit is contained in:
parent
42818405c1
commit
7cd73f703f
14 changed files with 52 additions and 16 deletions
|
@ -4,7 +4,9 @@ const md = require("markdown-it");
|
||||||
const mdAnchor = require("markdown-it-anchor");
|
const mdAnchor = require("markdown-it-anchor");
|
||||||
const mdFootnote = require("markdown-it-footnote");
|
const mdFootnote = require("markdown-it-footnote");
|
||||||
const prettier = require("prettier");
|
const prettier = require("prettier");
|
||||||
|
const dayjs = require("dayjs")
|
||||||
const clean = require("eleventy-plugin-clean");
|
const clean = require("eleventy-plugin-clean");
|
||||||
|
const site = require("./site/_data/site");
|
||||||
|
|
||||||
module.exports = (config) => {
|
module.exports = (config) => {
|
||||||
const slugify = config.getFilter("slugify");
|
const slugify = config.getFilter("slugify");
|
||||||
|
@ -21,10 +23,10 @@ module.exports = (config) => {
|
||||||
symbol: "",
|
symbol: "",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.use(mdFootnote)
|
.use(mdFootnote);
|
||||||
config.setLibrary("md", mdLib);
|
config.setLibrary("md", mdLib);
|
||||||
config.addPassthroughCopy({
|
config.addPassthroughCopy({
|
||||||
"assets": "/"
|
assets: "/",
|
||||||
});
|
});
|
||||||
|
|
||||||
// collection from music folder
|
// collection from music folder
|
||||||
|
@ -52,8 +54,8 @@ module.exports = (config) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
config.addTransform("prettier", (content, outputPath) => {
|
config.addTransform("prettier", (content, outputPath) => {
|
||||||
if (typeof outputPath !== 'string') {
|
if (typeof outputPath !== "string") {
|
||||||
return content
|
return content;
|
||||||
}
|
}
|
||||||
const extname = path.extname(outputPath);
|
const extname = path.extname(outputPath);
|
||||||
switch (extname) {
|
switch (extname) {
|
||||||
|
@ -66,7 +68,17 @@ module.exports = (config) => {
|
||||||
default:
|
default:
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
config.addFilter("absoluteURL", (url) => {
|
||||||
|
return new URL(url, site.baseUrl).href;
|
||||||
|
});
|
||||||
|
config.addFilter("toISOString", (dateString) => {
|
||||||
|
return new Date(dateString).toISOString()
|
||||||
|
});
|
||||||
|
config.addFilter("formatDate", (date, format) => {
|
||||||
|
return dayjs(date).format(format);
|
||||||
|
});
|
||||||
|
|
||||||
clean.updateFileRecord("dist");
|
clean.updateFileRecord("dist");
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@11ty/eleventy": "^2.0.1",
|
"@11ty/eleventy": "^2.0.1",
|
||||||
|
"dayjs": "^1.11.11",
|
||||||
"eleventy-plugin-clean": "^1.2.6",
|
"eleventy-plugin-clean": "^1.2.6",
|
||||||
"markdown-it-anchor": "^9.0.1",
|
"markdown-it-anchor": "^9.0.1",
|
||||||
"markdown-it-footnote": "^4.0.0",
|
"markdown-it-footnote": "^4.0.0",
|
||||||
|
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
|
@ -11,6 +11,9 @@ importers:
|
||||||
'@11ty/eleventy':
|
'@11ty/eleventy':
|
||||||
specifier: ^2.0.1
|
specifier: ^2.0.1
|
||||||
version: 2.0.1
|
version: 2.0.1
|
||||||
|
dayjs:
|
||||||
|
specifier: ^1.11.11
|
||||||
|
version: 1.11.11
|
||||||
eleventy-plugin-clean:
|
eleventy-plugin-clean:
|
||||||
specifier: ^1.2.6
|
specifier: ^1.2.6
|
||||||
version: 1.2.6(@11ty/eleventy@2.0.1)
|
version: 1.2.6(@11ty/eleventy@2.0.1)
|
||||||
|
@ -291,6 +294,9 @@ packages:
|
||||||
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
|
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
|
||||||
engines: {node: '>= 8'}
|
engines: {node: '>= 8'}
|
||||||
|
|
||||||
|
dayjs@1.11.11:
|
||||||
|
resolution: {integrity: sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
@ -1244,6 +1250,8 @@ snapshots:
|
||||||
shebang-command: 2.0.0
|
shebang-command: 2.0.0
|
||||||
which: 2.0.2
|
which: 2.0.2
|
||||||
|
|
||||||
|
dayjs@1.11.11: {}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.0.0
|
ms: 2.0.0
|
||||||
|
|
9
site/_data/site.js
Normal file
9
site/_data/site.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
const isDev = process.env.ELEVENTY_ENV === "development";
|
||||||
|
|
||||||
|
const baseUrl = isDev ? "localhost:8080" : "https://joshua.seigler.net/";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
title: "joshua.seigler.net",
|
||||||
|
description: "Personal homepage of Joshua Seigler",
|
||||||
|
baseUrl,
|
||||||
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
<header>
|
<header>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav-categories">
|
<div class="nav-categories">
|
||||||
<a href="{{ "/" | url }}">joshua.seigler.net</a>
|
<a href="{{ "/" | url }}">{{ site.title }}</a>
|
||||||
<a href="{{ "/posts" | url }}">/posts</a>
|
<a href="{{ "/posts" | url }}">/posts</a>
|
||||||
<a href="{{ "/timeline" | url }}">/timeline</a>
|
<a href="{{ "/timeline" | url }}">/timeline</a>
|
||||||
<a href="{{ "/recipes" | url }}">/recipes</a>
|
<a href="{{ "/recipes" | url }}">/recipes</a>
|
||||||
|
@ -31,8 +31,8 @@
|
||||||
{%-if author -%}
|
{%-if author -%}
|
||||||
<author>{{ author }}</author>
|
<author>{{ author }}</author>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- if dateString -%}
|
{%- if date -%}
|
||||||
<date>{{ dateString }}</date>
|
<date>{{ date | formatDate("MMMM D, YYYY") }}</date>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
---
|
---
|
||||||
title: Joshua's Homepage
|
title: Joshua's Homepage
|
||||||
---
|
---
|
||||||
|
{%- set computedTitle = tag | capitalize if tag else title -%}
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="stylesheet" href="{{ "/site.css" | url }}"/>
|
<link rel="stylesheet" href="{{ "/site.css" | url }}"/>
|
||||||
<title>{{ tag | capitalize if tag else title }} - joshua.seigler.net</title>
|
<title>{{ computedTitle }} - {{ site.title }}</title>
|
||||||
|
<meta property="og:title" content="{{ computedTitle }}" />
|
||||||
|
<meta property="og:type" content="{{ article }}" />
|
||||||
|
<meta property="og:url" content="{{ url | absoluteURL }}" />
|
||||||
|
{# <meta property="og:image" content="https://....jpg" /> #}
|
||||||
|
<meta name="twitter:title" content="{{ computedTitle }}">
|
||||||
|
<meta name="twitter:description" content="{{ description }}">
|
||||||
|
{# <meta name="twitter:image" content="https://....jpg"> #}
|
||||||
|
<meta name="twitter:card" content="summary">
|
||||||
</head>
|
</head>
|
||||||
<body data-font="english" data-path="{{page.url}}">
|
<body data-font="english" data-path="{{page.url}}">
|
||||||
{% include "-header.njk" %}
|
{% include "-header.njk" %}
|
||||||
|
|
|
@ -10,7 +10,7 @@ eleventyComputed:
|
||||||
{% for item in collections[tag] | reverse %}
|
{% for item in collections[tag] | reverse %}
|
||||||
<article class="item-summary">
|
<article class="item-summary">
|
||||||
<a href="{{ item.url }}">{{ item.data.title }}</a>
|
<a href="{{ item.url }}">{{ item.data.title }}</a>
|
||||||
{% if item.data.dateString %}<aside>{{item.data.dateString}}</aside>{% endif %}
|
{% if item.data.date %}<aside>{{item.data.date | formatDate("MMMM DD, YYYY")}}</aside>{% endif %}
|
||||||
<p class="item-summary-description">{{ item.data.description }}</p>
|
<p class="item-summary-description">{{ item.data.description }}</p>
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
const { DateTime } = require("luxon");
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
layout: "post.njk",
|
layout: "post.njk",
|
||||||
permalink: "/posts/{{ title | slugify }}/",
|
permalink: "/posts/{{ title | slugify }}/",
|
||||||
tags: ["posts"],
|
tags: ["posts"],
|
||||||
|
author: "Joshua Seigler",
|
||||||
eleventyComputed: {
|
eleventyComputed: {
|
||||||
dateString: ({ page }) => DateTime.fromJSDate(page.date, { zone: 'utc' }).toLocaleString(DateTime.DATE_FULL)
|
date: "{{ page.date }}"
|
||||||
},
|
}
|
||||||
author: "Joshua Seigler"
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue