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/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 }) diff --git a/netlify.toml b/netlify.toml index 068c665..c9cec96 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 = "/" 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..102f2ea 100644 --- a/pages/game/_slug/index.vue +++ b/pages/game/_slug/index.vue @@ -1,14 +1,19 @@