add blog
This commit is contained in:
30
superpage/src/pages/blog/[slug].astro
Normal file
30
superpage/src/pages/blog/[slug].astro
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
import Layout from '~/layouts/Layout.astro'
|
||||
import Container from '~/components/Container'
|
||||
|
||||
const { slug } = Astro.params
|
||||
|
||||
let res = await fetch(`https://betaeducacao.com.br/wp-json/wp/v2/posts?slug=${slug}&_embed`)
|
||||
let [post] = await res.json()
|
||||
|
||||
// The getStaticPaths() is required for static Astro sites.
|
||||
// If using SSR, you will not need this function.
|
||||
export async function getStaticPaths() {
|
||||
let data = await fetch('https://betaeducacao.com.br/wp-json/wp/v2/posts')
|
||||
let posts = await data.json()
|
||||
|
||||
return posts.map((post) => ({
|
||||
params: { slug: post.slug },
|
||||
props: { post: post },
|
||||
}))
|
||||
}
|
||||
---
|
||||
|
||||
<Layout title={post.title.rendered}>
|
||||
<Container>
|
||||
<article>
|
||||
<h1 set:html={post.title.rendered} />
|
||||
<Fragment set:html={post.content.rendered} />
|
||||
</article>
|
||||
</Container>
|
||||
</Layout>
|
||||
Reference in New Issue
Block a user