Skip to content

Commit

Permalink
Actually render drafts at build time (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-leri authored Apr 25, 2024
1 parent 26f6b2d commit 13dc28a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/lib/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<p class="menu-label">{$t("application.sidebar.articles")}</p>
<ul class="menu-list">
{#each categories as category}
<li>
<li class:is-hidden={category.draft}>
{$t(category.name)}
<ul>
{#each category.pages as page}
<li>
<li class:is-hidden={page.draft}>
<a
href={`/${$locale}/${category.slug}/${page.slug}`}
class:is-active={url === `/${$locale}${category.slug}/${page.slug}`}
Expand Down
1 change: 1 addition & 0 deletions src/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export interface Category {
slug: string;
index: number;
name: string;
draft: boolean;
pages: Page[];
}
3 changes: 1 addition & 2 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export async function load({ params }) {
draft: page_metadata.draft || false
};
})
// exlude draft pages
.filter((page) => !page.draft)
.sort((a, b) => a.index - b.index);

// get the metadata of each category from their yaml file
Expand All @@ -50,6 +48,7 @@ export async function load({ params }) {
? category_metadata.index
: Number.MAX_SAFE_INTEGER, // Put the categories with no index last
name: category_metadata.name,
draft: pages.length === pages.filter((page) => page.draft).length,
pages: pages
};
})
Expand Down

1 comment on commit 13dc28a

@Cozy-GitHub
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See preview on Cloudflare Pages: https://cec6ff12.developer-wiki.pages.dev

Please sign in to comment.