All Posts
+ {collection.start + 1}–{collection.end + 1} of {collection.total}+ {collection.data.map((post) =>
From 3639190b4e1b4c97836d448fa80a58aa45c823a7 Mon Sep 17 00:00:00 2001 From: Drew Powers <1369770+drwpow@users.noreply.github.com> Date: Mon, 12 Apr 2021 17:21:29 -0600 Subject: [PATCH] Renaming to import.meta.fetchContent (#70) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change to import.meta.glob() Change of plans—maintain parity with Snowpack and Vite because our Collections API will use a different interface * Get basic pagination working * Get params working * Rename to import.meta.fetchContent * Upgrade to fdir --- README.md | 197 +- examples/blog/astro/components/Counter.jsx | 10 +- examples/blog/astro/components/Nav.astro | 4 +- .../blog/astro/components/Pagination.astro | 38 +- examples/blog/astro/pages/$posts.astro | 48 + examples/blog/astro/pages/$tag.astro | 58 + examples/blog/astro/pages/index.astro | 26 +- examples/blog/package-lock.json | 2737 ++++++----------- examples/blog/package.json | 5 +- package-lock.json | 52 +- package.json | 7 +- src/@types/astro.ts | 44 + src/compiler/codegen/content.ts | 78 + src/compiler/{codegen.ts => codegen/index.ts} | 214 +- src/compiler/codegen/utils.ts | 20 + src/compiler/index.ts | 4 +- src/frontend/render/svelte.ts | 3 +- src/runtime.ts | 78 +- src/search.ts | 59 +- 19 files changed, 1736 insertions(+), 1946 deletions(-) create mode 100644 examples/blog/astro/pages/$posts.astro create mode 100644 examples/blog/astro/pages/$tag.astro create mode 100644 src/compiler/codegen/content.ts rename src/compiler/{codegen.ts => codegen/index.ts} (73%) create mode 100644 src/compiler/codegen/utils.ts diff --git a/README.md b/README.md index d8d01b7b4..e465d2e05 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ export default { astroRoot: './astro', /** When running `astro build`, path to final static output */ dist: './_site', - /** A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don‘t need processing. */ + /** A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing. */ public: './public', /** Extension-specific handlings */ extensions: { @@ -80,7 +80,7 @@ Our goal is to support all popular state management libraries, as long as there ### 💅 Styling -If you‘ve used [Svelte][svelte]’s styles before, Astro works almost the same way. In any `.astro` file, start writing styles in a ` + + diff --git a/examples/blog/astro/pages/$posts.astro b/examples/blog/astro/pages/$posts.astro new file mode 100644 index 000000000..ae4bcb223 --- /dev/null +++ b/examples/blog/astro/pages/$posts.astro @@ -0,0 +1,48 @@ +--- +import MainHead from '../components/MainHead.astro'; +import Nav from '../components/Nav.astro'; +import PostPreview from '../components/PostPreview.astro'; +import Pagination from '../components/Pagination.astro'; + +// page +let title = 'Muppet Blog: Home'; +let description = 'An example blog on Astro'; + +// collection +import authorData from '../data/authors.json'; +export let collection: any; +export async function createCollection() { + return { + async data() { + let allPosts = await import.meta.fetchContent('./post/*.md'); + allPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); + return allPosts; + }, + pageSize: 3 + }; +} +--- + + +
+