Skip to content

Instantly share code, notes, and snippets.

@henninghall
henninghall / sitemap.xml.tsx
Created October 13, 2019 15:38
sitemap.xml in next.js which is easy to extend with dynamic routes
// place in pages/sitemap.xml.tsx
const fs = require('fs')
import { endpoint } from '../config'
const Sitemap = () => null
Sitemap.getInitialProps = async ({ res }) => {
if (!res) return {}
const folder = 'pages'
res.setHeader('content-type', 'application/xml')
@henninghall
henninghall / gist:7997047851b17063fc510281e6fed269
Created February 12, 2023 13:04
git command to checkout PR from another fork
git config --global alias.pr '!f() { if [ $# -lt 1 ]; then echo "Usage: git pr <id> [<remote>] # assuming <remote>[=origin] is on GitHub"; else git checkout -q "$(git rev-parse --verify HEAD)" && git fetch -fv "${2:-origin}" pull/"$1"/head:pr/"$1" && git checkout pr/"$1"; fi; }; f'
# Usage: git pr 123 (where 123 is the number of the pr)