Skip to content

Commit

Permalink
Removed layout from blog and doc content
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristineTham committed Feb 10, 2023
1 parent 5c99e9a commit 841edb4
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 28 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ All commands are run from the root of the project, from a terminal:
- 2.2.0: Fixed lint errors, reimplemented map, lightbox and carousel to use
leaflet, photoswipe and swiper packages instead of relying on external CDN.
- 2.2.1: Update to astro 2.0.10, fixed asset loading issue with base
- 2.3.0: Removed layout from blog and doc content
1 change: 0 additions & 1 deletion src/content/blog/2000-01-01-template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
draft: true
layout: ../../layouts/blog.astro
title: Template
description: Copy to create a new post
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-09-mit-licence.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: MIT Licence
description: The MIT License, explained.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-10-markdown-cheat-sheet.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Markdown Cheat Sheet
description: A quick reference to the Markdown syntax.
author: Matt Cone
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-19-sample-carousel.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Sample Carousel
description: Test post with a carousel
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-20-mermaid-diagrams.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Mermaid Diagrams
description: Generate mermaid diagrams in blog posts.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-21-sample-gallery-post.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Sample Gallery post
description: Test post with a photo gallery and lightbox (using PhotoSwipe)
author: Chris Tham
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Sample Gallery post (Markdown!)
description: Test post with a photo gallery and lightbox (using PhotoSwipe)
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-23-sample-mdx-post.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Sample MDX post
description: Test post illustrating the use of MDX.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-24-math-equations.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Math Equations
description: Display math equations in blog posts!
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-25-plantuml-diagrams.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: PlantUML Diagrams
description: Generate PlantUML diagrams in blog posts.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-26-markmap-diagrams.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Mind Map Diagram
description: MDX post illustrating the use of Markmap component to generate mind map diagrams.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2022-08-27-how-to-use.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: How to Use
description: Some suggestions for how to use this starter.
author: Chris Tham
Expand Down
1 change: 0 additions & 1 deletion src/content/blog/2023-01-26-roadmap.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
layout: ../../layouts/blog.astro
title: Roadmap
description: List of features to be considered for future versions of this starter.
author: Chris Tham
Expand Down
5 changes: 0 additions & 5 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ import { z, defineCollection } from 'astro:content'
const blogCollection = defineCollection({
schema: z.object({
draft: z.boolean().optional(),
layout: z.string().optional(),
title: z.string(),
description: z.string(),
author: z.string().optional(),
publishDate: z.date(),
// publishDate: z.string().datetime({ offset: true }),
// publishDate: z.string().transform((str: string) => new Date(str)),
// publishDate: z.string().transform((str: string | Date) => new Date(str)),
coverSVG: z.string().optional(),
coverImage: z.string().optional(),
socialImage: z.string().optional(),
Expand All @@ -28,7 +24,6 @@ const blogCollection = defineCollection({
const docCollection = defineCollection({
schema: z.object({
draft: z.boolean().optional(),
layout: z.string(),
section: z.string(),
weight: z.number().default(0),
title: z.string(),
Expand Down
1 change: 0 additions & 1 deletion src/content/doc/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
section: Section Header
title: Introduction
description: Docs intro
layout: ../../layouts/doc.astro
---

**Welcome to Astro!**
Expand Down
1 change: 0 additions & 1 deletion src/content/doc/page-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
section: Section Header
title: Page 2
description: Lorem ipsum dolor sit amet - 2
layout: ../../layouts/doc.astro
---

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Expand Down
1 change: 0 additions & 1 deletion src/content/doc/page-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
section: Section Header
title: Page 3
description: Lorem ipsum dolor sit amet - 3
layout: ../../layouts/doc.astro
---

This is a fully-featured page, written in Markdown!
Expand Down
1 change: 0 additions & 1 deletion src/content/doc/page-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
section: Another Section
title: Page 4
description: Lorem ipsum dolor sit amet - 4
layout: ../../layouts/doc.astro
---

This is a fully-featured page, written in Markdown!
Expand Down
1 change: 0 additions & 1 deletion src/layouts/doc.astro
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ docs.forEach((doc, i) => {
})
const basefm: Frontmatter = {
draft: frontmatter.draft,
layout: frontmatter.layout,
title: frontmatter.title,
description: frontmatter.description,
publishDate: new Date(),
Expand Down
12 changes: 11 additions & 1 deletion src/pages/blog/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
---
import type { CollectionEntry } from 'astro:content'
import { getCollection } from 'astro:content'
import Layout from '../../layouts/blog.astro'
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const blogEntries = await getCollection('blog')
return blogEntries.map(entry => ({
params: { slug: entry.slug }, props: { entry },
}))
}
type Props = {
entry: CollectionEntry<'blog'>
}
// 2. When its time to render, you can get the entry directly from the prop
const { entry } = Astro.props;
const { Content } = await entry.render()
---
<Content />
<Layout frontmatter={entry.data}>
<Content />
</Layout>
18 changes: 14 additions & 4 deletions src/pages/doc/[slug].astro
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
---
import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content'
import { getCollection } from 'astro:content'
import Layout from '../../layouts/doc.astro'
// 1. Generate a new path for every collection entry
export async function getStaticPaths() {
const docEntries = await getCollection('doc');
return docEntries.map(entry => ({
params: { slug: entry.slug }, props: { entry },
}));
}
type Props = {
entry: CollectionEntry<'doc'>
}
// 2. When its time to render, you can get the entry directly from the prop
const { entry } = Astro.props;
const { Content } = await entry.render();
const { entry } = Astro.props
const { Content, headings } = await entry.render()
---
<Content />
<Layout frontmatter={entry.data} headings={headings}>
<Content />
</Layout>

0 comments on commit 841edb4

Please sign in to comment.