Skip to content

Commit a84bf8f

Browse files
committed
jpg glob is failing
1 parent 1c88769 commit a84bf8f

File tree

10 files changed

+72
-3
lines changed

10 files changed

+72
-3
lines changed

docs/working-notes/todo2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ https://lea.verou.me/blog/2023/going-lean/#public-or-private-repo%3F
200200
analytics, internationalisation, github issue template, small project
201201
https://github.com/wanoo21/tailwind-astro-starting-blog
202202

203+
// good blog design
204+
https://www.builder.io/blog/react-intersection-observer
205+
203206
-----------
204207
za local state mora react ili solid
205208
for state between pages nanostore with localStorage

docs/working-notes/todo3.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,17 @@ astro env vars sa schema
472472
astro component container, render component to string for rss
473473
css directive transitions
474474
remote collection 2.0, custom folder
475+
476+
-------------
477+
// gallery
478+
479+
480+
For lazy loading checkout unpic - https://unpic.pics/lib/
481+
482+
For image resizing I would use a CDN - depending on usage you might be able to use a free tier or pay very little.
483+
484+
For Gallery - https://benhowell.github.io/react-grid-gallery - which is client side React. For onscroll I used react-intersection-observer - https://www.builder.io/blog/react-intersection-observer
485+
486+
I hope this helps, sorry I can't share my code.
487+
------------
475488
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"object-treeify": "^4.0.1",
4949
"react": "^18.3.1",
5050
"react-dom": "^18.3.1",
51+
"react-grid-gallery": "^1.0.1",
5152
"reading-time": "^1.5.0",
5253
"sharp": "0.32.6",
5354
"tailwind-clip-path": "^1.0.0",

src/components/Gallery.astro

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
import { Image } from 'astro:assets';
3+
4+
import { IMAGE_SIZES } from '@/constants/image';
5+
6+
import type { ImageMetadata } from 'astro';
7+
8+
const getAllImagesMetadata = (): ImageMetadata[] => {
9+
//
10+
// src/assets/images/all-images/river9.jpg
11+
const imageModules = import.meta.glob<{ default: ImageMetadata }>(
12+
'/src/assets/images/all-images/*.{jpg}',
13+
{ eager: true }
14+
);
15+
16+
console.log('imageModules', imageModules);
17+
18+
const imagesMetadata = Object.keys(imageModules).map((path) => imageModules[path].default);
19+
return imagesMetadata;
20+
};
21+
22+
const imagesMetadata = getAllImagesMetadata();
23+
---
24+
25+
<ul>
26+
{
27+
imagesMetadata.map((image) => (
28+
<li>
29+
<Image {...IMAGE_SIZES.FIXED.MDX_XS_16_9} src={image} alt="my image" />
30+
</li>
31+
))
32+
}
33+
</ul>

src/constants/navigation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const NAVIGATION_ITEMS = [
2626
title: 'About',
2727
path: ROUTES.ABOUT,
2828
},
29+
{
30+
title: 'Gallery',
31+
path: ROUTES.GALLERY,
32+
},
2933
// {
3034
// title: 'Resume',
3135
// path: ROUTES.RESUME,

src/constants/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const ROUTES = {
1515
EXPLORE_TAGS: '/blog/explore/tags/',
1616
EXPLORE_CATEGORIES: '/blog/explore/categories/',
1717
DESIGN: '/design/',
18+
GALLERY: '/gallery/',
1819
/** maybe in future */
1920
DRAFTS: '/drafts/',
2021
_404: '/404/',

src/pages/about.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: '../layouts/Page.astro'
3-
title: 'About Me'
4-
description: 'Lorem ipsum dolor sit amet'
3+
title: 'About'
4+
description: 'About me page'
55
---
66

77
import { Image } from 'astro:assets';

src/pages/gallery.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
layout: '../layouts/Page.astro'
3+
title: 'Gallery'
4+
description: 'Image gallery'
5+
---
6+
7+
import Gallery from '../components/Gallery.astro';
8+
9+
<Gallery />

src/pages/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: '../layouts/Page.astro'
33
title: 'Home'
4-
description: 'Lorem ipsum dolor sit amet'
4+
description: 'Welcome to nemanjamitic.com'
55
---
66

77
import { Image } from 'astro:assets';

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5556,6 +5556,11 @@ react-dom@^18.3.1:
55565556
loose-envify "^1.1.0"
55575557
scheduler "^0.23.2"
55585558

5559+
react-grid-gallery@^1.0.1:
5560+
version "1.0.1"
5561+
resolved "https://registry.yarnpkg.com/react-grid-gallery/-/react-grid-gallery-1.0.1.tgz#51e9e920cb83df6c61fbd1f2c7eed7db3b6e5a1b"
5562+
integrity sha512-+fVd6fH9tm0W+UMgzRHET/gmzSs2/l2sGOuELLaHXMto6UhuZdscj9ILHOYe7hn0GBRUJiczMllsEs7OJz9uPA==
5563+
55595564
react-refresh@^0.14.2:
55605565
version "0.14.2"
55615566
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.2.tgz#3833da01ce32da470f1f936b9d477da5c7028bf9"

0 commit comments

Comments
 (0)