Skip to content

Instantly share code, notes, and snippets.

View rileybathurst's full-sized avatar

Riley rileybathurst

View GitHub Profile
@rileybathurst
rileybathurst / OrTypesPage.tsx
Created June 22, 2024 18:14
A couple of different or types
import * as React from "react"
interface MessageBasics {
other: string;
}
interface MessageWithlabel {
label: string;
title?: never
}
interface MessageWithTitle {
label?: never;
@rileybathurst
rileybathurst / service.tsx
Created June 22, 2024 17:02
working out a cleaner string replace
const adj: { [key: string]: string } = {
wedding: 'special day',
residential: 'home',
commercial: 'business',
'commercial-events': 'business',
'social_events': 'event',
patio: 'patio'
};
const adjective = adj[data.strapiService.slug];
@rileybathurst
rileybathurst / test.tsx
Created June 22, 2024 17:01
unicorns are good dinos are bad
import * as React from "react"
interface BasicTypes {
other: string;
}
interface withLabel extends BasicTypes {
label: string;
title?: never;
}
interface withTitle extends BasicTypes {
label?: never;
@rileybathurst
rileybathurst / vendors.tsx
Created June 19, 2024 18:45
grab all the version of a strapi query and loop them in gatsby
import * as React from "react"
import { Link, useStaticQuery, graphql } from 'gatsby';
import { SEO } from "../components/seo";
import Header from "../components/header";
import Footer from "../components/footer";
import Card from "../components/card";
import type { CardType } from "../types/card-type";
@rileybathurst
rileybathurst / seo.tsx
Last active June 12, 2024 23:54
current but maybe still kinda not quite right version
import React from "react";
import { Script, useStaticQuery, graphql } from "gatsby";
interface BreadcrumbsTypes {
url: string;
[key: number]: {
name: string;
item: string;
};
}[]
import * as React from "react";
interface BreadcrumbTypes {
name: string;
item: string;
}
function Breadcrumb(breadcrumbs: BreadcrumbTypes[]) {
return (
<>
test
@rileybathurst
rileybathurst / text.astro
Created June 11, 2024 22:25
astro with strapi blocks render
<div class="pre-wrap">
<BlocksRenderer content={contact.attributes.postal} />
</div>
<style>
.pre-wrap {
white-space: pre-wrap;
}
</style>
@rileybathurst
rileybathurst / strapi.ts
Created June 11, 2024 20:03
The documentation I was using for strapi wasnt giving a polouate so I was missing pieces
import qs from "qs";
interface Props {
endpoint: string;
query?: Record<string, string>;
wrappedByKey?: string;
wrappedByList?: boolean;
// https://docs.strapi.io/dev-docs/api/query-engine/populating
populate?: {
[key: string]: {
@rileybathurst
rileybathurst / spec.tsx
Last active June 10, 2024 01:14
Working on a type safe way of showing variable info
import * as React from "react"
interface SpecsTypes {
[key: string]: string | number | boolean;
}
function Specs(keyValuePairs: SpecsTypes) {
return (
Object.entries(keyValuePairs).map(([key, value]) => {
if (key === 'length' && typeof value === 'number') {
@rileybathurst
rileybathurst / keyValue.tsx
Created June 5, 2024 04:10
Working on an idea for how im returning objects that can be split betwen elements on a page
import * as React from "react";
interface tTTypes {
start?: string;
finish?: string;
duration?: number;
key?: string | null;
unit?: string | null;
}
const tT = ({ start, finish, duration, key, unit }: tTTypes) => {