Skip to content

Instantly share code, notes, and snippets.

@third774
Created December 15, 2023 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save third774/b098cc2a8c9a1cffe39da2eab670b89d to your computer and use it in GitHub Desktop.
Save third774/b098cc2a8c9a1cffe39da2eab670b89d to your computer and use it in GitHub Desktop.
// Name: New Astro Blog Post
import "@johnlindquist/kit";
const title = await arg("What's the title of the post?");
const description = await arg("What's the description of the post?");
const slug = title.toLowerCase().split(" ").join("-");
const blogCollectionPath = await env("ASTRO_BLOG_COLLECTION_PATH");
const content = `---
{
"title": "${title}",${
description ? `\n "description": "${description}",` : ""
}
"published": "${new Date().toISOString()}"
}
---
`;
const filePath = `${blogCollectionPath}/${slug}.md`;
const editedContent = await editor(content);
await writeFile(filePath, editedContent);
await exec(`/opt/homebrew/bin/code ${filePath}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment