diff options
author | 2022-03-28 17:16:06 -0700 | |
---|---|---|
committer | 2022-03-28 17:16:06 -0700 | |
commit | 4299ab303b0743349fbd01f85340bea61a1c16a8 (patch) | |
tree | 7012176c704d4f254fb2a602101fb7f0a01b8450 /examples/portfolio/src | |
parent | 7d29feace103c0cf7c682634d4359b69338c2a1d (diff) | |
download | astro-4299ab303b0743349fbd01f85340bea61a1c16a8.tar.gz astro-4299ab303b0743349fbd01f85340bea61a1c16a8.tar.zst astro-4299ab303b0743349fbd01f85340bea61a1c16a8.zip |
New Markdown API (#2862)
* Implement new markdown plugin with deferred markdown rendering
* feat: switch from `getContent()` fn to `<Content />` API
* update types
* Update packages/astro/src/@types/astro.ts
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* update types
* Create forty-coins-attend.md
Co-authored-by: Nate Moore <nate@skypack.dev>
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'examples/portfolio/src')
-rw-r--r-- | examples/portfolio/src/components/PortfolioPreview/index.jsx | 9 | ||||
-rw-r--r-- | examples/portfolio/src/pages/index.astro | 2 | ||||
-rw-r--r-- | examples/portfolio/src/pages/projects.astro | 10 |
3 files changed, 9 insertions, 12 deletions
diff --git a/examples/portfolio/src/components/PortfolioPreview/index.jsx b/examples/portfolio/src/components/PortfolioPreview/index.jsx index 6957e5884..4f1627604 100644 --- a/examples/portfolio/src/components/PortfolioPreview/index.jsx +++ b/examples/portfolio/src/components/PortfolioPreview/index.jsx @@ -2,16 +2,17 @@ import { h } from 'preact'; import Styles from './styles.module.scss'; function PortfolioPreview({ project }) { + const { frontmatter } = project; return ( <div className={Styles.card}> - <div className={Styles.titleCard} style={`background-image:url(${project.img})`}> - <h1 className={Styles.title}>{project.title}</h1> + <div className={Styles.titleCard} style={`background-image:url(${frontmatter.img})`}> + <h1 className={Styles.title}>{frontmatter.title}</h1> </div> <div className="pa3"> - <p className={`${Styles.desc} mt0 mb2`}>{project.description}</p> + <p className={`${Styles.desc} mt0 mb2`}>{frontmatter.description}</p> <div className={Styles.tags}> Tagged: - {project.tags.map((t) => ( + {frontmatter.tags.map((t) => ( <div className={Styles.tag} data-tag={t}> {t} </div> diff --git a/examples/portfolio/src/pages/index.astro b/examples/portfolio/src/pages/index.astro index ce11119b5..d8a9efcc2 100644 --- a/examples/portfolio/src/pages/index.astro +++ b/examples/portfolio/src/pages/index.astro @@ -7,7 +7,7 @@ import Footer from '../components/Footer/index.jsx'; import PortfolioPreview from '../components/PortfolioPreview/index.jsx'; // Data Fetching: List all Markdown posts in the repo. -const projects = Astro.fetchContent('./project/**/*.md'); +const projects = await Astro.glob('./project/**/*.md'); const featuredProject = projects[0]; // Full Astro Component Syntax: diff --git a/examples/portfolio/src/pages/projects.astro b/examples/portfolio/src/pages/projects.astro index 991c254bc..1aa05e07f 100644 --- a/examples/portfolio/src/pages/projects.astro +++ b/examples/portfolio/src/pages/projects.astro @@ -4,13 +4,9 @@ import Footer from '../components/Footer/index.jsx'; import Nav from '../components/Nav/index.jsx'; import PortfolioPreview from '../components/PortfolioPreview/index.jsx'; -interface MarkdownFrontmatter { - publishDate: number; -} - -const projects = Astro.fetchContent<MarkdownFrontmatter>('./project/**/*.md') - .filter(({ publishDate }) => !!publishDate) - .sort((a, b) => new Date(b.publishDate).valueOf() - new Date(a.publishDate).valueOf()); +const projects = (await Astro.glob('./project/**/*.md')) + .filter(({ frontmatter }) => !!frontmatter.publishDate) + .sort((a, b) => new Date(b.frontmatter.publishDate).valueOf() - new Date(a.frontmatter.publishDate).valueOf()); --- <html lang="en"> |