Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const filenamifyUrl = require('filenamify-url');
import filenamifyUrl from 'filenamify-url';
import rssPlugin from '@11ty/eleventy-plugin-rss';
import shuffle from './filters/shuffle.js';
import { minify } from 'html-minifier-next';

const rssPlugin = require('@11ty/eleventy-plugin-rss');
// const lazyImagesPlugin = require('eleventy-plugin-lazyimages');

const shuffle = require('./filters/shuffle.js');
const { minify } = require('html-minifier-next');

require('dotenv').config();

module.exports = (eleventyConfig) => {
export default (eleventyConfig) => {
// Pass through
eleventyConfig.addPassthroughCopy('assets');

Expand All @@ -30,8 +25,7 @@ module.exports = (eleventyConfig) => {
// Filters
eleventyConfig.addFilter('shuffle', shuffle);
eleventyConfig.addFilter('cleanUrl', (str) => {
const urlCruft = /http[s]?:\/\/|\/$/gi;
return str.replace(urlCruft, '');
return str.replace(/^https?:\/\/| \/$/gi, '');
});

// Minify
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
node_modules
_site

# IDE / editor specific ignores
.idea/
.vscode/

# Local Netlify folder
.netlify

*.env
*.env
4 changes: 0 additions & 4 deletions .vscode/settings.json

This file was deleted.

38 changes: 15 additions & 23 deletions buildSites.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const fs = require('fs');
const https = require('https');
const cloudinary = require('cloudinary').v2;
const frontMatter = require('front-matter');
const captureWebsite = require('capture-website');
const filenamifyUrl = require('filenamify-url');
const { resolve } = require('path');

require('dotenv').config();
import fs from 'node:fs';
import https from 'node:https';
import { v2 as cloudinary } from 'cloudinary';
import frontMatter from 'front-matter';
import captureWebsite from 'capture-website';
import filenamifyUrl from 'filenamify-url';

cloudinary.config({
cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
Expand Down Expand Up @@ -36,7 +33,7 @@ const getSites = () => {
const getScreenshot = async (site) => {
// TODO — Check if screenshot exists in Cloudinary space before running Puppeteer
// TODO — Statically render URLs in template files
const doesntExist = await new Promise((resolve, reject) => {
const doesntExist = await new Promise((resolve) => {
https.get(cloudinary.url(site.title), (response) => {
if (response.statusCode !== 404) {
console.log(`${site.title} exists on cloudinary.`);
Expand All @@ -59,19 +56,14 @@ const getScreenshot = async (site) => {
}
}
};
(async () => {
const sites = await getSites();
(async () => {
for (const site of sites) {
await getScreenshot(site);
}
console.log(`
const sites = getSites();
for (const site of sites) {
await getScreenshot(site);
}

console.log(`
=====
Screenshots collection complete.
Screenshot collection complete.

Failed sites (may need to capture manually):
${failedSites.join(`\n`)}
${failedSites.length > 0 ? `Failed sites:\n${failedSites.join('\n')}. May need to capture manually.` : 'All sites captured successfully!'}
=====`);
})();
return;
})();
4 changes: 2 additions & 2 deletions feeds/all.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permalink: feed/all.xml
<subtitle>All sites from personalsit.es</subtitle>
<link href="https://personalsit.es/feed/all.xml" rel="self"/>
<link href="https://personalsit.es/"/>
<updated>{{ collections.sites | rssLastUpdatedDate }}</updated>
<updated>{{ collections.sites | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
<id>https://personalsit.es</id>
<author>
<name>Andy Bell</name>
Expand All @@ -18,7 +18,7 @@ permalink: feed/all.xml
<entry>
<title>{{ post.data.title }}</title>
<link href="{{ post.data.url }}"/>
<updated>{{ post.date | rssDate }}</updated>
<updated>{{ post.date | dateToRfc3339 }}</updated>
<id>{{ absolutePostUrl }}</id>
<content type="html"><![CDATA[
<h3>{{ post.data.title }}</h3>
Expand Down
2 changes: 1 addition & 1 deletion feeds/opml.njk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ permalink: feed/opml.opml
<?xml version="1.0" encoding="utf-8"?>
<opml version="1.0">
<head>
<dateCreated>{{ collections.sites | rssLastUpdatedDate }}</dateCreated>
<dateCreated>{{ collections.sites | getNewestCollectionItemDate | dateToRfc822 }}</dateCreated>
<title>Personal sites are awesome!</title>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion filters/shuffle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// From: https://github.com/Daplie/knuth-shuffle/blob/master/index.js
module.exports = function shuffle(items) {
export default function(items) {
var currentIndex = items.length,
temporaryValue,
randomIndex;
Expand Down
Loading