Skip to content

Commit

Permalink
feat: add contributors and badge to doc pages (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalaforge committed Nov 22, 2023
1 parent 746c0fc commit 06b86a9
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export default defineConfig({
autogenerate: { directory: 'utilities' },
},
],
components: {
PageTitle: './src/components/PageTitle.astro',
MarkdownContent: './src/components/Content.astro',
},
}),
],
});
19 changes: 19 additions & 0 deletions docs/src/components/Content.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
import Default from '@astrojs/starlight/components/MarkdownContent.astro';
import type { Props } from '@astrojs/starlight/props';
const {contributor} = Astro.props.entry.data;
---

{ contributor && <p class="contributor">Created by {contributor}</p> }

<Default {...Astro.props}><slot /></Default>

<style>
.contributor {
margin-top: -1rem;
font-size: var(--sl-text-xs);
color: var(--sl-color-gray-3);
}
</style>
37 changes: 37 additions & 0 deletions docs/src/components/PageTitle.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
import Default from '@astrojs/starlight/components/PageTitle.astro';
import type { Props } from '@astrojs/starlight/props';
const badge = Astro.props.entry.data.badge;
---

<div class="page-title-content">
<Default {...Astro.props}><slot /></Default>
{badge && <div class="chip">{badge}</div> }
</div>

<style>
.page-title-content {
display: flex;
justify-content: space-between;
align-items: center;
}

@media (max-width: 1010px) {
.page-title-content {
flex-direction: column;
align-items: flex-start;
}
}

.chip {
border-width: 1px;
border-style: solid;
border-radius: 6px;
padding: 2px 8px;
color: var(--sl-color-text);
width: fit-content;
height: fit-content;
margin-top: 1rem;
}
</style>
10 changes: 8 additions & 2 deletions docs/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { defineCollection } from 'astro:content';
import { defineCollection, z } from 'astro:content';

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
docs: defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
badge: z.enum(['stable', 'unstable', 'experimental']).optional(),
contributor: z.string().optional(),
}),
}),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
};
2 changes: 2 additions & 0 deletions docs/src/content/docs/utilities/Operators/filter-array.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: filterArray
description: An RxJS operator to simplify the process of filtering arrays within an Observable stream.
badge: stable
contributor: Thomas Laforge
---

## Import
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/utilities/Operators/filter-nil.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: filterNil
description: An RxJS operator designed to filter out `undefined` and `null` values from an Observable stream, returning a strongly-typed value.
badge: stable
contributor: Thomas Laforge
---

## Import
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/utilities/Operators/map-array.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: mapArray
description: An RxJS operator designed to apply a map function to an array within an Observable stream, simplifying array transformations.
badge: stable
contributor: Thomas Laforge
---

## Import
Expand Down

0 comments on commit 06b86a9

Please sign in to comment.