Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@treckstar
treckstar / schema.json
Last active May 18, 2023 16:34
Oh My Posh Theme
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://gist.githubusercontent.com/treckstar/175547806360c7f2c81cc961ad8037f1/raw/treckstar.omp.json",
"type": "object",
"title": "The Oh My Posh theme definition",
"description": "https://ohmyposh.dev/docs/configuration/overview",
"definitions": {
"color": {
"anyOf": [
{
@treckstar
treckstar / [[...slug]].tsx
Created May 11, 2023 18:59
Next.js TypeScript Localization Proof of Concept for `output: 'export'` builds
import { GetStaticPaths, GetStaticProps } from 'next';
type Locale = 'en-US' | 'es' | 'hm';
type PageData = {
// Define the properties you need for your page data
title: string;
content: string;
};
@treckstar
treckstar / UniformSitemap.js
Created April 11, 2023 19:20
Sitemap.xml Generator using next-sitemap, uniformdev, & contentful
// Import required packages and functions
const fs = require('fs');
const { SitemapStream, streamToPromise } = require('sitemap');
const { createGzip } = require('zlib');
const { getSiteMapUrls } = require('@uniformdev/next-jss/server');
// Set up Uniform and Contentful credentials
const UNIFORM_API_KEY = process.env.UNIFORM_API_KEY;
const CONTENTFUL_SPACE_ID = process.env.CONTENTFUL_SPACE_ID;
const CONTENTFUL_ACCESS_TOKEN = process.env.CONTENTFUL_ACCESS_TOKEN;
@treckstar
treckstar / ActiveState.tsx
Created April 10, 2023 19:17
Set active class using state & withRouter in TypeScript class based components
import React from 'react';
import { withRouter, Router } from 'next/router';
interface IndexProps {
router: Router;
}
interface IndexState {
activeLink: string;
}
@treckstar
treckstar / ImageLoader.tsx
Created April 6, 2023 18:37
Class based Image loader
import React from "react";
import { Image, ImageProps } from "next/image";
type ImageLoaderProps = Omit<ImageProps, "src"> & {
src: string;
};
class ImageLoader extends React.Component<ImageLoaderProps> {
public loader({ src, width, quality }: ImageLoaderProps): string {
return `${src}?w=${width}&q=${quality || 75}`;
@treckstar
treckstar / ContentfulLoader.tsx
Last active April 6, 2023 18:32
Class based next/image loader for Contentful
import React from "react";
import { Image, ImageProps } from "next/image";
import { createClient } from "contentful";
type ContentfulImage = {
fields: {
file: {
url: string;
details: {
image: {
@treckstar
treckstar / LocaleSwitcher.tsx
Last active April 5, 2023 15:11
Class Based TypeScript React.Component - Locale Switcher
import React from 'react';
import { useRouter } from 'next/router';
type Props = {
locales: string[];
currentLocale: string;
};
class LocaleSwitcher extends React.Component<Props> {
private handleLocaleChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
@treckstar
treckstar / LocaleSwitcher.tsx
Created April 5, 2023 15:04
Class Based TypeScript React.Component - Locale Switcher Menu
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
type Locale = {
locale: string;
label: string;
};
type Props = {
@treckstar
treckstar / awesome-possum.txt
Created December 22, 2022 20:13
Random 😎 Sites for Hope & Inspiration
my personal strapi + gatsby + plain custom + tailwindcss + headlessui + framermotion
this site was never finished which is why some things look out of place
https://www.treckstar.net
The monorepo for above
https://github.com/treckstar/grapsbi
Gatsby Plugins I use/like
https://github.com/treckstar/grapsbi/blob/main/frontend/package.json
Packaged with PNPM
https://pnpm.io/
@treckstar
treckstar / .bashrc
Created October 2, 2022 10:26
Ubuntu 18.04 - 20.04
#!/bin/bash
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
#
# These are just some functions to add into the ~/.bashrc file
# Modified print_r command to output color without installing any themes
# Normally around line #118 these can be placed. I always put them at the end of file.
# You must restart the terminal after updating the ~/.bashrc file
cecho(){