Fix minimal details

This commit is contained in:
prototypa
2022-09-04 00:56:24 -04:00
parent 570cf904c4
commit 1cf25d6b43
44 changed files with 757 additions and 641 deletions

View File

@ -8,4 +8,4 @@ const title = `Error 404 — ${SITE.name}`;
<Layout meta={{ title }}>
<Error404 />
</Layout>
</Layout>

View File

@ -1,11 +1,12 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
import { getCanonical, getPermalink, BLOG_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/posts";
import { getCanonical, getPermalink, BLOG_BASE } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled) return [];
@ -24,16 +25,15 @@ const currentPage = page.currentPage ?? 1;
const meta = {
title: `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name}`,
description: SITE.description,
canonical: getCanonical(getPermalink(page.url.current))
}
canonical: getCanonical(getPermalink(page.url.current)),
};
---
<Layout meta={meta}>
<Fragment slot="title">
News and step-by-step guides about
<span class="bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-pink-500">AstroWind
</span>
<span class="bg-clip-text text-transparent bg-gradient-to-r from-primary-500 to-secondary-500">AstroWind</span>
</Fragment>
<BlogList posts={page.data} />
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</Layout>
</Layout>

View File

@ -1,11 +1,12 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { getCanonical, getPermalink, cleanSlug, BLOG_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/fetchPosts";
import { findImage } from "~/utils/findImage";
import Layout from "~/layouts/PageLayout.astro";
import BlogPost from "~/components/widgets/BlogPost.astro";
import { getCanonical, getPermalink, cleanSlug, BLOG_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/posts";
import { findImage } from "~/utils/images";
export async function getStaticPaths() {
if (BLOG?.disabled) return [];
@ -25,9 +26,9 @@ const meta = {
description: post.description,
canonical: post.canonical || getCanonical(getPermalink(post.slug, "post")),
image: await findImage(post.image),
}
};
---
<Layout meta={meta}>
<BlogPost post={{ ...post, image: meta.image }} />
</Layout>
</Layout>

View File

@ -1,30 +1,33 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
import { getCanonical, getPermalink, cleanSlug, CATEGORY_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/posts";
import { getCanonical, getPermalink, cleanSlug, CATEGORY_BASE } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled || BLOG?.category?.disabled) return [];
const posts = await fetchPosts();
const categories = new Set()
posts.map(post => {
typeof post.category === "string" && categories.add(post.category.toLowerCase())
})
const categories = new Set();
posts.map((post) => {
typeof post.category === "string" && categories.add(post.category.toLowerCase());
});
return Array.from(categories).map((category) => (
paginate(posts.filter((post) => typeof post.category === "string" && category === post.category.toLowerCase()), {
params: { category: cleanSlug(category), categories: CATEGORY_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { category }
})
))
return Array.from(categories).map((category) =>
paginate(
posts.filter((post) => typeof post.category === "string" && category === post.category.toLowerCase()),
{
params: { category: cleanSlug(category), categories: CATEGORY_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { category },
}
)
);
}
const { page, category } = Astro.props;
@ -34,8 +37,8 @@ const currentPage = page.currentPage ?? 1;
const meta = {
title: `Category '${category}' ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name}`,
description: SITE.description,
canonical: getCanonical(getPermalink(page.url.current))
}
canonical: getCanonical(getPermalink(page.url.current)),
};
---
<Layout meta={{ ...meta, noindex: true }}>
@ -44,4 +47,4 @@ const meta = {
</Fragment>
<BlogList posts={page.data} />
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</Layout>
</Layout>

View File

@ -1,29 +1,33 @@
---
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
import { getCanonical, getPermalink, cleanSlug, TAG_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/posts";
import { getCanonical, getPermalink, cleanSlug, TAG_BASE } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled || BLOG?.tag?.disabled) return [];
const posts = await fetchPosts();
const tags = new Set()
posts.map(post => {
Array.isArray(post.tags) && post.tags.map(tag => tags.add(tag.toLowerCase()))
})
const tags = new Set();
posts.map((post) => {
Array.isArray(post.tags) && post.tags.map((tag) => tags.add(tag.toLowerCase()));
});
return Array.from(tags).map((tag) => (
paginate(posts.filter((post) => Array.isArray(post.tags) && post.tags.includes(tag)), {
params: { tag: cleanSlug(tag), tags: TAG_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { tag },
})
))
return Array.from(tags).map((tag) =>
paginate(
posts.filter((post) => Array.isArray(post.tags) && post.tags.includes(tag)),
{
params: { tag: cleanSlug(tag), tags: TAG_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { tag },
}
)
);
}
const { page, tag } = Astro.props;
@ -33,8 +37,8 @@ const currentPage = page.currentPage ?? 1;
const meta = {
title: `Posts by tag '${tag}' ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name}`,
description: SITE.description,
canonical: getCanonical(getPermalink(page.url.current))
}
canonical: getCanonical(getPermalink(page.url.current)),
};
---
<Layout meta={{ ...meta, noindex: true }}>
@ -43,4 +47,4 @@ const meta = {
</Fragment>
<BlogList posts={page.data} />
<Pagination prevUrl={page.url.prev} nextUrl={page.url.next} />
</Layout>
</Layout>

View File

@ -17,7 +17,7 @@ const meta = {
title: SITE.title,
description: SITE.description,
canonical: getCanonical(getHomePermalink()),
}
};
---
<Layout meta={meta}>
@ -30,4 +30,4 @@ const meta = {
<FAQs />
<Stats />
<BasicCTA />
</Layout>
</Layout>

View File

@ -1,13 +1,20 @@
import rss from "@astrojs/rss";
import { SITE } from "~/config.mjs";
import { fetchPosts } from "~/utils/fetchPosts";
import { SITE, BLOG } from "~/config.mjs";
import { fetchPosts } from "~/utils/posts";
import { getPermalink } from "~/utils/permalinks";
const posts = await fetchPosts();
export const get = async () => {
if (BLOG.disabled) {
return new Response(null, {
status: 404,
statusText: 'Not found'
});
}
export const get = () =>
rss({
const posts = await fetchPosts();
return rss({
title: `${SITE.name}s Blog`,
description: SITE.description,
site: import.meta.env.SITE,
@ -19,3 +26,4 @@ export const get = () =>
pubDate: post.pubDate,
})),
});
}