Skip to content

Instantly share code, notes, and snippets.

View notrab's full-sized avatar

Jamie Barton notrab

View GitHub Profile
@patrikalienus
patrikalienus / r_pages.11tydata.js
Last active April 19, 2021 14:36
Pages in 11ty from consumed GraphCMS data with localization
require("dotenv").config(); // Store of GCMS_ENDPOINT and GCMS_TOKEN
const { gql } = require("graphql-request");
const { GraphQLClient } = require("graphql-request");
const client = new GraphQLClient(process.env.GCMS_ENDPOINT);
const requestHeaders = {
authorization: "Bearer " + process.env.GCMS_TOKEN,
};
@steven-tey
steven-tey / title-from-url.ts
Last active November 13, 2025 06:54
Get Title from URL
// Note: this gist is a part of this OSS project that I'm currently working on: https://github.com/steven-tey/dub
export default async function getTitleFromUrl (url: string) {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 2000); // timeout if it takes longer than 2 seconds
const title = await fetch(url, { signal: controller.signal })
.then((res) => {
clearTimeout(timeoutId);
return res.text();
})