Skip to content

Commit

Permalink
Merge pull request #28 from john-kurkowski/lost-pixel
Browse files Browse the repository at this point in the history
* Copy Lost Pixel getting started instructions
* Bump actions versions
* Test Gatsby production build, instead of development server
* Copy npm scripts from newer upstream Gatsby starter
* Allow visiting production build via IP
* List all routes for testing
* Upgrade ECMAScript version, for newer string matching functions
  • Loading branch information
john-kurkowski committed Apr 3, 2024
2 parents dc6c6c5 + 2b76677 commit 413a501
Show file tree
Hide file tree
Showing 5 changed files with 1,054 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/vrt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [push]

jobs:
build:
runs-on: ubuntu-latest
name: Lost Pixel

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.12.0

- name: Install dependencies
run: npm install

- name: Build app
run: npm run build

- name: Start server (in background)
run: npm run serve &

- name: Lost Pixel
uses: lost-pixel/lost-pixel@v3.16.0
env:
LOST_PIXEL_API_KEY: ${{ secrets.LOST_PIXEL_API_KEY }}
31 changes: 31 additions & 0 deletions lostpixel.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CustomProjectConfig } from 'lost-pixel'
import { readFileSync } from 'fs'
import { join } from 'path'

function pagePaths(): string[] {
const siteUrl = 'https://johnkurkowski.com'
const sitemapXml = readFileSync(
join(__dirname, 'public', 'sitemap-0.xml'),
'utf-8',
)
const urlsRe = new RegExp(`${siteUrl}(/[^<]*)`, 'g')
return Array.from(sitemapXml.matchAll(urlsRe)).map(function ([, url]) {
return url.replaceAll('&amp;', '&')
})
}

function slugify(str: string): string {
const replaced = str.replaceAll('/', '-')
const stripped = replaced.replaceAll(/(^-+|-+$)/g, '')
return stripped ? stripped : 'index'
}

export const config: CustomProjectConfig = {
apiKey: process.env.LOST_PIXEL_API_KEY,
breakpoints: [414, 1280],
lostPixelProjectId: 'clud602ae10romo0e861bvpv2',
pageShots: {
pages: pagePaths().map((path) => ({ path, name: slugify(path) })),
baseUrl: 'http://172.17.0.1:9000',
},
}
Loading

0 comments on commit 413a501

Please sign in to comment.