Skip to content

Commit

Permalink
Make title optional as we are expecting it to be optional in the pars…
Browse files Browse the repository at this point in the history
…edSteps object

Use ?? in please of || as suggested by linter

Remove conditional chaining as needsEnv will always have a value
  • Loading branch information
karannakra committed May 17, 2023
1 parent 4007938 commit b6a4d0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { defineCollection,z } from 'astro:content';

const setupCollection = defineCollection({
schema: z.object({
title: z.string(),
title: z.string().optional(),
needsEnv: z.array(z.string()),
}),
});
Expand Down
6 changes: 3 additions & 3 deletions src/pages/setup/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const parsedSteps: {
}[] = [];
for (const slug of checksOrder) {
const step = await getEntryBySlug('setup', slug);
const havePassed = step.data.needsEnv?.every((x) => {
const value = process.env[x] || import.meta.env[x];
const havePassed = step.data.needsEnv.every((x) => {
const value = process.env[x] ?? import.meta.env[x];
return value !== undefined && value !== false;
});
if (!havePassed && firstFail == '') {
Expand Down Expand Up @@ -61,7 +61,7 @@ for (const slug of checksOrder) {
<sl-details open={firstFail === step.slug}>
<h3 slot="summary" class="text-gray-600">
<span class="w-4 inline-block">{i + 1}.</span> {havePassed ? '' : ''}
{step.data.title || step.slug}
{step.data.title ?? step.slug}
</h3>
<div class="prose max-w-none bg-white px-4 py-2 my-2 rounded-md">
<Content />
Expand Down

0 comments on commit b6a4d0d

Please sign in to comment.