1
0
Fork
You've already forked plugin-astro-content
0
plugin-astro-content is an Astro.glob() alternative
  • JavaScript 100%
2025年01月09日 19:14:39 +01:00
.github/workflows update 2025年01月09日 19:14:39 +01:00
demo add 2024年05月21日 10:10:44 +02:00
plugin-astro-content bump 2025年01月09日 18:28:54 +01:00
LICENSE Initial commit 2024年05月21日 09:53:50 +02:00
README.md clean 2024年12月24日 11:26:59 +01:00

plugin-astro-content npm link npm downloads

Glob import in astrojs ! See demo https://its-just-nans.github.io/plugin-astro-content/

Usage

There are two possible usage for this plugin:

  • at compile time
  • at runtime

Usage at compile time

Add to your astro.config.mjs:

import Content from "plugin-astro-content";
export default defineConfig({
 vite: {
 plugins: [
 Content({ objectMode: true }) // change options here
 ],
 },
});

Then in your astro file:

---
import { ContentLoader } from "plugin-astro-content";
const ContentLoaderValue = ContentLoader("../*"); // act mostly like import.meta.glob("../*")
---
<div>{ContentLoaderValue}</div>

Usage at runtime

In this case (no need to change the config)

---
import { ContentLoaderRuntime } from "plugin-astro-content";
const dynamic = "../*";
const ContentLoaderRuntimeValue = await ContentLoaderRuntime(dynamic);
// with dynamic options
const ContentLoaderRuntimeValueWithOptions = await ContentLoaderRuntime(dynamic, { objectMode: true });
---
<div>{ContentLoaderRuntimeValue}</div>
<div>{ContentLoaderRuntimeValueWithOptions}</div>

License

Licensed under the MIT License - LICENSE