Skip to content

Commit

Permalink
Add blog images in src/assets/blog/
Browse files Browse the repository at this point in the history
Load the image from frontmatter using the <Image> tag in [slug].astro.
  • Loading branch information
fwextensions committed Jan 13, 2024
1 parent 30fbd31 commit 2278475
Show file tree
Hide file tree
Showing 77 changed files with 51 additions and 31 deletions.
Binary file added packages/astro/src/assets/blog/EthanAbroad.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/IMG_1846.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/IMG_2066.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/IMG_2084.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/NDoCH-2019.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/adopt-a-drain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/carla.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/cfa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/cliffhouse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/codeforsf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/congress.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/datasette.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/dswg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/dvirc-masthead.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/dvirc-masthead.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/fire-risk.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/first.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/gyver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/headshot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/astro/src/assets/blog/image.png
Binary file added packages/astro/src/assets/blog/image10.jpg
Binary file added packages/astro/src/assets/blog/image11.png
Binary file added packages/astro/src/assets/blog/image13.jpg
Binary file added packages/astro/src/assets/blog/image14.jpg
Binary file added packages/astro/src/assets/blog/image15.png
Binary file added packages/astro/src/assets/blog/image16.jpg
Binary file added packages/astro/src/assets/blog/image17.jpg
Binary file added packages/astro/src/assets/blog/image18.jpg
Binary file added packages/astro/src/assets/blog/image20.jpg
Binary file added packages/astro/src/assets/blog/image7.png
Binary file added packages/astro/src/assets/blog/jason.jpg
Binary file added packages/astro/src/assets/blog/jen.jpg
Binary file added packages/astro/src/assets/blog/logo.png
Binary file added packages/astro/src/assets/blog/meagan.jpg
Binary file added packages/astro/src/assets/blog/microsoft.png
Binary file added packages/astro/src/assets/blog/nltweets.jpg
Binary file added packages/astro/src/assets/blog/nltweets2.png
Binary file added packages/astro/src/assets/blog/odsc.png
Binary file added packages/astro/src/assets/blog/osm.jpg
Binary file added packages/astro/src/assets/blog/panel.jpg
Binary file added packages/astro/src/assets/blog/prep.jpg
Binary file added packages/astro/src/assets/blog/sanat.jpg
Binary file added packages/astro/src/assets/blog/sandra.jpg
Binary file added packages/astro/src/assets/blog/screenshot.jpg
Binary file added packages/astro/src/assets/blog/screenshot.png
Binary file added packages/astro/src/assets/blog/segment.png
Binary file added packages/astro/src/assets/blog/sf-crime-data.png
Binary file added packages/astro/src/assets/blog/sign.jpg
Binary file added packages/astro/src/assets/blog/speaker.jpg
Binary file added packages/astro/src/assets/blog/team.jpg
Binary file added packages/astro/src/assets/blog/twabler.jpg
Binary file added packages/astro/src/assets/blog/unconference.jpg
Binary file added packages/astro/src/assets/blog/visualization.png
Binary file added packages/astro/src/assets/blog/vr.jpg
Binary file added packages/astro/src/assets/blog/wevote-logo.gif
Binary file added packages/astro/src/assets/blog/wevote.png
Binary file added packages/astro/src/assets/blog/wordcloud.png

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
23 changes: 22 additions & 1 deletion packages/astro/src/pages/blog/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
import type { ImageMetadata } from "astro";
import { Image } from "astro:assets";
import { getCollection } from "astro:content";
import BaseLayout from "@/layouts/BaseLayout.astro";
Expand All @@ -16,10 +18,29 @@ export async function getStaticPaths()
}));
}
const { entry: { render, data: { title } } } = Astro.props;
const { entry: { render, data: { title, image, image_alt = "" } } } = Astro.props;
const { Content } = await render();
let imageSrc;
if (image) {
// this Vite import method requires that its parameter be a literal string, not even one assembled from other literals
const images = import.meta.glob<{ default: ImageMetadata }>("/src/assets/blog/*.{jpeg,jpg,png,gif}");
const imagePath = "/src/assets/blog/" + image.replace(/^\/img\/uploads\//, "");
if (images[imagePath]) {
imageSrc = images[imagePath]();
} else {
console.error(`${title} missing image: ${imagePath}`);
}
}
---

<BaseLayout title={title}>
{
imageSrc &&
<p>
<Image src={imageSrc} alt={image_alt} />
</p>
}
<Content />
</BaseLayout>
4 changes: 1 addition & 3 deletions packages/astro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"strict": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
"@/*": ["./src/*"],
}
}
}

0 comments on commit 2278475

Please sign in to comment.