this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

๐Ÿง‘๐Ÿ’ป Display astro.locals and link build commit to github

Signed-off-by: Gwenn Le Bihan <gwenn.lebihan7@gmail.com>

+13 -4
+2
src/env.d.ts
··· 5 5 namespace App { 6 6 interface Locals { 7 7 lang: "fr" | "en"; 8 + locale?: `${Locals["lang"]}-${string}`; 9 + buildCommit?: string; 8 10 } 9 11 }
+6 -1
src/layouts/Layout.astro
··· 69 69 } 70 70 </ul> 71 71 72 - <pre>{Astro.locals.commit}</pre> 72 + <pre 73 + set:html={JSON.stringify(Astro.locals).replace( 74 + Astro.locals.buildCommit ?? "", 75 + `<a href=https://github.com/gwennlbh/portfolio/commit/${Astro.locals.buildCommit}>${Astro.locals.buildCommit}</a>`, 76 + )} 77 + /> 73 78 </footer> 74 79 </body> 75 80 </html>
+5 -3
src/middleware.ts
··· 1 1 import { defineMiddleware } from "astro:middleware"; 2 - import { getCollection, getEntry } from "astro:content"; 2 + import { getEntry } from "astro:content"; 3 3 import { JSDOM } from "jsdom"; 4 4 5 5 export const onRequest = defineMiddleware(async ({ locals, url }, next) => { 6 6 locals.lang = process.env.LANG === "fr" ? "fr" : "en"; 7 - locals.locale = process.env.LOCALE; 8 - locals.commit = process.env.BUILD_COMMIT; 7 + locals.locale = process.env.LOCALE as 8 + | `${typeof locals.lang}-${string}` 9 + | undefined; 10 + locals.buildCommit = process.env.BUILD_COMMIT; 9 11 const response = await next(); 10 12 const dom = new JSDOM(await response.text(), { 11 13 url: url.toString(),