mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-20 07:03:41 +09:00
updated to astro v3.6
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
---
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const pages = await getSinglePage("pages");
|
||||
const COLLECTION_FOLDER = "pages";
|
||||
|
||||
const pages = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data }) => !data.draft,
|
||||
);
|
||||
|
||||
const paths = pages.map((page) => ({
|
||||
params: {
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
import Social from "@/components/Social.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { slugify } from "@/lib/utils/textConverter";
|
||||
import { Image } from "astro:assets";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const authors = await getSinglePage("authors");
|
||||
const COLLECTION_FOLDER = "authors";
|
||||
const authors = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
|
||||
const paths = authors.map((author) => ({
|
||||
params: {
|
||||
@@ -19,11 +22,13 @@ export async function getStaticPaths() {
|
||||
return paths;
|
||||
}
|
||||
|
||||
const { blog_folder }: { blog_folder: string } = config.settings;
|
||||
const { author } = Astro.props;
|
||||
const { title, social, meta_title, description, image } = author.data;
|
||||
const { Content } = await author.render();
|
||||
const posts = await getSinglePage(blog_folder);
|
||||
const posts = await getCollection(
|
||||
"blog",
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const postFilterByAuthor = posts.filter(
|
||||
(post) => slugify(post.data.author) === slugify(title),
|
||||
);
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
---
|
||||
import AuthorCard from "@/components/AuthorCard.astro";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { getEntry } from "astro:content";
|
||||
import { getCollection, getEntry } from "astro:content";
|
||||
|
||||
const authorIndex = await getEntry<any, string>("authors", "-index");
|
||||
const authors = await getSinglePage("authors");
|
||||
const COLLECTION_FOLDER = "authors";
|
||||
|
||||
const authorIndex = await getEntry(COLLECTION_FOLDER, "-index");
|
||||
const authors = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
---
|
||||
|
||||
<Base title={authorIndex.data.title}>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import PostSingle from "@/layouts/PostSingle.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const COLLECTION_FOLDER = "blog";
|
||||
const posts = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
|
||||
const paths = posts.map((post) => ({
|
||||
params: {
|
||||
|
||||
@@ -3,19 +3,22 @@ import BlogCard from "@/components/BlogCard.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import PostSidebar from "@/partials/PostSidebar.astro";
|
||||
import { getEntry } from "astro:content";
|
||||
import { getCollection, getEntry } from "astro:content";
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
const postIndex = await getEntry<any, string>(blog_folder, "-index");
|
||||
const posts = await getSinglePage(blog_folder);
|
||||
const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
const categories = await getTaxonomy(blog_folder, "categories");
|
||||
const tags = await getTaxonomy(blog_folder, "tags");
|
||||
const COLLECTION_FOLDER = "blog";
|
||||
|
||||
const postIndex = await getEntry(COLLECTION_FOLDER, "-index");
|
||||
const posts = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const allCategories = await getAllTaxonomy(COLLECTION_FOLDER, "categories");
|
||||
const categories = await getTaxonomy(COLLECTION_FOLDER, "categories");
|
||||
const tags = await getTaxonomy(COLLECTION_FOLDER, "tags");
|
||||
const sortedPosts = sortByDate(posts);
|
||||
const totalPages: number = Math.ceil(posts.length / config.settings.pagination);
|
||||
const currentPosts = sortedPosts.slice(0, config.settings.pagination);
|
||||
@@ -43,7 +46,7 @@ const currentPosts = sortedPosts.slice(0, config.settings.pagination);
|
||||
}
|
||||
</div>
|
||||
<Pagination
|
||||
section={blog_folder}
|
||||
section={COLLECTION_FOLDER}
|
||||
currentPage={1}
|
||||
totalPages={totalPages}
|
||||
/>
|
||||
|
||||
@@ -3,20 +3,23 @@ import BlogCard from "@/components/BlogCard.astro";
|
||||
import Pagination from "@/components/Pagination.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { sortByDate } from "@/lib/utils/sortFunctions";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import PostSidebar from "@/partials/PostSidebar.astro";
|
||||
import { getEntry } from "astro:content";
|
||||
import { getCollection, getEntry } from "astro:content";
|
||||
|
||||
const COLLECTION_FOLDER = "blog";
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
const { slug } = Astro.params;
|
||||
const postIndex = await getEntry<any, string>(blog_folder, "-index");
|
||||
const posts = await getSinglePage(blog_folder);
|
||||
const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
const categories = await getTaxonomy(blog_folder, "categories");
|
||||
const tags = await getTaxonomy(blog_folder, "tags");
|
||||
const postIndex = await getEntry(COLLECTION_FOLDER, "-index");
|
||||
const posts = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const allCategories = await getAllTaxonomy(COLLECTION_FOLDER, "categories");
|
||||
const categories = await getTaxonomy(COLLECTION_FOLDER, "categories");
|
||||
const tags = await getTaxonomy(COLLECTION_FOLDER, "tags");
|
||||
const sortedPosts = sortByDate(posts);
|
||||
const totalPages = Math.ceil(posts.length / config.settings.pagination);
|
||||
const currentPage = slug && !isNaN(Number(slug)) ? Number(slug) : 1;
|
||||
@@ -25,7 +28,11 @@ const indexOfFirstPost = indexOfLastPost - config.settings.pagination;
|
||||
const currentPosts = sortedPosts.slice(indexOfFirstPost, indexOfLastPost);
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const COLLECTION_FOLDER = "blog";
|
||||
const posts = await getCollection(
|
||||
COLLECTION_FOLDER,
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const totalPages = Math.ceil(posts.length / config.settings.pagination);
|
||||
const paths = [];
|
||||
|
||||
@@ -62,7 +69,7 @@ export async function getStaticPaths() {
|
||||
}
|
||||
</div>
|
||||
<Pagination
|
||||
section={blog_folder}
|
||||
section={COLLECTION_FOLDER}
|
||||
currentPage={currentPage}
|
||||
totalPages={totalPages}
|
||||
/>
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = await getTaxonomy(
|
||||
config.settings.blog_folder,
|
||||
"categories"
|
||||
);
|
||||
const BLOG_FOLDER = "blog";
|
||||
const categories = await getTaxonomy(BLOG_FOLDER, "categories");
|
||||
|
||||
return categories.map((category) => {
|
||||
return {
|
||||
@@ -21,7 +18,10 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { category } = Astro.params;
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const posts = await getCollection(
|
||||
"blog",
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const filterByCategories = taxonomyFilter(posts, "categories", category!);
|
||||
---
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
const { blog_folder }: { blog_folder: string } = config.settings;
|
||||
const categories = await getTaxonomy(blog_folder, "categories");
|
||||
const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
const BLOG_FOLDER = "blog";
|
||||
|
||||
const categories = await getTaxonomy(BLOG_FOLDER, "categories");
|
||||
const allCategories = await getAllTaxonomy(BLOG_FOLDER, "categories");
|
||||
---
|
||||
|
||||
<Base title={"Categories"}>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import Search from "@/layouts/Search";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import SearchLayout from "@/layouts/Search";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
|
||||
// Retrieve all articles
|
||||
const posts = await getSinglePage(blog_folder);
|
||||
const posts = await getCollection(
|
||||
"blog",
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
|
||||
// List of items to search in
|
||||
const searchList = posts.map((item) => ({
|
||||
@@ -18,5 +17,5 @@ const searchList = posts.map((item) => ({
|
||||
---
|
||||
|
||||
<Base title={`Search`}>
|
||||
<Search client:load searchList={searchList} />
|
||||
<SearchLayout client:load searchList={searchList} />
|
||||
</Base>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
---
|
||||
import BlogCard from "@/components/BlogCard.astro";
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const tags = await getTaxonomy(config.settings.blog_folder, "tags");
|
||||
const BLOG_FOLDER = "blog";
|
||||
const tags = await getTaxonomy(BLOG_FOLDER, "tags");
|
||||
|
||||
return tags.map((tag) => {
|
||||
return {
|
||||
@@ -18,8 +18,11 @@ export async function getStaticPaths() {
|
||||
}
|
||||
|
||||
const { tag } = Astro.params;
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const filterByCategories = taxonomyFilter(posts, "tags", tag!);
|
||||
const posts = await getCollection(
|
||||
"blog",
|
||||
({ data, slug }) => !data.draft && slug !== "-index",
|
||||
);
|
||||
const filterByTags = taxonomyFilter(posts, "categories", tag!);
|
||||
---
|
||||
|
||||
<Base title={tag}>
|
||||
@@ -28,7 +31,7 @@ const filterByCategories = taxonomyFilter(posts, "tags", tag!);
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
{
|
||||
filterByCategories.map((post) => (
|
||||
filterByTags.map((post) => (
|
||||
<div class="mb-14 md:col-6 lg:col-4">
|
||||
<BlogCard data={post} />
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
import config from "@/config/config.json";
|
||||
import Base from "@/layouts/Base.astro";
|
||||
import { getAllTaxonomy, getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import { humanize } from "@/lib/utils/textConverter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
const { blog_folder }: { blog_folder: string } = config.settings;
|
||||
const tags = await getTaxonomy(blog_folder, "tags");
|
||||
const allTags = await getAllTaxonomy(blog_folder, "tags");
|
||||
const BLOG_FOLDER = "blog";
|
||||
|
||||
const tags = await getTaxonomy(BLOG_FOLDER, "tags");
|
||||
const allTags = await getAllTaxonomy(BLOG_FOLDER, "tags");
|
||||
---
|
||||
|
||||
<Base title={"Tags"}>
|
||||
|
||||
Reference in New Issue
Block a user