Skip to content

Commit

Permalink
Remove drafts. I don't use them
Browse files Browse the repository at this point in the history
  • Loading branch information
johnzanussi committed Feb 25, 2025
1 parent d62cdbc commit 28051e1
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 38 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Read more about why I chose these libraries and services on the [Built With](htt
| `title` | `String` | Yes | |
| `excerpt` | `String` | No | | Used on [/pages](https://johnzanussi.com/pages) and in meta tags description. |
| `cover` | `ImageMetaData` | Yes | Image should be 16x9 ratio |
| `draft` | `Boolean` | No | Setting to `true` only displays the page in dev environments |

#### 🗒️ Posts
| Property | Type | Required | Notes |
Expand All @@ -106,7 +105,6 @@ Read more about why I chose these libraries and services on the [Built With](htt
| `date` | `String` | Yes | Value is passed to `new Date()` |
| `hasAmazonLinks` | `Boolean` | No | Default `false`. If `true` the [`<AmazonDisclosure>`](/~https://github.com/johnzanussi/johnzanussi.com/blob/main/src/components/AmazonDisclosure.astro) component will be rendered at the bottom of the post. |
| `hiddenIntro` | `Boolean` | No | Default `false`. If `true` and the post contains `## Intro` the resulting heading will be removed from the rendered page but the `Intro` link will remain in the table of contents. |
| `draft` | `Boolean` | No | Setting to `true` only displays the page in dev environments |

### 🧩 MDX Components
The following components are made available in all `.mdx` files without the need to explicitly import.
Expand Down
13 changes: 0 additions & 13 deletions src/components/DraftBadge.astro

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/PostCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getPostUrl } from '@/utils/collections';
import Card, { type Props as CardProps } from '@/components/Card.astro';
import DateFormat from '@/components/DateFormat.astro';
import DraftBadge from '@/components/DraftBadge.astro';
import { Image } from 'astro:assets';
import Link from '@/components/Link.astro';
Expand All @@ -26,7 +25,6 @@ const {
date,
title,
excerpt,
draft,
minutesRead,
} = data;
---
Expand All @@ -46,10 +44,6 @@ const {
{minutesRead}
</span>

{draft && (
<DraftBadge class="ms-2" />
)}

</div>

<h1 class="font-mono font-medium text-2xl md:text-3xl mb-2 md:mb-4">
Expand Down
2 changes: 0 additions & 2 deletions src/content.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const pageCollection = defineCollection({
title: z.string(),
excerpt: z.string().nullable(),
cover: image(),
draft: z.boolean().optional()
}),
});

Expand All @@ -29,7 +28,6 @@ const postCollection = defineCollection({
date: z.string().transform((date) => new Date(date)),
hasAmazonLinks: z.boolean().optional(),
hiddenIntro: z.boolean().optional(),
draft: z.boolean().optional(),
}),
});

Expand Down
6 changes: 0 additions & 6 deletions src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Layout from '@/layouts/Layout.astro';
import AmazonDisclosure from '@/components/AmazonDisclosure.astro';
import Comments from '@/components/Comments.astro';
import DateFormat from '@/components/DateFormat.astro';
import DraftBadge from '@/components/DraftBadge.astro';
import EnjoyCTA from '@/components/EnjoyCTA.astro';
import Markdown from '@/components/Markdown.astro';
import PostPagination from '@/components/PostPagination.astro';
Expand Down Expand Up @@ -52,7 +51,6 @@ const {
title,
date,
excerpt,
draft,
minutesRead,
hasAmazonLinks = false,
hiddenIntro = false,
Expand Down Expand Up @@ -130,10 +128,6 @@ const includeSidebar = headings && !!headings.length;

<Emoji label="stopwatch" class="me-1">⏱️</Emoji> {minutesRead}

{draft && (
<DraftBadge class="ms-2" />
)}

</p>

</div>
Expand Down
11 changes: 2 additions & 9 deletions src/utils/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,10 @@ const collectionUrls = {
pages: '/',
};

const isDev = import.meta.env.MODE === 'development';

export const getItems = async (
collection: ContentCollectionKey,
includeDrafts = isDev
collection: ContentCollectionKey
) => {
const draftFilter = !includeDrafts
? (item: CollectionEntry<ContentCollectionKey>) => 'draft' in item.data && !item.data.draft
: undefined;

const items = await getCollection(collection, draftFilter);
const items = await getCollection(collection);

return items;
};
Expand Down

0 comments on commit 28051e1

Please sign in to comment.