Skip to content

Instantly share code, notes, and snippets.

View diboune's full-sized avatar

Mohamed Amine Diboune diboune

View GitHub Profile
@diboune
diboune / configure.ts
Created March 18, 2024 09:30
Configure website pathname
import { z } from "zod";
export type Locale = z.input<typeof localeSchema>;
const localeSchema = z.object({
name: z.string(),
path: z.string(),
default: z.boolean().optional(),
dir: z.enum(["ltr", "rtl"]).optional().default("ltr"),
metadata: z.record(z.unknown()).optional().default({}),
@diboune
diboune / test.tsx
Last active November 22, 2023 22:40
Fetcher Error Handling
import { useFetcher } from "@remix-run/react";
import { Control, Field, Message, Root, Submit } from "@radix-ui/react-form";
import { useEffect, useState } from "react";
import { type DataFunctionArgs } from "@remix-run/node";
export default function Testing() {
const { Form, data } = useFetcher<typeof action>();
const [error, setError] = useState(false);
useEffect(() => {
{% comment %}
Lazily importing css stylesheets, without blocking the document download.
Accepts:
- sheets: `string` of the css files seperated by `,`.
Usage:
{% render 'stylesheet-import', sheets: 'component.css,not-component.css' %}
{% endcomment %}
@diboune
diboune / routes_gen.mjs
Last active August 29, 2023 00:53
Remix routes id as an array
// 1. copy and paste this in a remix project base directory.
// 2. run `node routes_gen.mjs <optional routes folder default to "./app/routes"> <optional output file default to "./app/routes.ts">`
// 3. you get a cool string[] of all the routes ids in a file inside your project
import fs from "fs";
import path from "path";
const routesFolder = process.argv[2] || "./app/routes/";
const outputFile = process.argv[3] || "./app/routes.ts";
import { sql } from "@vercel/postgres";
import { drizzle } from "drizzle-orm/vercel-postgres";
import { migrate } from "drizzle-orm/vercel-postgres/migrator";
import "dotenv/config";
async function runMigrate() {
if (!process.env.POSTGRES_DATABASE) {
throw new Error("POSTGRES_DATABASE is not defined");
}