mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-11-05 07:05:40 -05:00
fix post title encoding
This commit is contained in:
@@ -3,7 +3,7 @@ export const siteName = "Jake Jarvis";
|
||||
export const siteLocale = "en-US";
|
||||
export const timeZone = "America/New_York"; // https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
|
||||
export const onionDomain = "jarvis2i2vp4j4tbxjogsnqdemnte5xhzyi7hziiyzxwge3hzmh57zad.onion";
|
||||
export const shortDescription = "Front-End Web Developer in Boston; MA";
|
||||
export const shortDescription = "Front-End Web Developer in Boston, MA";
|
||||
export const longDescription =
|
||||
"Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps.";
|
||||
export const license = "Creative Commons Attribution 4.0 International";
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from "path";
|
||||
import glob from "fast-glob";
|
||||
import pMap from "p-map";
|
||||
import pMemoize from "p-memoize";
|
||||
import { decode } from "html-entities";
|
||||
import { formatDate } from "./format-date";
|
||||
import { BASE_URL, POSTS_DIR } from "../config/constants";
|
||||
|
||||
@@ -32,7 +33,7 @@ export const getFrontMatter = async (slug: string): Promise<FrontMatter> => {
|
||||
|
||||
// allow *very* limited markdown to be used in post titles
|
||||
const parseTitle = async (title: string, allowedTags: string[] = []): Promise<string> => {
|
||||
return String(
|
||||
const newTitle = (
|
||||
await unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkSmartypants, {
|
||||
@@ -45,7 +46,10 @@ export const getFrontMatter = async (slug: string): Promise<FrontMatter> => {
|
||||
.use(rehypeSanitize, { tagNames: allowedTags })
|
||||
.use(rehypeStringify)
|
||||
.process(title)
|
||||
);
|
||||
).toString();
|
||||
|
||||
// assume if we don't want any html titles then we don't want encoded html entities either
|
||||
return allowedTags.length === 0 ? decode(newTitle) : newTitle;
|
||||
};
|
||||
|
||||
// process title as both plain and stylized
|
||||
@@ -57,8 +61,9 @@ export const getFrontMatter = async (slug: string): Promise<FrontMatter> => {
|
||||
// return both the parsed YAML front matter (with a few amendments) and the raw, unparsed markdown content
|
||||
return {
|
||||
...(frontmatter as Partial<FrontMatter>),
|
||||
// zero markdown title:
|
||||
// plain title without html or markdown syntax:
|
||||
title,
|
||||
// stylized title with limited html tags:
|
||||
htmlTitle,
|
||||
slug,
|
||||
date: formatDate(frontmatter.date), // validate/normalize the date string provided from front matter
|
||||
|
||||
Reference in New Issue
Block a user