-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
242 changed files
with
18,129 additions
and
4,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,224 @@ | ||
// @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig | ||
|
||
// Imports -------------------------------------------- | ||
|
||
const { | ||
EleventyI18nPlugin, | ||
EleventyHtmlBasePlugin, | ||
EleventyRenderPlugin, | ||
} = require('@11ty/eleventy'); | ||
const markdownIt = require('markdown-it'); | ||
const markdownItAttrs = require('markdown-it-attrs'); | ||
const markdownItFootnote = require('markdown-it-footnote'); | ||
const markdownItIns = require('markdown-it-ins'); | ||
const markdownItMark = require('markdown-it-table-of-contents'); | ||
const markdownItSub = require('markdown-it-sub'); | ||
const markdownItSup = require('markdown-it-sup'); | ||
const markdownItTableOfContents = require('markdown-it-table-of-contents'); | ||
const pluginEmbedEverything = require('eleventy-plugin-embed-everything'); | ||
const pluginRSS = require('@11ty/eleventy-plugin-rss'); | ||
const pluginSyntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); | ||
|
||
const markdownItAnchor = require('markdown-it-anchor'); | ||
const pluginTOC = require('eleventy-plugin-toc'); | ||
|
||
// Local Imports -------------------------------------- | ||
|
||
const {formatDate} = require('./src/_config/filters/dates'); | ||
|
||
// 11ty ----------------------------------------------- | ||
|
||
module.exports = (eleventyConfig) => { | ||
// Global Settings -------------------------------- | ||
|
||
eleventyConfig.addGlobalData('settings', { | ||
// these get merged with _data/settings.js | ||
url: | ||
// process.env.URL || | ||
// process.env.VERCEL_URL || | ||
// process.env.CF_PAGES_URL || | ||
'https://miguelpimentel.do', | ||
isProduction: process.env.NODE_ENV === 'production', | ||
isProduction: process.env.VERCEL_ENV === 'production', | ||
// isStaging: | ||
// (process.env.URL && process.env.URL.includes('github.io')) || | ||
// (process.env.VERCEL_URL && process.env.VERCEL_URL.includes('vercel.app')) || | ||
// (process.env.CF_PAGES_URL && | ||
// process.env.CF_PAGES_URL.includes('pages.dev')) || | ||
// false, | ||
}); | ||
|
||
// Watch Targets ---------------------------------- | ||
|
||
eleventyConfig.addWatchTarget('./src/assets'); | ||
eleventyConfig.addWatchTarget('./src/_layouts'); | ||
|
||
// Layouts ---------------------------------------- | ||
|
||
eleventyConfig.addLayoutAlias('base', 'base.njk'); | ||
eleventyConfig.addLayoutAlias('rss', 'rss.njk'); | ||
eleventyConfig.addLayoutAlias('rssxsl', 'rss.xsl.njk'); | ||
eleventyConfig.addLayoutAlias('json', 'json.njk'); | ||
eleventyConfig.addLayoutAlias('manifest', 'manifest.njk'); | ||
eleventyConfig.addLayoutAlias('home', 'home.njk'); | ||
eleventyConfig.addLayoutAlias('page', 'page.njk'); | ||
eleventyConfig.addLayoutAlias('post', 'post.njk'); | ||
eleventyConfig.addLayoutAlias('posts', 'posts.njk'); | ||
eleventyConfig.addLayoutAlias('note', 'note.njk'); | ||
eleventyConfig.addLayoutAlias('notes', 'notes.njk'); | ||
|
||
// Plugins ---------------------------------------- | ||
|
||
const markdownItOptions = { | ||
html: true, | ||
linkify: true, | ||
typographer: true, | ||
}; | ||
|
||
const md = markdownIt(markdownItOptions) | ||
.use(require('markdown-it-anchor')) | ||
.use(require('markdown-it-attrs')) | ||
.use(require('markdown-it-footnote')) | ||
.use(require('markdown-it-table-of-contents')) | ||
.use(function (md) { | ||
// Recognize Mediawiki links ([[text]]) | ||
md.linkify.add('[[', { | ||
validate: /^\s?([^\[\]\|\n\r]+)(\|[^\[\]\|\n\r]+)?\s?\]\]/, | ||
normalize: (match) => { | ||
const parts = match.raw.slice(2, -2).split('|'); | ||
parts[0] = parts[0].replace(/.(md|markdown)\s?$/i, ''); | ||
// parts[0] = parts[0].replace(/\b\s+\b/, '-'); | ||
match.text = (parts[1] || parts[0]).trim(); | ||
match.url = `/en/notes/${parts[0].trim()}/`; | ||
}, | ||
}); | ||
}); | ||
|
||
eleventyConfig.addPlugin(require('./src/_config/plugins/drafts')); | ||
eleventyConfig.addPlugin(pluginTOC, { | ||
ul: true, | ||
}); | ||
eleventyConfig.addPlugin(pluginRSS); | ||
eleventyConfig.addPlugin(pluginSyntaxHighlight); | ||
eleventyConfig.addPlugin(EleventyHtmlBasePlugin); | ||
eleventyConfig.addPlugin(EleventyRenderPlugin); | ||
eleventyConfig.addPlugin(EleventyI18nPlugin, {defaultLanguage: 'en'}); | ||
eleventyConfig.addPlugin(pluginEmbedEverything, { | ||
use: ['twitter', 'youtube', 'vimeo'], | ||
twitter: { | ||
options: { | ||
embedClass: 'oembed oembed-twitter', | ||
doNotTrack: true, | ||
}, | ||
}, | ||
vimeo: { | ||
options: { | ||
embedClass: 'oembed oembed-vimeo', | ||
//wrapperStyle | ||
}, | ||
}, | ||
youtube: { | ||
options: { | ||
embedClass: 'oembed oembed-youtube', | ||
modestBranding: true, | ||
lazy: true, | ||
lite: { | ||
thumbnailQuality: 'maxresdefault', | ||
css: { | ||
inline: true, | ||
}, | ||
js: { | ||
inline: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
// Transforms ------------------------------------- | ||
|
||
eleventyConfig.addPlugin(require('./src/_config/transforms/css')); | ||
eleventyConfig.addPlugin(require('./src/_config/transforms/html')); | ||
eleventyConfig.addPlugin(require('./src/_config/transforms/js')); | ||
|
||
// Shortcodes -------------------------------------- | ||
|
||
eleventyConfig.addShortcode('version', () => `${+new Date()}`); | ||
eleventyConfig.addShortcode('year', () => `${new Date().getFullYear()}`); | ||
eleventyConfig.addShortcode( | ||
'build', | ||
() => `${new Date().toISOString().split('T')[0]}`, | ||
); | ||
eleventyConfig.addShortcode( | ||
'image', | ||
require('./src/_config/shortcodes/image'), | ||
); | ||
eleventyConfig.addShortcode('currentDate', (date = DateTime.now()) => { | ||
return date; | ||
}); | ||
|
||
// Filters ---------------------------------------- | ||
|
||
eleventyConfig.addFilter('formatDate', formatDate); | ||
eleventyConfig.addFilter( | ||
'languageFilter', | ||
require('./src/_config/filters/language'), | ||
); | ||
eleventyConfig.addFilter( | ||
'translate', | ||
require('./src/_config/filters/translate'), | ||
); | ||
eleventyConfig.addFilter( | ||
'mimetype', | ||
require('./src/_config/filters/mimetype'), | ||
); | ||
eleventyConfig.addFilter('cdnify', require('./src/_config/filters/cdnify')); | ||
eleventyConfig.addFilter('widont', require('./src/_config/filters/widont')); | ||
eleventyConfig.addFilter('random', require('./src/_config/filters/random')); | ||
eleventyConfig.addFilter('where', require('./src/_config/filters/where')); | ||
eleventyConfig.addFilter('sort', require('./src/_config/filters/sort')); | ||
eleventyConfig.addFilter('base64', require('./src/_config/filters/base64')); | ||
eleventyConfig.addFilter( | ||
'readingTime', | ||
require('./src/_config/filters/readingtime'), | ||
); | ||
eleventyConfig.addFilter('markdownify', (string) => { | ||
return md.render(string); | ||
}); | ||
|
||
// Passthrough ------------------------------------- | ||
|
||
eleventyConfig.addPassthroughCopy({'./src/assets/': './assets/'}); | ||
|
||
// Markdown ---------------------------------------- | ||
|
||
eleventyConfig.setLibrary('md', md); | ||
eleventyConfig.amendLibrary('md', (mdLib) => { | ||
mdLib.use(markdownItIns); | ||
mdLib.use(markdownItMark); | ||
mdLib.use(markdownItSub); | ||
mdLib.use(markdownItSup); | ||
mdLib.use(markdownItAttrs); | ||
mdLib.use(markdownItFootnote); | ||
mdLib.use(markdownItTableOfContents); | ||
mdLib.use(markdownItAnchor); | ||
}); | ||
|
||
// 11ty Settings ----------------------------------- | ||
|
||
return { | ||
markdownTemplateEngine: 'njk', | ||
htmlTemplateEngine: 'njk', | ||
|
||
// If your site deploys to a subdirectory, change `pathPrefix` | ||
pathPrefix: '/', | ||
|
||
dir: { | ||
input: 'src', | ||
output: 'dist', | ||
layouts: '_layouts', | ||
includes: '_includes', | ||
data: '_data', | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"src":{"assets":{"img":{"en.jpg":{"caption":"Photo by Scott Evans on Unsplash.","alt":"Yellow rapeseed flowers bloom against a clear blue sky.","title":"English countryside"},"sv.jpg":{"caption":"Foto av Scott Evans på Unsplash","alt":"Båten Stockholms Ström 2 glider över vattnet med Stockholm i fjärran.","title":"Stockholm archipelago"},"screenshots.png":{"caption":"Screenshot of elva with Front Matter CMS.","alt":"Screenshot of elva in VSCodium and the browser.","title":"Elva screenshots"}}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<html data-theme="dark"> | ||
|
||
<head> | ||
<!-- set the URL to http://localhost:8080 with your 11ty server running for testing --> | ||
<link href="{{ url }}/assets/css/bundle.css" rel="stylesheet"> | ||
<style> | ||
html { | ||
background-color: var(--white); | ||
} | ||
|
||
body { | ||
width: 1200px; | ||
height: 630px; | ||
min-height: auto; | ||
padding: var(--space-2xl); | ||
justify-content: space-between; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div style="max-height: 100px;"> | ||
<img alt="opengraph image" src="{{ url }}/assets/images/opengraph-default.png" | ||
style="width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%;" /> | ||
<!-- <svg fill="none" style="width:100%; height:100%;" height="242" viewBox="0 0 541 242" width="541" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-labelledby="intro-title" role="img"> | ||
<title id="intro-title">{{ title }}</title> | ||
<clipPath id="a"><path d="m0 0h541v242h-541z"/></clipPath> | ||
<clipPath id="b"><path d="m0 0h541v242h-541z"/></clipPath> | ||
<g clip-path="url(#a)"> | ||
<g clip-path="url(#b)" fill="currentColor"> | ||
<path d="m157.943 101.588c.969-2.2645 2.584-3.2351 4.522-3.2351 5.814 0 14.212 8.0881 14.212 15.5291 0 41.736-34.237 128.118-107.8795 128.118-50.7099 0-68.7975-34.618-68.7975-75.706 0-52.412 31.3303-92.5294 72.3504-92.5294 29.3926 0 47.8026 17.1471 47.8026 43.3534 0 26.205-23.5782 56.941-71.3811 57.588 4.8449 16.176 15.8267 23.617 28.7464 23.617 41.9887 0 63.6297-52.735 80.4247-96.735zm-111.755 51.118c27.4544-11.324 35.5292-23.618 35.5292-33.324 0-6.47-2.907-10.029-9.0438-10.029-14.2117 0-26.4854 19.412-26.4854 43.353z"/> | ||
<path d="m265.817 101.588c2.584-9.0586 18.733 2.265 18.733 12.294 0 41.736-31.33 128.118-85.27 128.118-46.511 0-63.307-35.912-62.338-125.206 0-70.2058 23.579-116.794 66.86-116.794 27.131 0 38.436 19.4118 38.436 54.6765 0 37.2059-20.348 73.1175-59.108 102.2355.646 28.47 11.305 41.412 24.871 41.412 26.162 0 44.896-53.383 57.816-96.736zm-82.364 17.147c13.566-25.235 21.964-47.8821 21.964-65.0291 0-14.5588-2.907-18.1177-7.106-18.1177-8.075 0-13.566 11.9706-14.858 83.1468z"/> | ||
<path d="m243.853 110.324c0-18.1181 17.442-32.3534 31.007-32.3534 15.181 0 15.181 5.8236 23.256 76.3534 3.23 29.441 6.137 44 15.504 44 6.459 0 12.273-11 15.503-24.265-12.919-9.706-17.441-27.5-17.441-50.794 0-30.7355 10.335-48.5296 26.485-48.5296 21.641 0 30.038 28.1466 30.038 50.7936 0 7.765-.323 15.53-1.292 22.971 13.889-2.912 23.902-16.176 35.853-46.912.969-2.2644 2.584-3.235 4.521-3.235 5.491 0 14.212 8.088 14.212 15.529 0 39.471-21.64 67.618-61.045 68.912-10.336 35.265-30.362 58.883-54.909 58.883-41.666 0-61.692-86.383-61.692-131.353z"/> | ||
<path d="m466.712 209c-9.367 18.441-22.287 32.353-38.436 32.353-24.548 0-49.418-25.235-49.418-63.412 0-60.176 30.361-104.1764 68.797-104.1764 15.181 0 22.933 9.0589 27.455 20.7059 2.583-11.9706 5.49-16.5 12.273-16.5 13.243 0 23.902 8.0883 23.902 18.1177 0 12.9408-6.137 71.1768-6.137 83.7938 0 7.765 3.23 10.03 8.398 10.03 4.522 0 8.72-3.559 11.95-8.412 1.938-3.235 3.876-5.5 7.106-5.5 4.845 0 8.398 4.529 8.398 12.294 0 26.853-12.274 53.706-31.33 53.706-16.796 0-35.529-14.235-42.958-33zm-45.865-34.941c0 8.412 2.261 14.882 7.752 14.882 16.149 0 31.653-44.323 31.653-63.412 0-6.47-2.261-9.382-6.137-9.382-13.243 0-33.268 31.059-33.268 57.912z"/> | ||
</g> | ||
</g> | ||
</svg> --> | ||
</div> | ||
<h1> | ||
{{title}} | ||
</h1> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const fs = require('fs') | ||
const slugify = require('@sindresorhus/slugify'); | ||
const nodeHtmlToImage = require('node-html-to-image'); | ||
|
||
const args = process.argv; | ||
const template = fs.readFileSync(args[1].replace('opengraph.js', 'opengraph-template.html'), 'utf8'); | ||
const frontmatter = args[4] && typeof args[4] === "string" ? JSON.parse(args[4]) : null; | ||
const data = {...frontmatter, ...{ 'url': 'http://localhost:8080' }}; | ||
|
||
nodeHtmlToImage({ | ||
output: args[2] + '/src/assets/img/opengraph-' + slugify(data.title) + '.png', | ||
html: template, | ||
content: data | ||
}).then(() => { | ||
const output = JSON.stringify({ | ||
'frontmatter': { | ||
'thumbnail': '/assets/img/opengraph-' + slugify(data.title) + '.png' | ||
} | ||
}); | ||
console.log(output); | ||
}).catch(e => console.log(e?.message || e)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: "{{title}}" | ||
date: "{{now}}" | ||
draft: true | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { registerCardImage, enableDevelopmentMode } from "https://cdn.jsdelivr.net/npm/@frontmatter/extensibility/+esm"; | ||
//enableDevelopmentMode(); | ||
|
||
/** | ||
* @param {string} filePath - The path of the file | ||
* @param {object} data - The metadata of the file | ||
* @returns {string} - The HTML to be rendered in the card footer | ||
*/ | ||
registerCardImage(async (filePath, metadata) => { | ||
const image = metadata.fmPreviewImage ? metadata.fmPreviewImage : `${metadata.fmWebviewUrl}/src/assets/img/opengraph-default.png`; | ||
return `<img src="${image}" alt="${metadata.title.thumbnailDescription || metadata.title }" style="object-fit: cover;" class="h-36 w-full" />`; | ||
}); |
Oops, something went wrong.