Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: eleventy plugin metagen #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = function (eleventyConfig) {

// https://www.npmjs.com/package/eleventy-plugin-metagen
eleventyConfig.addPlugin(require('eleventy-plugin-metagen'))

// Add filters to Nunjucks
eleventyConfig.addFilter("dateDisplay", require("./src/_filters/dates.js") );

19 changes: 18 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
"description": "Eleventy theme based on Bragdoc by Jonny Burch and the team at Progression.app",
"main": "index.js",
"dependencies": {
"@11ty/eleventy": "^0.12.1"
"@11ty/eleventy": "^0.12.1",
"eleventy-plugin-metagen": "^1.5.2"
},
"devDependencies": {
"gh-pages": "^3.2.3"
23 changes: 7 additions & 16 deletions src/_data/data.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
{
"site":
{
"name": "11ty x Bragdocs",
"description": "Eleventy theme inspired by Julia Evan's Brag Document. Original Bragdocs design by Jonny Burch and the team at Progression.app.",
"url": "https://emilyyleung.github.io",
"baseUrl": "/eleventy-bragdoc/",
"author":
{
"handle": "@emily_y_leung",
"name": "Emily Y Leung"
},
"images":
{
"twitter": "https://i.imgur.com/ewfT3Xg.jpg"
}
}
"name": "11ty x Bragdocs",
"description": "Eleventy theme inspired by Julia Evan's Brag Document. Original Bragdocs design by Jonny Burch and the team at Progression.app.",
"url": "https://emilyyleung.github.io",
"baseUrl": "/eleventy-bragdoc/",
"author": "Emily Y Leung",
"twitter_handle": "@emily_y_leung",
"img": "https://i.imgur.com/ewfT3Xg.jpg"
}
29 changes: 23 additions & 6 deletions src/_includes/layouts/base.njk
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
---
eleventyComputed:
url_long: '{{ data.url }}{{ data.baseUrl }}'
title_long: '{{ data.author }} / {{ data.name }}'
metagen:
title: '{{ data.name }}'
name: '{{ data.author }}'
desc: '{{ data.description | safe }}'
generator: 'eleventy'
comments: true
url: '{{ url_long }}'
site_name: '{{ title_long }}'
og_title: '{{ title_long }}'
img: '{{ data.img }}'
img_alt: '{{ data.author }}'
twitter_card_type: 'summary_large_image'
twitter_handle: '{{ data.twitter_handle }}'
twitter_title: '{{ title_long }}'
---
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>{{ data.name }}</title>
<!-- eleventy plugin metagen -->
{% metagen metagen %}
{% include "partials/site-meta-head.njk" %}

<link rel="stylesheet" href="{{ '/css/styles.css' | url }}">

<link rel="apple-touch-icon" sizes="180x180" href="{{ '/images/favicon_io/apple-touch-icon.png' | url }}">
@@ -21,8 +40,6 @@

gtag('config', 'G-QHTYKWLREY');
</script>

{% include "partials/site-meta-head.njk" %}
</head>
<body>
{{ content | safe }}
2 changes: 1 addition & 1 deletion src/_includes/partials/site-foot.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<footer>
<div><a target="_blank" href="https://www.bragdocs.com/">Bragdocs</a> inspired theme built with <a target="_blank" href="https://www.11ty.dev/">11ty</a></div>
<div>Made with ♥ by <a target="_blank" href="{{ data.url }}">{{ data.author.name }}</a></div>
<div>Made with ♥ by <a target="_blank" href="{{ data.url }}">{{ data.author }}</a></div>
</footer>
34 changes: 7 additions & 27 deletions src/_includes/partials/site-meta-head.njk
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
<meta name="author" content="{{ data.site.author.name }}">
<meta name="description" content="{{ data.site.description }}">
<meta property="og:data.site_name" content="{{ data.site.author.name }} / {{ data.site.name }}">

<!-- HTML Meta Tags -->
<meta name="description" content="{{ data.site.description }}">

<!-- Google / Search Engine Tags -->
<meta itemprop="name" content="{{ data.site.author.name }} / {{ data.site.name }}">
<meta itemprop="description" content="{{ data.site.description }}">
<meta itemprop="image" content="{{ data.site.images.twitter }}">

<!-- Facebook Meta Tags -->
<meta property="og:url" content="{{ data.site.url }}{{ data.site.baseUrl }}">
<meta property="og:type" content={{ pagetype }}>
<meta property="og:title" content="{{ data.site.author.name }} / {{ data.site.name }}">
<meta property="og:description" content="{{ data.site.description }}">
<meta property="og:image" content="{{ data.site.images.twitter }}">

<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{{ data.site.author.name }} / {{ data.site.name }}">
<meta name="twitter:description" content="{{ data.site.description }}">
<meta name="twitter:image" content="{{ data.site.images.twitter }}">
<meta name="twitter:image:alt" content="{{ data.site.author.name }}">
<meta name="twitter:data.site" content="{{ data.site.author.handle }}">

<!-- consider removing, Google+
https://stackoverflow.com/questions/29928974/what-is-the-purpose-of-meta-itemprop
https://stackoverflow.com/a/29929151/5216425 -->
<meta itemprop="name" content="{{ title_long }}">
<meta itemprop="description" content="{{ data.description | safe }}">
<meta itemprop="image" content="{{ data.img }}">
<!-- Opt Out Pinterest https://developers.pinterest.com/docs/rich-pins/overview/ -->
<meta name="pinterest-rich-pin" content="false" />