Skip to content

Instantly share code, notes, and snippets.

View laneparton's full-sized avatar

Lane Parton laneparton

View GitHub Profile
@laneparton
laneparton / GenerateMeta.js
Last active December 1, 2023 01:38
An Astro integration that generates a meta description and writes it to markdown files.
import fs from 'fs';
import path from 'path';
import matter from 'gray-matter';
import OpenAI from 'openai';
import { remark } from 'remark';
import strip from 'strip-markdown';
async function markdownToPlainText(parsedMarkdown) {
const result = await remark().use(strip).process(parsedMarkdown.content);
return String(result.value);
@laneparton
laneparton / gatsby-webhook.js
Last active August 3, 2022 14:36
A webhook that builds Gatsby via an Express endpoint with a FIFO queue.
const express = require("express");
const util = require("util");
const moment = require("moment"); // require
const exec = util.promisify(require("child_process").exec);
require("dotenv").config();
// Overall, it isn't clear what the best method of building these webhooks is.
// Is Express the answer? Is an entirely different language more efficient than Node?
// I'm leaning towards Node primarily because Gatsby builds with Node (we already need the node image)
const app = express();
@laneparton
laneparton / gatsby-cypress-endpoints.js
Last active June 7, 2022 00:55
Save all Gatsby pages to a Cypress fixture.
// gatsby-node.js
const path = require("path");
const fs = require("fs").promises;
exports.createPages = async ({ graphql, actions }) => {
if (process.env.NODE_ENV === "development") {
const { data } = await graphql(`
{
pages: allSitePage {
nodes {
@laneparton
laneparton / test-gatsby-link.jsx
Created September 28, 2021 22:07
Just showing state based on getProps in Reach Router <Link>