Skip to content

Instantly share code, notes, and snippets.

@AceCodePt
AceCodePt / generate-routes.mts
Last active August 10, 2023 13:37
Generate NextJS safe Routing (don't forget to install glob)
import * as fs from "fs";
import * as glob from "glob";
const routes = glob.globSync("**/app/**/route.ts", {});
const constDef: string[] = [];
const typeDef: string[] = [];
const routeTypes: string[] = [];
function toConstDef(varName: string, path: string): string {
@AceCodePt
AceCodePt / hx-astro-view-transition.js
Last active October 29, 2023 17:30
htmx-astro-view-transition
htmx.defineExtension("hx-astro-view-transition", {
onEvent: function (name, evt: any) {
if (name === "htmx:afterRequest") {
const attributes = evt.target.attributes;
const viewTransitionTarget =
attributes["hx-view-transition"]?.value;
if (!viewTransitionTarget) {
console.log(evt);
return;
}