Skip to content

Commit

Permalink
feat: create blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh authored and stdavis committed Mar 26, 2024
1 parent 5da611f commit a6af2f1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/new-blog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fs from 'fs';

// e.g. node scripts/new-blog.mjs "Blog Title"

const title = process.argv[2];
const date = new Date().toISOString().split('T')[0];
const slug = `${date}-${title.toLowerCase().replace(/\s+/g, '-')}`;
const filePath = `../src/content/blog/${slug}.mdx`;
const folderPath = `../src/images/pillar-blog/${slug}`;

const data = `---
title: ${title}
author: Steve Gourley
description: 100-160 character description of the blog post
date: ${new Date().toISOString()}
category: UGRC
tags:
- website
cover_image: /src/images/pillar-blog/default-social-card.png
cover_image_alt: ugrc social card
---
import { Image } from 'astro:assets';
import myImage from \`@images/blog/${slug}/image.png\`;
My blog post content starts here.
<Image src={myImage} loading="eager" alt="A sample image" />
`;

fs.writeFileSync(filePath, data, 'utf-8');
fs.mkdirSync(folderPath);

0 comments on commit a6af2f1

Please sign in to comment.