Add fontawesome support to emojis

This commit is contained in:
Lewis Dale 2023-02-10 14:38:00 +00:00
parent 90a1d9d4fe
commit b70c43d765
20 changed files with 1899 additions and 11 deletions

3
config/filters/arrays.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function(eleventyConfig) {
eleventyConfig.addFilter('take', (list, n) => list.slice(0, n));
}

View File

@ -1,5 +1,7 @@
const dateFilters = require('./dates');
const arrayFilters = require('./arrays');
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(dateFilters);
eleventyConfig.addPlugin(arrayFilters);
}

1858
config/plugins/icons.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ const markdownItFootnote = require('markdown-it-footnote');
const markdownitMark = require('markdown-it-mark');
const markdownitAbbr = require('markdown-it-abbr');
const markdownItEleventyImg = require('markdown-it-eleventy-img');
const icons = require('./icons.json');
const { slugifyString } = require('../utils');
const markdownLib = markdownIt({
html: true,
@ -44,7 +45,7 @@ const markdownLib = markdownIt({
}
}
])
.use(markdownItEmoji)
.use(markdownItEmoji, { defs: icons })
.use(markdownItFootnote)
.use(markdownitMark)
.use(markdownitAbbr)
@ -64,6 +65,10 @@ const markdownLib = markdownIt({
}
});
markdownLib.renderer.rules.emoji = function(token, idx) {
return `<span class="fa-li"><i class="fa-solid fa-${token[idx].markup}"></i></span>`;
};
module.exports = function(eleventyConfig) {
eleventyConfig.setLibrary('md', markdownLib);
};

View File

@ -2,7 +2,9 @@
<html lang={{data.page.lang}}>
<head>
<title>{{ title }} | {{ metadata.site.name }}</title>
{% if includeFA %}
<link rel="stylesheet" type="text/css" href="/assets/css/fontawesome.css" />
{% endif %}
<link rel="stylesheet" type="text/css" href="/assets/css/styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>

View File

@ -1,5 +1,6 @@
---
layout: base.njk
includeFA: true
---
<main class="wrapper-lg stack-md">

9
src/assets/css/fontawesome.css vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,6 +11,10 @@
font-size: var(--text-size-3xl);
}
h2 {
font-size: var(--text-size-xl);
}
picture {
max-width: clamp(8rem, calc(1.09rem + 10vw), 12rem);
margin-left: auto;

View File

@ -0,0 +1,4 @@
.fa-li {
position: initial;
display: inline-block;
}

View File

@ -19,18 +19,18 @@ h5 {
}
h1 {
font-size: var(--text-size-2xl);
font-size: var(--text-size-xl);
word-wrap: normal;
text-underline-offset: var(--space-size-2xs);
}
h2 {
font-size: var(--text-size-xl);
font-size: var(--text-size-l);
text-underline-offset: var(--space-size-3xs);
}
h3 {
font-size: var(--text-size-l);
font-size: var(--text-size-m);
text-underline-offset: var(--space-size-3xs);
}

View File

@ -24,7 +24,7 @@ layout: base.njk
<h2>Recent Posts</h2>
<ul class="stack-2xs">
{% for post in collections.posts.slice(0, 3) %}
{% for post in collections.posts | reverse | take(3) %}
<li><a href="{{ post.data.url }}">{{ post.data.title }}</a> <time>{{ post.date | dateDisplay }}</time></li>
{% endfor %}
</ul>

View File

@ -5,14 +5,14 @@ layout: page.njk
## What I'm reading
:open_book: City of Last Chances by Adrian Tchaikovsky
* :book: City of Last Chances by Adrian Tchaikovsky
## What I'm watching
:tv: For All Mankind
* :tv: For All Mankind
## What I'm enjoying
:bike: Preparing for a 100km charity cycle
:family: Spending time with my family
:computer: Working on my ZX Basic interpreter
* :bicycle: Preparing for a 100km charity cycle
* :people-roof: Spending time with my family
* :computer: Working on my ZX Basic interpreter