fix: highlighting

This commit is contained in:
Cory Dransfeldt 2024-06-03 06:33:03 -07:00
parent 09cdd5dbdc
commit ae13df9813
No known key found for this signature in database
4 changed files with 14 additions and 12 deletions

View file

@ -69,6 +69,11 @@ export default async function (eleventyConfig) {
eleventyConfig.setLibrary('md', md) eleventyConfig.setLibrary('md', md)
// filters // filters
eleventyConfig.addLiquidFilter('markdown', (content) => {
if (!content) return
return md.render(content)
})
Object.keys(filters).forEach((filterName) => { Object.keys(filters).forEach((filterName) => {
eleventyConfig.addLiquidFilter(filterName, filters[filterName]) eleventyConfig.addLiquidFilter(filterName, filters[filterName])
}) })

View file

@ -3,11 +3,10 @@ import { URL } from 'url'
import slugify from 'slugify' import slugify from 'slugify'
import markdownIt from 'markdown-it' import markdownIt from 'markdown-it'
import sanitizeHtml from 'sanitize-html'; import sanitizeHtml from 'sanitize-html';
import { shuffleArray, sanitizeMediaString } from '../utilities/index.js' import { shuffleArray, sanitizeMediaString } from '../utilities/index.js'
const BASE_URL = 'https://coryd.dev' const BASE_URL = 'https://coryd.dev'
const md = markdownIt({ html: true, linkify: true })
export default { export default {
// general // general
@ -24,9 +23,6 @@ export default {
formatNumber: (number) => number.toLocaleString('en-US'), formatNumber: (number) => number.toLocaleString('en-US'),
shuffleArray, shuffleArray,
// markdown
markdown: (content) => md.render(content),
// navigation // navigation
isLinkActive: (category, page) => { isLinkActive: (category, page) => {
const normalizedPage = page.includes('.html') ? page.replace('.html', '/') : page const normalizedPage = page.includes('.html') ? page.replace('.html', '/') : page
@ -116,6 +112,7 @@ export default {
entries.forEach((entry) => { entries.forEach((entry) => {
const dateKey = Object.keys(entry).find((key) => key.includes('date')) const dateKey = Object.keys(entry).find((key) => key.includes('date'))
const date = new Date(entry[dateKey]) const date = new Date(entry[dateKey])
const md = markdownIt({ html: true, linkify: true })
let excerpt = '' let excerpt = ''
let url = '' let url = ''
let title = entry.title let title = entry.title

10
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "18.6.8", "version": "18.6.9",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "coryd.dev", "name": "coryd.dev",
"version": "18.6.8", "version": "18.6.9",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@cdransf/api-text": "^1.4.0", "@cdransf/api-text": "^1.4.0",
@ -829,9 +829,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001626", "version": "1.0.30001627",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001626.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001627.tgz",
"integrity": "sha512-JRW7kAH8PFJzoPCJhLSHgDgKg5348hsQ68aqb+slnzuB5QFERv846oA/mRChmlLAOdEDeOkRn3ynb1gSFnjt3w==", "integrity": "sha512-4zgNiB8nTyV/tHhwZrFs88ryjls/lHiqFhrxCW4qSTeuRByBVnPYpDInchOIySWknznucaf31Z4KYqjfbrecVw==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {

View file

@ -1,6 +1,6 @@
{ {
"name": "coryd.dev", "name": "coryd.dev",
"version": "18.6.8", "version": "18.6.9",
"description": "The source for my personal site. Built using 11ty.", "description": "The source for my personal site. Built using 11ty.",
"type": "module", "type": "module",
"scripts": { "scripts": {