Skip to content

Commit

Permalink
feat: add collection for contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalaforge committed Nov 23, 2023
1 parent 1b1efe2 commit 8bbd35a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 14 deletions.
6 changes: 4 additions & 2 deletions docs/src/components/Content.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
import Default from '@astrojs/starlight/components/MarkdownContent.astro';
import type { Props } from '@astrojs/starlight/props';
import { getEntry } from 'astro:content';
import Contributor from './Contributor.astro';
const {contributor} = Astro.props.entry.data;
const contributor = Astro.props.entry.data.contributor ? await getEntry(Astro.props.entry.data.contributor) : null;
---

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

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

Expand Down
41 changes: 41 additions & 0 deletions docs/src/components/Contributor.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
import { Icon } from '@astrojs/starlight/components';
interface Props {
name: string;
twitter?: string;
linkedin?: string;
github?: string;
}
const { name, twitter, linkedin, github } = Astro.props;
---

<p class="contributor">
Created by {name}
{twitter && <a href={twitter}><Icon class='icon' name="twitter" size="0.75rem" /></a>}
{linkedin && <a href={linkedin}><Icon class='icon' name="linkedin" size="0.75rem" /></a>}
{github && <a href={github}><Icon class='icon' name="github" size="0.75rem" /></a>}

</p>

<style>
.contributor {
display: flex;
gap: 0.5rem;
align-items: center;
margin-top: -1rem;
font-size: var(--sl-text-xs);
color: var(--sl-color-gray-3);
}

.icon {
vertical-align: middle;
color: var(--sl-color-gray-3);

&:hover {
color: var(--sl-color-accent-high)
}
}
</style>
33 changes: 24 additions & 9 deletions docs/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { defineCollection, z } from 'astro:content';
import { defineCollection, reference, z } from 'astro:content';

export const collections = {
docs: defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
badge: z.enum(['stable', 'unstable', 'experimental']).optional(),
contributor: z.string().optional(),
}),
const contributors = defineCollection({
type: 'data',
schema: z.object({
name: z.string(),
twitter: z.string().url().optional(),
linkedin: z.string().url().optional(),
github: z.string().url().optional(),
}),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
});

const docs = defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
badge: z.enum(['stable', 'unstable', 'experimental']).optional(),
contributor: reference('contributors').optional(),
}),
});

const i18n = defineCollection({ type: 'data', schema: i18nSchema() });

export const collections = {
docs: docs,
i18n: i18n,
contributors: contributors,
};
6 changes: 6 additions & 0 deletions docs/src/content/contributors/thomas-laforge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Thomas Laforge",
"twitter": "https://twitter.com/laforge_toma",
"linkedin": "https://www.linkedin.com/in/thomas-laforge-2b05a945/",
"github": "https://github.com/tomalaforge"
}
2 changes: 1 addition & 1 deletion docs/src/content/docs/utilities/Operators/filter-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: filterArray
description: An RxJS operator to simplify the process of filtering arrays within an Observable stream.
badge: stable
contributor: Thomas Laforge
contributor: thomas-laforge
---

## Import
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/utilities/Operators/filter-nil.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
contributor: thomas-laforge
---

## Import
Expand Down
2 changes: 1 addition & 1 deletion docs/src/content/docs/utilities/Operators/map-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
contributor: thomas-laforge
---

## Import
Expand Down

0 comments on commit 8bbd35a

Please sign in to comment.