Update blog post metadata and styles
All checks were successful
Test / test (push) Successful in 49s
All checks were successful
Test / test (push) Successful in 49s
This commit is contained in:
parent
d4eab1ff13
commit
2b53025876
@ -3,6 +3,7 @@ title: "Example Content"
|
|||||||
author: "Example User"
|
author: "Example User"
|
||||||
pubDate: "2018-01-01"
|
pubDate: "2018-01-01"
|
||||||
description: "Howdy! This is an example blog post that shows several types of HTML content supported in this theme."
|
description: "Howdy! This is an example blog post that shows several types of HTML content supported in this theme."
|
||||||
|
draft: true
|
||||||
---
|
---
|
||||||
|
|
||||||
Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. _Aenean eu leo quam._ Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
|
Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. _Aenean eu leo quam._ Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.
|
||||||
|
@ -5,6 +5,7 @@ const blog = defineCollection({
|
|||||||
schema: z.object({
|
schema: z.object({
|
||||||
author: z.string(),
|
author: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
|
draft: z.optional(z.boolean()),
|
||||||
pubDate: z.coerce.date(),
|
pubDate: z.coerce.date(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
}),
|
}),
|
||||||
|
@ -8,7 +8,10 @@ import PostSummary from "../components/PostSummary.astro";
|
|||||||
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
|
||||||
|
|
||||||
export const getStaticPaths = (async ({ paginate }) => {
|
export const getStaticPaths = (async ({ paginate }) => {
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection("blog", ({ data }) => {
|
||||||
|
return data.draft !== true;
|
||||||
|
});
|
||||||
|
|
||||||
posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
|
posts.sort((a, b) => b.data.pubDate.getTime() - a.data.pubDate.getTime());
|
||||||
|
|
||||||
return paginate(posts, {
|
return paginate(posts, {
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
import { type CollectionEntry, getCollection } from "astro:content";
|
import { type CollectionEntry, getCollection } from "astro:content";
|
||||||
import Comments from "../../components/Comments.astro";
|
import Comments from "../../components/Comments.astro";
|
||||||
import Layout from "../../layouts/BaseLayout.astro";
|
import Layout from "../../layouts/BaseLayout.astro";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
type Props = CollectionEntry<"blog">;
|
type Props = CollectionEntry<"blog">;
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection("blog", ({ data }) => {
|
||||||
|
return data.draft !== true;
|
||||||
|
});
|
||||||
|
|
||||||
return posts.map((post) => ({
|
return posts.map((post) => ({
|
||||||
params: { slug: post.slug },
|
params: { slug: post.slug },
|
||||||
@ -15,33 +18,30 @@ export async function getStaticPaths() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const post = Astro.props;
|
const post = Astro.props;
|
||||||
const { Content, remarkPluginFrontmatter } = await post.render();
|
const { Content } = await post.render();
|
||||||
|
const formattedDate = dayjs(post.data.pubDate.toString()).format("MMMM DD, YYYY");
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
|
||||||
.header {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<Layout description={post.data.description} title={post.data.title}>
|
<Layout description={post.data.description} title={post.data.title}>
|
||||||
<article>
|
<article>
|
||||||
<section class="header">
|
<section>
|
||||||
<h1>{post.data.title}</h1>
|
<h1>{post.data.title}</h1>
|
||||||
<p>
|
|
||||||
<small>
|
|
||||||
Posted
|
|
||||||
<time datetime={post.data.pubDate.toISOString()}>{post.data.pubDate.toDateString()}</time>
|
|
||||||
by {post.data.author} ‐
|
|
||||||
<strong>{remarkPluginFrontmatter.minutesRead}</strong>
|
|
||||||
</small>
|
|
||||||
</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<Content />
|
<Content />
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<p>
|
||||||
|
<small>
|
||||||
|
Posted
|
||||||
|
<time datetime={post.data.pubDate.toISOString()}>{formattedDate}</time>
|
||||||
|
by {post.data.author}
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<Comments />
|
<Comments />
|
||||||
</section>
|
</section>
|
||||||
|
@ -2,7 +2,9 @@ import { getCollection } from "astro:content";
|
|||||||
import rss from "@astrojs/rss";
|
import rss from "@astrojs/rss";
|
||||||
|
|
||||||
export async function GET(context) {
|
export async function GET(context) {
|
||||||
const posts = await getCollection("blog");
|
const posts = await getCollection("blog", ({ data }) => {
|
||||||
|
return data.draft !== true;
|
||||||
|
});
|
||||||
|
|
||||||
return rss({
|
return rss({
|
||||||
customData: `<language>ru-ru</language>`,
|
customData: `<language>ru-ru</language>`,
|
||||||
|
@ -55,8 +55,7 @@ h5,
|
|||||||
h6 {
|
h6 {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 1.1;
|
line-height: 1.1;
|
||||||
margin-bottom: 1.5rem;
|
margin: 3rem 0;
|
||||||
margin-top: 3rem;
|
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
Loading…
Reference in New Issue
Block a user