diff --git a/.gitignore b/.gitignore
index 45421092e0..919cc45dac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@ dist/
_site/
*.log
package-lock.json
+
+# .vscode files other than at top-level
+**/.vscode
diff --git a/examples/astro-markdown/src/pages/collections.astro b/examples/astro-markdown/src/pages/collections.astro
deleted file mode 100644
index efdf85d5e1..0000000000
--- a/examples/astro-markdown/src/pages/collections.astro
+++ /dev/null
@@ -1,211 +0,0 @@
----
-import Markdown from 'astro/components/Markdown.astro';
----
-
-
-
- Collections
-
-
-
-
- # 🍱 Collections
-
- ## ❓ What are Collections?
-
- [Fetching data is easy in Astro][docs-data]. But what if you wanted to make a paginated blog? What if you wanted an easy way to sort data, or filter data based on part of the URL? Or generate an RSS 2.0 feed? When you need something a little more powerful than simple data fetching, Astro’s Collections API may be what you need.
-
- An Astro Collection is similar to the general concept of Collections in static site generators like Jekyll, Hugo, Eleventy, etc. It’s a general way to load an entire data set. But one big difference between Astro Collections and traditional static site generators is: **Astro lets you seamlessly blend remote API data and local files in a JAMstack-friendly way.** To see how, this guide will walk through a few examples. If you’d like, you can reference the [blog example project][example-blog] to see the finished code in context.
-
- ## 🧑🎨 How to Use
-
- By default, any Astro component can fetch data from any API or local `*.md` files. But what if you had a blog you wanted to paginate? What if you wanted to generate dynamic URLs based on metadata (e.g. `/tag/:tag/`)? Or do both together? Astro Collections are a way to do all of that. It’s perfect for generating blog-like content, or scaffolding out dynamic URLs from your data.
-
- Let’s pretend we have some blog posts written already. This is our starting project structure:
-
- ```
- └── src/
- └── pages/
- └── post/
- └── (blog content)
- ```
-
- The first step in adding some dynamic collections is deciding on a URL schema. For our example website, we’re aiming for the following URLs:
-
- - `/post/:post`: A single blog post page
- - `/posts/:page`: A list page of all blog posts, paginated, and sorted most recent first
- - `/tag/:tag`: All blog posts, filtered by a specific tag
-
- Because `/post/:post` references the static files we have already, that doesn’t need to be a collection. But we will need collections for `/posts/:page` and `/tag/:tag` because those will be dynamically generated. For both collections we’ll create a `/src/pages/$[collection].astro` file. This is our new structure:
-
- ```diff
- └── src/
- └── pages/
- ├── post/
- │ └── (blog content)
- + ├── $posts.astro -> /posts/1, /posts/2, …
- + └── $tag.astro -> /tag/:tag/1, /tag/:tag/2, …
- ```
-
- 💁 **Tip**: Any `.astro` filename beginning with a `$` is how it’s marked as a collection.
-
- In each `$[collection].astro` file, we’ll need 2 things:
-
- ```js
- // 1. We need to mark “collection” as a prop (this is a special reserved name)
- export let collection: any;
-
- // 2. We need to export an async createCollection() function that will retrieve our data.
- export async function createCollection() {
- return {
- async data() {
- // return data here to load (we’ll cover how later)
- },
- };
- }
- ```
-
- These are important so your data is exposed to the page as a prop, and also Astro has everything it needs to gather your data and generate the proper routes. How it does this is more clear if we walk through a practical example.
-
- #### Example 1: Simple pagination
-
- Our blog posts all contain `title`, `tags`, and `published_at` in their frontmatter:
-
- ```md
- ---
- title: My Blog Post
- tags:
- - javascript
- published_at: 2021-03-01 09:34:00
- ---
-
- # My Blog post
-
- …
- ```
-
- There’s nothing special or reserved about any of these names; you’re free to name everything whatever you’d like, or have as much or little frontmatter as you need.
-
- ```jsx
- // /src/pages/$posts.astro
- ---
- export let collection: any;
-
- export async function createCollection() {
- const allPosts = Astro.fetchContent('./post/*.md'); // load data that already lives at `/post/:slug`
- allPosts.sort((a, b) => new Date(b.published_at) - new Date(a.published_at)); // sort newest -> oldest (we got "published_at" from frontmatter!)
-
- // (load more data here, if needed)
-
- return {
- async data() {
- return allPosts;
- },
- pageSize: 10, // how many we want to show per-page (default: 25)
- };
- }
-
- function formatDate(date) {
- return new Date(date).toUTCString();
- }
- ---
-
-
-
- Blog Posts: page {collection.page.current}
-
-
-
-
-
-
-
+
+
+
+
diff --git a/examples/doc/src/pages/example.md b/examples/doc/src/pages/example.md
new file mode 100644
index 0000000000..0966595d84
--- /dev/null
+++ b/examples/doc/src/pages/example.md
@@ -0,0 +1,35 @@
+---
+layout: ../layouts/Main.astro
+---
+
+# Markdown example
+
+This is a fully-featured page, written in Markdown!
+
+## Section A
+
+Lorem ipsum dolor sit amet, **consectetur adipiscing elit**. Sed ut tortor _suscipit_, posuere ante id, vulputate urna. Pellentesque molestie aliquam dui sagittis aliquet. Sed sed felis convallis, lacinia lorem sit amet, fermentum ex. Etiam hendrerit mauris at elementum egestas. Vivamus id gravida ante. Praesent consectetur fermentum turpis, quis blandit tortor feugiat in. Aliquam erat volutpat. In elementum purus et tristique ornare. Suspendisse sollicitudin dignissim est a ultrices. Pellentesque sed ipsum finibus, condimentum metus eget, sagittis elit. Sed id lorem justo. Vivamus in sem ac mi molestie ornare.
+
+## Section B
+
+Nam quam dolor, pellentesque sed odio euismod, feugiat tempus tellus. Quisque arcu velit, ultricies in faucibus sed, ultrices ac enim. Nunc eget dictum est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ex nisi, egestas mollis ultricies ut, laoreet suscipit libero. Nam condimentum molestie turpis. Sed vestibulum sagittis congue. Maecenas tristique enim et tincidunt tempor. Curabitur ac scelerisque nulla, in malesuada libero. Praesent eu tempus odio. Pellentesque aliquam ullamcorper quam at gravida. Sed non fringilla mauris. Aenean sit amet ultrices erat. Vestibulum congue venenatis tortor, nec suscipit tortor. Aenean pellentesque mauris eget tortor tincidunt pharetra.
+
+## Section C
+
+```markdown
+---
+layout: ../layouts/Main.astro
+---
+
+# Markdown example
+
+This is a fully-featured page, written in Markdown!
+
+## Section A
+
+Lorem ipsum dolor sit amet, **consectetur adipiscing elit**. Sed ut tortor _suscipit_, posuere ante id, vulputate urna. Pellentesque molestie aliquam dui sagittis aliquet. Sed sed felis convallis, lacinia lorem sit amet, fermentum ex. Etiam hendrerit mauris at elementum egestas. Vivamus id gravida ante. Praesent consectetur fermentum turpis, quis blandit tortor feugiat in. Aliquam erat volutpat. In elementum purus et tristique ornare. Suspendisse sollicitudin dignissim est a ultrices. Pellentesque sed ipsum finibus, condimentum metus eget, sagittis elit. Sed id lorem justo. Vivamus in sem ac mi molestie ornare.
+
+## Section B
+
+Nam quam dolor, pellentesque sed odio euismod, feugiat tempus tellus. Quisque arcu velit, ultricies in faucibus sed, ultrices ac enim. Nunc eget dictum est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ex nisi, egestas mollis ultricies ut, laoreet suscipit libero. Nam condimentum molestie turpis. Sed vestibulum sagittis congue. Maecenas tristique enim et tincidunt tempor. Curabitur ac scelerisque nulla, in malesuada libero. Praesent eu tempus odio. Pellentesque aliquam ullamcorper quam at gravida. Sed non fringilla mauris. Aenean sit amet ultrices erat. Vestibulum congue venenatis tortor, nec suscipit tortor. Aenean pellentesque mauris eget tortor tincidunt pharetra.
+```
diff --git a/examples/doc/src/pages/index.astro b/examples/doc/src/pages/index.astro
new file mode 100644
index 0000000000..fe00e15a86
--- /dev/null
+++ b/examples/doc/src/pages/index.astro
@@ -0,0 +1,14 @@
+---
+import Markdown from 'astro/components/Markdown.astro';
+import Layout from '../layouts/Main.astro';
+---
+
+
+
+ # Hello world!
+
+ This is a starter template, have fun building your next documentation site with [Astro](https://astro.build).
+
+ It offers the right mix of simple-to-use [Markdown pages](/example) and rich, interactive components embedded in `.astro` files using ``.
+
+
diff --git a/packages/astro/components/Prism.astro b/packages/astro/components/Prism.astro
index 6b73d5bbc8..5462cba0e6 100644
--- a/packages/astro/components/Prism.astro
+++ b/packages/astro/components/Prism.astro
@@ -10,12 +10,12 @@ const languageMap = new Map([
['ts', 'typescript']
]);
-if(lang == null) {
+if (lang == null) {
console.warn('Prism.astro: No language provided.');
}
const ensureLoaded = lang => {
- if(!Prism.languages[lang]) {
+ if(lang && !Prism.languages[lang]) {
loadLanguages([lang]);
}
};
@@ -30,14 +30,17 @@ if(languageMap.has(lang)) {
ensureLoaded(lang);
}
-if(!Prism.languages[lang]) {
+if(lang && !Prism.languages[lang]) {
console.warn(`Unable to load the language: ${lang}`);
}
const grammar = Prism.languages[lang];
-let html = Prism.highlight(code, grammar, lang);
+let html = code;
+if (grammar) {
+ html = Prism.highlight(code, grammar, lang);
+}
-let className = `language-${lang}`;
+let className = lang ? `language-${lang}` : '';
---
-