Skip to content

Commit

Permalink
Introduce Template Blog Post (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakob Helgesson <[email protected]>
  • Loading branch information
lucemans and svemat01 authored Aug 28, 2023
1 parent bbf9169 commit f010233
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
19 changes: 13 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@
"postCreateCommand": "cd blog && pnpm install && pnpm build:assets",

// Use 'postAttachCommand' to run commands after the a tool has successfully attatched to the container.
"postAttachCommand": "cd blog && pnpm dev"
"postAttachCommand": "cd blog && pnpm dev",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}





// Customizations
"customizations": {
"codespaces": {
// Automatically open the following files on first boot
"openFiles": [
"content/000_template_blog_post/readme.mdx",
"content/000_template_blog_post/meta.json",
"CONTRIBUTING.md"
]
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Build
working-directory: ./blog
run: pnpm run build
run: NODE_ENV=production pnpm run build

- name: Prepare tag
id: prepare_tag
Expand Down
5 changes: 3 additions & 2 deletions blog/src/lib/get_posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export const _getPostsMetadata = async (): Promise<BlogPostMetadataPlus[]> => {

const pageMetadata = await BlogPostMetadataSchema.parseAsync(meta);

// TODO: Load metadata or extra info for a file.
// NOTE: keep this lightweight as it runs during dev for every page
// Filter out any draft posts in production
if (pageMetadata.draft && process.env.NODE_ENV == 'production')
continue;

posts.push({ ...pageMetadata, file });
}
Expand Down
2 changes: 2 additions & 0 deletions blog/src/types/BlogPostMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const BlogPostMetadataSchema = z.object({
authors: z.array(z.string()),
// ENS Name of the author
youtube: z.string().optional(),
// Draft status of post
draft: z.boolean().default(false),
});

export type BlogPostMetadata = z.infer<typeof BlogPostMetadataSchema>;
10 changes: 10 additions & 0 deletions content/000_template_blog_post/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"slug": "template",
"cover": "https://mirror-media.imgix.net/publication-images/ixUWm-C6FTIi4Tg6IQ3Z8.jpeg?height=600&width=1200&h=600&w=1200&auto=compress",
"title": "Template Blog Post",
"description": "This is a template blog post.",
"date": "2023-08-28",
"tags": ["template"],
"authors": ["luc.eth"],
"draft": true
}
6 changes: 6 additions & 0 deletions content/000_template_blog_post/readme.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Template Blog

Hello this is the template blogpost

You can view this post, (and the rest of the site), at [http://localhost:3000](localhost:3000)

0 comments on commit f010233

Please sign in to comment.