From 841edb4f2de3f8d0ae82757f96d05267ab4fddb3 Mon Sep 17 00:00:00 2001 From: Christine Tham Date: Fri, 10 Feb 2023 21:59:35 +1100 Subject: [PATCH] Removed layout from blog and doc content --- README.md | 1 + src/content/blog/2000-01-01-template.md | 1 - src/content/blog/2022-08-09-mit-licence.md | 1 - .../blog/2022-08-10-markdown-cheat-sheet.md | 1 - .../blog/2022-08-19-sample-carousel.mdx | 1 - .../blog/2022-08-20-mermaid-diagrams.md | 1 - .../blog/2022-08-21-sample-gallery-post.mdx | 1 - .../2022-08-22-sample-gallery-post-markdown.md | 1 - .../blog/2022-08-23-sample-mdx-post.mdx | 1 - src/content/blog/2022-08-24-math-equations.md | 1 - .../blog/2022-08-25-plantuml-diagrams.md | 1 - .../blog/2022-08-26-markmap-diagrams.md | 1 - src/content/blog/2022-08-27-how-to-use.md | 1 - src/content/blog/2023-01-26-roadmap.md | 1 - src/content/config.ts | 5 ----- src/content/doc/introduction.md | 1 - src/content/doc/page-2.md | 1 - src/content/doc/page-3.md | 1 - src/content/doc/page-4.md | 1 - src/layouts/doc.astro | 1 - src/pages/blog/[slug].astro | 12 +++++++++++- src/pages/doc/[slug].astro | 18 ++++++++++++++---- 22 files changed, 26 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 82445a5..89532ae 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/content/blog/2000-01-01-template.md b/src/content/blog/2000-01-01-template.md index 337bc27..0d9c821 100644 --- a/src/content/blog/2000-01-01-template.md +++ b/src/content/blog/2000-01-01-template.md @@ -1,6 +1,5 @@ --- draft: true -layout: ../../layouts/blog.astro title: Template description: Copy to create a new post author: Chris Tham diff --git a/src/content/blog/2022-08-09-mit-licence.md b/src/content/blog/2022-08-09-mit-licence.md index 43266e7..2dffe0c 100644 --- a/src/content/blog/2022-08-09-mit-licence.md +++ b/src/content/blog/2022-08-09-mit-licence.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: MIT Licence description: The MIT License, explained. author: Chris Tham diff --git a/src/content/blog/2022-08-10-markdown-cheat-sheet.md b/src/content/blog/2022-08-10-markdown-cheat-sheet.md index 51042bf..f064507 100644 --- a/src/content/blog/2022-08-10-markdown-cheat-sheet.md +++ b/src/content/blog/2022-08-10-markdown-cheat-sheet.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: Markdown Cheat Sheet description: A quick reference to the Markdown syntax. author: Matt Cone diff --git a/src/content/blog/2022-08-19-sample-carousel.mdx b/src/content/blog/2022-08-19-sample-carousel.mdx index 1451865..174bad4 100644 --- a/src/content/blog/2022-08-19-sample-carousel.mdx +++ b/src/content/blog/2022-08-19-sample-carousel.mdx @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: Sample Carousel description: Test post with a carousel author: Chris Tham diff --git a/src/content/blog/2022-08-20-mermaid-diagrams.md b/src/content/blog/2022-08-20-mermaid-diagrams.md index a98445f..74ab908 100644 --- a/src/content/blog/2022-08-20-mermaid-diagrams.md +++ b/src/content/blog/2022-08-20-mermaid-diagrams.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: Mermaid Diagrams description: Generate mermaid diagrams in blog posts. author: Chris Tham diff --git a/src/content/blog/2022-08-21-sample-gallery-post.mdx b/src/content/blog/2022-08-21-sample-gallery-post.mdx index 0bb3ac1..8a8c6c8 100644 --- a/src/content/blog/2022-08-21-sample-gallery-post.mdx +++ b/src/content/blog/2022-08-21-sample-gallery-post.mdx @@ -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 diff --git a/src/content/blog/2022-08-22-sample-gallery-post-markdown.md b/src/content/blog/2022-08-22-sample-gallery-post-markdown.md index 63893be..63445ca 100644 --- a/src/content/blog/2022-08-22-sample-gallery-post-markdown.md +++ b/src/content/blog/2022-08-22-sample-gallery-post-markdown.md @@ -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 diff --git a/src/content/blog/2022-08-23-sample-mdx-post.mdx b/src/content/blog/2022-08-23-sample-mdx-post.mdx index 919cf5d..b997b07 100644 --- a/src/content/blog/2022-08-23-sample-mdx-post.mdx +++ b/src/content/blog/2022-08-23-sample-mdx-post.mdx @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: Sample MDX post description: Test post illustrating the use of MDX. author: Chris Tham diff --git a/src/content/blog/2022-08-24-math-equations.md b/src/content/blog/2022-08-24-math-equations.md index 41082f4..782bbe3 100644 --- a/src/content/blog/2022-08-24-math-equations.md +++ b/src/content/blog/2022-08-24-math-equations.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: Math Equations description: Display math equations in blog posts! author: Chris Tham diff --git a/src/content/blog/2022-08-25-plantuml-diagrams.md b/src/content/blog/2022-08-25-plantuml-diagrams.md index d46c374..3bc06bd 100644 --- a/src/content/blog/2022-08-25-plantuml-diagrams.md +++ b/src/content/blog/2022-08-25-plantuml-diagrams.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: PlantUML Diagrams description: Generate PlantUML diagrams in blog posts. author: Chris Tham diff --git a/src/content/blog/2022-08-26-markmap-diagrams.md b/src/content/blog/2022-08-26-markmap-diagrams.md index 35ebe2f..413a45c 100644 --- a/src/content/blog/2022-08-26-markmap-diagrams.md +++ b/src/content/blog/2022-08-26-markmap-diagrams.md @@ -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 diff --git a/src/content/blog/2022-08-27-how-to-use.md b/src/content/blog/2022-08-27-how-to-use.md index d2f8057..4cd5ea9 100644 --- a/src/content/blog/2022-08-27-how-to-use.md +++ b/src/content/blog/2022-08-27-how-to-use.md @@ -1,5 +1,4 @@ --- -layout: ../../layouts/blog.astro title: How to Use description: Some suggestions for how to use this starter. author: Chris Tham diff --git a/src/content/blog/2023-01-26-roadmap.md b/src/content/blog/2023-01-26-roadmap.md index ff8b70e..5627f41 100644 --- a/src/content/blog/2023-01-26-roadmap.md +++ b/src/content/blog/2023-01-26-roadmap.md @@ -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 diff --git a/src/content/config.ts b/src/content/config.ts index 0a68a85..37753cc 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -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(), @@ -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(), diff --git a/src/content/doc/introduction.md b/src/content/doc/introduction.md index 10e690c..f9a8a2d 100644 --- a/src/content/doc/introduction.md +++ b/src/content/doc/introduction.md @@ -2,7 +2,6 @@ section: Section Header title: Introduction description: Docs intro -layout: ../../layouts/doc.astro --- **Welcome to Astro!** diff --git a/src/content/doc/page-2.md b/src/content/doc/page-2.md index 0c1ea6b..071cc1d 100644 --- a/src/content/doc/page-2.md +++ b/src/content/doc/page-2.md @@ -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. diff --git a/src/content/doc/page-3.md b/src/content/doc/page-3.md index 0d5fda9..493f22b 100644 --- a/src/content/doc/page-3.md +++ b/src/content/doc/page-3.md @@ -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! diff --git a/src/content/doc/page-4.md b/src/content/doc/page-4.md index f315555..075b5f4 100644 --- a/src/content/doc/page-4.md +++ b/src/content/doc/page-4.md @@ -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! diff --git a/src/layouts/doc.astro b/src/layouts/doc.astro index f3e72dd..b8f1737 100644 --- a/src/layouts/doc.astro +++ b/src/layouts/doc.astro @@ -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(), diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro index 0d9f9d4..5191a4a 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[slug].astro @@ -1,5 +1,8 @@ --- +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') @@ -7,8 +10,15 @@ export async function getStaticPaths() { 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() --- - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/pages/doc/[slug].astro b/src/pages/doc/[slug].astro index f78d376..ba02d83 100644 --- a/src/pages/doc/[slug].astro +++ b/src/pages/doc/[slug].astro @@ -1,5 +1,8 @@ --- -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'); @@ -7,8 +10,15 @@ export async function getStaticPaths() { 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() --- - \ No newline at end of file + + + \ No newline at end of file