Skip to content

Commit

Permalink
Fixed my laundry list of goof ups.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisForti committed Sep 9, 2024
1 parent 64adc14 commit 6ee908a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
3 changes: 1 addition & 2 deletions content/chris.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ slug: understanding-typescript
tags:
- typescript
- programming
imageUrl:
author: "The Man"
author: Christopher Forti
---

# Content
Expand Down
2 changes: 1 addition & 1 deletion content/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Example
description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.
date: 2023-03-04
slug: example
author: "The Man"
author: Christopher Forti
---

# Example
Expand Down
2 changes: 1 addition & 1 deletion content/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Test
description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.
date: 2023-03-04
slug: test
author: "The Man"
author: Christopher Forti
---

# Test File
Expand Down
2 changes: 1 addition & 1 deletion content/with-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blan
date: 2024-03-04
imageUrl: https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80
slug: with-image
author: "The Man"
author: Christopher Forti
---

# Example
Expand Down
40 changes: 36 additions & 4 deletions parse-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type Metadata = {
description: string;
date: Date;
slug: string;
author: string;
authorImageUrl: string;
author?: string;
authorImage?: string;
tags?: string[];
imageUrl?: string;
};
Expand Down Expand Up @@ -89,8 +89,17 @@ function validateMetadata(metadata: unknown, fileName: string) {
return false;
}

const { published, title, description, date, slug, tags, imageUrl } =
metadata as Metadata;
const {
published,
title,
description,
date,
author,
authorImage,
slug,
tags,

Check failure on line 100 in parse-markdown.ts

View workflow job for this annotation

GitHub Actions / Lint

'tags' is assigned a value but never used
imageUrl,
} = metadata as Metadata;
try {
if (typeof published !== "boolean") {
throw new Error(
Expand Down Expand Up @@ -127,6 +136,29 @@ function validateMetadata(metadata: unknown, fileName: string) {
"\x1b[31mimageUrl must be an absolute URL or a path starting with /\nExample: /images/my-image.jpg for image in public folder\nOr: https://example.com/image.jpg for an external image\x1b[0m",
);
}
if (imageUrl === null) {
throw new Error("\x1b[31mimageUrl must be a string\x1b[0m");
}
if (typeof author !== "string") {
throw new Error(
"\x1b[31mThe markdown must contain a valid author. \x1b[0m",
);
}
if (
authorImage &&
!authorImage.startsWith("http://") &&
!authorImage.startsWith("https://") &&
!authorImage.startsWith("/")
) {
throw new Error(
"\x1b[31mimageUrl must be an absolute URL or a path starting with /\nExample: /images/my-image.jpg for image in public folder\nOr: https://example.com/image.jpg for an external image\x1b[0m",
);
}
if (authorImage === null) {
throw new Error(
"\x1b[31mauthorImage must be a string must be a string\x1b[0m",
);
}
} catch (error) {
if ("message" in (error as Error)) {
console.error(
Expand Down
21 changes: 8 additions & 13 deletions src/posts/posts.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"id": "a48d2f30-197c-4c30-9e6a-7a987bacb7cf",
"id": "90588fcb-6017-4db9-8589-4979b38c8520",
"metadata": {
"title": "Understanding TypeScript",
"published": true,
Expand All @@ -11,49 +11,44 @@
"typescript",
"programming"
],
"imageUrl": null,
"author": "The Man",
"authorImage": null
"author": "Christopher Forti"
},
"html": "<h1>Content</h1>\n<h2>Introduction</h2>\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus.</p>\n<h2>Main Content</h2>\n<p>Detailed content goes here. Include sections, lists, code snippets, images, tables, etc.</p>\n<h3>Subsection</h3>\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus</p>\n"
},
{
"id": "f5fa4f47-eaaf-4883-9bdd-a9024dcea864",
"id": "08f6b02f-fb9c-49fc-ab7e-ded4faa748ac",
"metadata": {
"published": true,
"title": "Example",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.",
"date": "2023-03-04T00:00:00.000Z",
"slug": "example",
"author": "The Man",
"authorImage": null
"author": "Christopher Forti"
},
"html": "<h1>Example</h1>\n<p>This is an example post.\nHere is some code:</p>\n<pre><code class=\"language-js\">const helloWorld = &quot;Hello, World!&quot;;\n\nconsole.log(helloWorld);\n</code></pre>\n<h2>Example 2</h2>\n<p>This is an example <code>of a inline code block</code>.</p>\n<h3>Example 3</h3>\n<p>This is an example of a list:</p>\n<ul>\n<li>Item 1<ul>\n<li>Nested Item 1</li>\n<li>Nested Item 2</li>\n</ul>\n</li>\n<li>Item 2<ul>\n<li>Nested Item 1<ul>\n<li>Deeply Nested Item 1</li>\n</ul>\n</li>\n</ul>\n</li>\n<li>Item 3</li>\n</ul>\n<h4>Example 4</h4>\n<p>This is an example of a numbered list:</p>\n<ol>\n<li>Item 1<ol>\n<li>Nested Item 1</li>\n<li>Nested Item 2</li>\n</ol>\n</li>\n<li>Item 2<ol>\n<li>Nested Item 1<ol>\n<li>Deeply Nested Item 1</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Item 3</li>\n</ol>\n<h5>Example 5</h5>\n<p>This is an example of a table:</p>\n<table>\n<thead>\n<tr>\n<th>Header 1</th>\n<th>Header 2</th>\n<th>Header 3</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Row 1</td>\n<td>Row 1</td>\n<td>Row 1</td>\n</tr>\n<tr>\n<td>Row 2</td>\n<td>Row 2</td>\n<td>Row 2</td>\n</tr>\n<tr>\n<td>Row 3</td>\n<td>Row 3</td>\n<td>Row 3</td>\n</tr>\n</tbody></table>\n<h6>Example 6</h6>\n<p>This is an example of a blockquote:</p>\n<blockquote>\n<p>This is a blockquote.</p>\n</blockquote>\n"
},
{
"id": "e7042de0-2c0b-47ed-a7e6-ff9ab26790d8",
"id": "5cbe01a0-da70-42b3-95ab-61deee465c25",
"metadata": {
"published": true,
"title": "Test",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.",
"date": "2023-03-04T00:00:00.000Z",
"slug": "test",
"author": "The Man",
"authorImage": null
"author": "Christopher Forti"
},
"html": "<h1>Test File</h1>\n<p>This is an test post.</p>\n<h2>Some Content</h2>\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.</p>\n<p>Nullam sodales scelerisque ornare. Integer sed lorem sed purus dignissim egestas. Mauris rhoncus tellus nisl, eu posuere diam hendrerit eu. Nulla scelerisque dolor lacus, ac vestibulum lacus tristique eget. Quisque tempor, lorem sed viverra tincidunt, eros velit efficitur neque, in iaculis ipsum libero eget nisl. Nunc a ipsum sed tellus volutpat accumsan. Duis sodales risus luctus velit iaculis pretium. Pellentesque tincidunt lobortis laoreet. Nam imperdiet, risus rutrum luctus consectetur, dui justo venenatis turpis, nec vestibulum tortor magna vel leo. Morbi blandit felis eget velit mollis, sagittis interdum velit porta. Vivamus tincidunt gravida facilisis. Integer condimentum, augue vel tristique tempor, lorem ipsum convallis mi, sit amet ultricies lectus nunc in orci. Pellentesque vel magna tellus.</p>\n<p>Cras ullamcorper felis vel nisi tempor commodo. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque ac augue faucibus, fermentum nisl nec, fermentum massa. Proin sit amet venenatis ligula, at pulvinar velit. Nunc auctor metus in urna placerat euismod. Quisque blandit turpis lacus, posuere vehicula erat cursus vel. Donec faucibus, ex eget tempus egestas, nibh mauris pellentesque tortor, malesuada posuere lorem elit tristique quam. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque ut neque eu tellus euismod volutpat. Pellentesque maximus est leo, id finibus enim vehicula in.</p>\n<p>Proin a enim at lorem maximus semper vel non mauris. Cras non pulvinar nunc. Proin tincidunt tempus purus, sed congue sem ultrices vel. Vestibulum justo justo, vestibulum nec scelerisque et, egestas eget felis. Sed pulvinar in massa vel tincidunt. Duis ac quam a diam gravida convallis. Nam dapibus velit a augue rhoncus, eu consectetur nulla efficitur. Aliquam vitae dolor imperdiet, ultricies ligula nec, euismod enim. Cras vehicula est vitae justo dignissim mattis. Praesent eleifend ullamcorper cursus.</p>\n<p>In eget rhoncus lacus. Maecenas semper iaculis pharetra. Duis auctor purus sed ligula viverra iaculis. Vivamus congue semper porta. Donec nec nunc vitae massa tempus rhoncus vel in orci. Curabitur sollicitudin enim sed elit semper maximus eu non purus. Nulla sagittis odio orci, non congue nulla faucibus ac. Nam vel pharetra turpis. Proin sed euismod tortor. Suspendisse auctor erat eu lectus vestibulum accumsan. Phasellus dictum condimentum ligula a ornare. Mauris condimentum malesuada nibh, commodo iaculis nisi dignissim et. Donec vestibulum turpis nibh, vitae dapibus dui gravida ac. Nam malesuada nulla nec ex congue rutrum. Integer non varius risus.</p>\n"
},
{
"id": "dba8bd73-52f1-4438-be0c-3fada74e742b",
"id": "eb49fc3e-aaca-4dd0-981a-c3a95774f33a",
"metadata": {
"published": true,
"title": "With Image",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla blandit aliquam finibus. Sed venenatis placerat eros, eget pulvinar lacus elementum ut. In hac habitasse platea dictumst. Etiam sed erat quis odio vehicula consequat. Phasellus magna magna, dignissim at felis eu, pulvinar venenatis turpis. Sed molestie consectetur magna, eget aliquam erat fermentum at. Nam bibendum enim in quam consequat, ut ultricies orci pellentesque. Curabitur viverra, est efficitur cursus cursus, ante magna eleifend sapien, eget pellentesque eros erat sit amet ante. Integer volutpat hendrerit imperdiet. Nulla facilisi. Quisque laoreet sem dolor, sed porttitor turpis pulvinar quis.",
"date": "2024-03-04T00:00:00.000Z",
"imageUrl": "https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
"slug": "with-image",
"author": "The Man",
"authorImage": null
"author": "Christopher Forti"
},
"html": "<h1>Example</h1>\n<p>This is an example post.\nHere is some prose:</p>\n<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus elementum tempus scelerisque. Aliquam mattis placerat quam id gravida. Nam nibh mi, dignissim a feugiat vitae, placerat non ipsum. Cras in libero sit amet erat ornare lobortis. Curabitur elementum tortor eros, vitae aliquet turpis rutrum quis. Curabitur ut interdum elit. In viverra finibus nisi, id vehicula mi pellentesque a. Vestibulum gravida magna odio, at cursus elit sagittis non.</p>\n<p>Morbi sagittis in velit non porttitor. Nam ac lobortis dolor, ultrices laoreet magna. Nulla at rhoncus ligula, eu convallis libero. Curabitur placerat ante eu ex accumsan blandit. Suspendisse vel volutpat nunc, eu sagittis felis. Nam quis elementum lorem. Sed tristique ultrices nisi, id tincidunt urna bibendum vel. Nam imperdiet accumsan libero, ut viverra dolor laoreet eu. Praesent aliquet lacus quis nisl iaculis hendrerit. Sed in semper ligula. Ut ultricies non arcu quis maximus. Mauris facilisis mi rhoncus porta faucibus. Quisque interdum, ante ac sollicitudin scelerisque, metus diam varius nisl, sit amet pretium lacus turpis ut tellus. Praesent et quam ullamcorper, gravida ligula in, placerat leo. Sed pharetra porttitor velit, a molestie justo facilisis quis.</p>\n<p>Donec non feugiat quam. Suspendisse potenti. Sed eu molestie nisl. Aliquam vel nulla malesuada, scelerisque turpis id, fermentum felis. In accumsan, massa sit amet auctor varius, quam nisl ullamcorper neque, tempus congue mauris mauris quis velit. Donec in faucibus mauris, id cursus elit. Maecenas eget lacus massa. Mauris euismod pretium lacus nec malesuada. Donec aliquet ipsum et justo euismod commodo. Duis commodo sed velit sit amet dapibus. Duis pulvinar ut nulla at faucibus. Duis ut metus vitae orci suscipit sodales vel sit amet enim.</p>\n<p>Nam ipsum urna, blandit non odio ut, pellentesque rutrum felis. Donec pulvinar, mi non dictum pretium, metus arcu sodales neque, at efficitur ligula diam a lectus. Vivamus malesuada arcu arcu, nec sodales nibh molestie eget. Praesent vel elit sed turpis tempor fermentum at eu lorem. Proin lacinia risus nec risus fringilla, sed vulputate purus pulvinar. Donec id eleifend felis. Phasellus bibendum nisi et purus volutpat, sit amet tempor quam dictum. Vivamus a urna vel leo fringilla ullamcorper sed at eros. Aliquam leo leo, molestie nec massa ut, aliquet tempus neque.</p>\n<p>Morbi eros ipsum, condimentum id placerat vitae, aliquet sit amet purus. Curabitur tempor non mi id posuere. Pellentesque vitae arcu nisi. Aenean tortor tellus, fermentum nec ante at, euismod dictum diam. In sed justo et mi dignissim interdum. Donec ante dui, suscipit in nisi non, sodales dictum augue. Sed sit amet nisl in nisl pharetra interdum at quis nisl. Sed iaculis ligula eu sodales tincidunt. Morbi tristique placerat sapien et sagittis. Sed accumsan libero ac tincidunt venenatis. Nulla in mi risus. Sed odio ante, pulvinar a sem et, commodo scelerisque leo. Morbi eget ipsum nisl. Nunc tristique enim eu ex convallis lobortis.</p>\n<p>Here is some code:</p>\n<pre><code class=\"language-js\">const helloWorld = &quot;Hello, World!&quot;;\n\nconsole.log(helloWorld);\n</code></pre>\n<h2>Example 2</h2>\n<p>This is an example <code>of a inline code block</code>.</p>\n<h3>Example 3</h3>\n<p>This is an example of a list:</p>\n<ul>\n<li>Item 1<ul>\n<li>Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n<li>Nested Item 2, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n</ul>\n</li>\n<li>Item 2<ul>\n<li>Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.<ul>\n<li>Deeply Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n</ul>\n</li>\n</ul>\n</li>\n<li>Item 3</li>\n</ul>\n<h4>Example 4</h4>\n<p>This is an example of a numbered list:</p>\n<ol>\n<li>Item 1<ol>\n<li>Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n<li>Nested Item 2, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n</ol>\n</li>\n<li>Item 2<ol>\n<li>Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.<ol>\n<li>Deeply Nested Item 1, Lorem ipsum dolor sit amet, consectetur adipiscing elit.</li>\n</ol>\n</li>\n</ol>\n</li>\n<li>Item 3</li>\n</ol>\n<h5>Example 5</h5>\n<p>This is an example of a table:</p>\n<table>\n<thead>\n<tr>\n<th>First Header</th>\n<th>Second Header</th>\n<th>Third Header</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>First Row</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n</tr>\n<tr>\n<td>Second Row</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n</tr>\n<tr>\n<td>Third Row</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</td>\n</tr>\n</tbody></table>\n<h6>Example 6</h6>\n<p>This is an example of a blockquote:</p>\n<blockquote>\n<p>This is a blockquote.</p>\n</blockquote>\n"
}
Expand Down
4 changes: 2 additions & 2 deletions src/posts/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type Metadata = {
description: string;
date: string;
slug: string;
author?: string;
authorImage?: string;
author: string;
authorImage: string;
tags?: string[];
imageUrl?: string;
};
Expand Down

0 comments on commit 6ee908a

Please sign in to comment.