Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested asset imports #364

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Nested asset imports #364

wants to merge 2 commits into from

Conversation

sdl60660
Copy link
Contributor

Adjusts path in asset index files to scan all media in subdirectories instead of just at the top-level asset directory

… instead of just at the top-level asset directory
@sdl60660 sdl60660 requested a review from pandringa October 30, 2024 16:23
…erence issue that overrides attrs in different videos during reduce
Copy link
Member

@aendra-rininsland aendra-rininsland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -6,7 +6,7 @@ const DEFAULT_IMAGE_PROPS = {
// alt: ''
};

const images = sortFiles(import.meta.glob('./*.{png,jpg,jpeg,gif}', { eager: true })).reduce(
const images = sortFiles(import.meta.glob('./**/*.{png,jpg,jpeg,gif,svg}', { eager: true })).reduce(
(acc, [k, v]) => {
const [, name, count, size] =
k.match(/\/([-_\w]+)\.([0-9]+)?\.?([SMLX]+)?\.?(png|jpe?g|gif)$/) || [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to note - this regex will only extract the file name (not the path). If you want to be able to reference images like image: myfolder/myimage.jpg in the ArchieML doc (or images['myfolder/myimage'] in the code), we should add a forward slash / to the character list in the first group.

On the other hand, we could definitely leave it as is — but we'd have to guarantee all filenames are unique across the folders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants