#Built-in method for listing directories

13 messages · Page 1 of 1 (latest)

cedar sparrow
#

Hi, I'm looking for a built-in method for listing directories so that I don't need to use fs. Or alternatively, is there a way for me to properly integrate fs because the module isn't detectable after npm install fs

jagged jungle
#

Hi. Could you try uninstalling fs? Fs is a native module in nodejs and should not need installing. It might actually make the default fs package inaccessible

#

Also, how exactly did you install fs? npmjs.com doesn’t even list it as a package

cedar sparrow
#

However I still don't know where I should import it from. Within the .astro file I want to use it in or in astro.config.mjs?

#

Also is it possible to use Astro.glob() for listing directories?

cedar sparrow
loud vault
#

why do you need access to the file system? You might have an easier time using astro's built in functionality.

cedar sparrow
#

Cause I wanted to automate the creation of pages from directory names which hosted links towards the actual sub-collection content. As of now, I still don't know or can't figure out any built-in function or technique to do that, so I did it the ugly way.

#

The smart way would have probably been to generate a "tree" of some sort and iterate through it to generate each page

loud vault
cedar sparrow
#

I meant featured or contained links, but yes I am using Astro content collections