From d5c270f768cb0b6a6134e1ec6d58daa300e505ec Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 20 Mar 2021 18:11:25 -0500 Subject: [PATCH 1/6] Add story image function --- functions/story-image-axis.svg.js | 60 +++++++++++++++++++++++++++++++ netlify.toml | 11 +++--- 2 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 functions/story-image-axis.svg.js diff --git a/functions/story-image-axis.svg.js b/functions/story-image-axis.svg.js new file mode 100644 index 0000000..3ff5027 --- /dev/null +++ b/functions/story-image-axis.svg.js @@ -0,0 +1,60 @@ +exports.handler = async function(event, context) { + const { + //path, // Path parameter + //httpMethod, // Incoming request’s method name + // headers, // {Incoming request headers} + queryStringParameters, // {query string parameters } + // body, // A JSON string of the request payload + // isBase64Encoded, // A boolean flag to indicate if the applicable request payload is Base64-encode + } = event + + // console.log('queryStringParameters', queryStringParameters) + + const { + width = 200, + height = 100, + heading = 'Does It ARM' + } = queryStringParameters + + return { + statusCode: 200, + headers: { + 'Content-Type': 'image/svg+xml', + }, + body: /* html */` + + + + + + + + + + + + + + + + + + + + + + +
${ heading }
+
+
+ ` + } +} diff --git a/netlify.toml b/netlify.toml index 068c665..fa35c52 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,7 @@ [build] publish = "dist/" command = "npm run generate --quiet" + functions = "functions/" @@ -16,7 +17,7 @@ from = "/app/node" to = "/app/nodejs" status = 301 - + # old git redirect [[redirects]] from = "/app/git" @@ -34,16 +35,16 @@ from = "/kind/photo-tools" to = "/kind/photo-and-graphic-tools/" status = 301 - - + + # Other Redirects - + # Random broken link from Chinese sites [[redirects]] from = "/。" to = "/" status = 301 - + [[redirects]] from = "/%E3%80%82" to = "/" From dd50bfe3f52fe5130d79377491caadcd7aa8db9d Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 20 Mar 2021 18:16:03 -0500 Subject: [PATCH 2/6] Remove period from function name --- functions/{story-image-axis.svg.js => story-image-axis-svg.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename functions/{story-image-axis.svg.js => story-image-axis-svg.js} (100%) diff --git a/functions/story-image-axis.svg.js b/functions/story-image-axis-svg.js similarity index 100% rename from functions/story-image-axis.svg.js rename to functions/story-image-axis-svg.js From 5a94ad0ba7052d71c36e6778d1aad1c47904a000 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 20 Mar 2021 18:30:30 -0500 Subject: [PATCH 3/6] Disable functions for now --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index fa35c52..c9cec96 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,7 @@ [build] publish = "dist/" command = "npm run generate --quiet" - functions = "functions/" + # functions = "functions/" From e2dcf8bac4dde8a5f6625c451327011a53c5fb63 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 10 Apr 2021 16:13:16 -0500 Subject: [PATCH 4/6] Exclude youtube thumbnails larger that 700px wide --- helpers/build-video-list.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/helpers/build-video-list.js b/helpers/build-video-list.js index bbc946a..10e3e01 100644 --- a/helpers/build-video-list.js +++ b/helpers/build-video-list.js @@ -84,23 +84,31 @@ const generateVideoTags = function ( video ) { return videoTags } -const makeThumbnailData = function ( thumbnails ) { +const makeThumbnailData = function ( thumbnails, widthLimit = null ) { + + const thumbnailEntries = Object.entries( thumbnails ) + const srcsetArray = [] let maxWidth = 0 - Object.entries( thumbnails ).forEach(([thumbnailKey, thumbnail]) => { + + thumbnailEntries.forEach(([thumbnailKey, thumbnail]) => { + if ( widthLimit !== null && widthLimit < thumbnail.width) return + + // If this width is more than known maxWidth + // then set maxWidth if (thumbnail.width > maxWidth) maxWidth = thumbnail.width + + // Add this width to our srcset + srcsetArray.push(`${thumbnail.url} ${thumbnail.width}w`) }) + const sizes = `(max-width: ${maxWidth}px) 100vw, ${maxWidth}px` - - const srcset = Object.entries( thumbnails ).map(([thumbnailKey, thumbnail]) => { - // console.log('thumbnail', thumbnail) - return `${thumbnail.url} ${thumbnail.width}w` - }).join(', ') - - + const srcset = srcsetArray.join(', ') const src = thumbnails.default.url + // console.log('srcsetArray', srcsetArray) + return { sizes, srcset, @@ -170,7 +178,7 @@ export default async function ( applist ) { tags: Array.from(tags), timestamps: fetchedVideos[videoId].timestamps, // thumbnails: fetchedVideos[videoId].rawData.snippet.thumbnails, - thumbnail: makeThumbnailData( fetchedVideos[videoId].rawData.snippet.thumbnails ), + thumbnail: makeThumbnailData( fetchedVideos[videoId].rawData.snippet.thumbnails, 700 ), endpoint: getVideoEndpoint({ slug }) From bcf3f6cb89386ae23f272297095ee792e88274c2 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sat, 10 Apr 2021 17:04:34 -0500 Subject: [PATCH 5/6] Push related video below fold on app and games --- pages-eleventy/app.11ty.js | 2 +- pages/game/_slug/index.vue | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pages-eleventy/app.11ty.js b/pages-eleventy/app.11ty.js index 5e4c818..9c62842 100644 --- a/pages-eleventy/app.11ty.js +++ b/pages-eleventy/app.11ty.js @@ -94,7 +94,7 @@ export class AppTemplate { return /* html */`
-
+

${ data.mainHeading }

diff --git a/pages/game/_slug/index.vue b/pages/game/_slug/index.vue index 5cf5d5a..f67121e 100644 --- a/pages/game/_slug/index.vue +++ b/pages/game/_slug/index.vue @@ -1,14 +1,19 @@