updated to astro v3.6

This commit is contained in:
somrat sorkar
2023-12-03 15:28:12 +06:00
parent 34e3ac525f
commit afb57b5825
22 changed files with 151 additions and 121 deletions
-3
View File
@@ -53,7 +53,4 @@ export default defineConfig({
},
extendDefaultPlugins: true,
},
build: {
format: "file",
},
});
+28 -27
View File
@@ -1,6 +1,6 @@
{
"name": "astroplate",
"version": "2.2.0",
"version": "2.3.0",
"description": "Astro and Tailwindcss boilerplate",
"author": "zeon.studio",
"license": "MIT",
@@ -8,53 +8,54 @@
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"format": "prettier -w ./src",
"generate-json": "node scripts/jsonGenerator.js",
"remove-darkmode": "node scripts/removeDarkmode.js && yarn format"
},
"dependencies": {
"@astrojs/mdx": "^1.1.3",
"@astrojs/react": "^3.0.4",
"@astrojs/mdx": "^1.1.5",
"@astrojs/react": "^3.0.6",
"@astrojs/rss": "^3.0.0",
"@astrojs/sitemap": "^3.0.2",
"@astrojs/sitemap": "^3.0.3",
"@astrojs/tailwind": "^5.0.2",
"astro": "^3.3.4",
"astro-auto-import": "^0.3.1",
"astro": "^3.6.4",
"astro-auto-import": "^0.4.1",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.0",
"disqus-react": "^1.1.5",
"fuse.js": "^6.6.2",
"fuse.js": "^7.0.0",
"github-slugger": "^2.0.0",
"gray-matter": "^4.0.3",
"marked": "^9.1.2",
"prettier-plugin-astro": "^0.12.0",
"prettier-plugin-tailwindcss": "^0.5.6",
"marked": "^11.0.0",
"prettier-plugin-astro": "^0.12.2",
"prettier-plugin-tailwindcss": "^0.5.7",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.11.0",
"react-lite-youtube-embed": "^2.3.52",
"react-icons": "^4.12.0",
"react-lite-youtube-embed": "^2.4.0",
"remark-collapse": "^0.1.2",
"remark-toc": "^9.0.0",
"sharp": "^0.32.6",
"swiper": "^11.0.1"
"sharp": "^0.33.0",
"swiper": "^11.0.5"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@types/marked": "^5.0.2",
"@types/node": "20.8.8",
"@types/react": "18.2.31",
"@types/react-dom": "18.2.14",
"@types/node": "20.10.2",
"@types/react": "18.2.41",
"@types/react-dom": "18.2.17",
"autoprefixer": "^10.4.16",
"eslint": "^8.52.0",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.0",
"prettier-plugin-tailwindcss": "^0.5.6",
"sass": "^1.69.4",
"tailwindcss": "^3.3.4",
"tailwind-bootstrap-grid": "^5.0.1",
"typescript": "5.2.2"
"eslint": "^8.55.0",
"postcss": "^8.4.32",
"prettier": "^3.1.0",
"prettier-plugin-astro": "^0.12.2",
"prettier-plugin-tailwindcss": "^0.5.7",
"sass": "^1.69.5",
"tailwindcss": "^3.3.5",
"tailwind-bootstrap-grid": "^5.1.0",
"typescript": "5.3.2"
}
}
+2 -2
View File
@@ -10,8 +10,8 @@
</h2>
<p align=center>
<a href="https://github.com/withastro/astro/releases/tag/astro%403.0.0" alt="Contributors">
<img src="https://img.shields.io/static/v1?label=ASTRO&message=3.0&color=000&logo=astro" />
<a href="https://github.com/withastro/astro/releases/tag/astro%403.6.0" alt="Contributors">
<img src="https://img.shields.io/static/v1?label=ASTRO&message=3.6&color=000&logo=astro" />
</a>
<a href="https://github.com/zeon-studio/astroplate/blob/main/LICENSE">
+9 -6
View File
@@ -1,23 +1,26 @@
---
import BlogCard from "@/components/BlogCard.astro";
import Share from "@/components/Share.astro";
import config from "@/config/config.json";
import Disqus from "@/helpers/Disqus";
import { getSinglePage } from "@/lib/contentParser.astro";
import dateFormat from "@/lib/utils/dateFormat";
import similerItems from "@/lib/utils/similarItems";
import similarItems from "@/lib/utils/similarItems";
import { humanize, markdownify, slugify } from "@/lib/utils/textConverter";
import { Image } from "astro:assets";
import { getCollection } from "astro:content";
import {
FaRegClock,
FaRegFolder,
FaRegUserCircle,
} from "react-icons/fa/index.js";
const { blog_folder } = config.settings;
const posts = await getSinglePage(blog_folder);
const COLLECTION_FOLDER = "blog";
const { post } = Astro.props;
const similarPosts = similerItems(post, posts, post.slug);
const posts = await getCollection(
COLLECTION_FOLDER,
({ data, slug }) => !data.draft && slug !== "-index",
);
const similarPosts = similarItems(post, posts);
const { Content } = await post.render();
const { title, description, author, categories, image, date, tags } = post.data;
---
+2 -2
View File
@@ -25,7 +25,7 @@ interface SearchResult {
refIndex: number;
}
const Search = ({ searchList }: Props) => {
const SearchLayout = ({ searchList }: Props) => {
const inputRef = useRef<HTMLInputElement>(null);
const [inputVal, setInputVal] = useState("");
const [searchResults, setSearchResults] = useState<SearchResult[]>([]);
@@ -178,4 +178,4 @@ const Search = ({ searchList }: Props) => {
);
};
export default Search;
export default SearchLayout;
+1 -1
View File
@@ -20,7 +20,7 @@ export interface ISocial {
rel="noopener noreferrer nofollow"
>
<span class="sr-only">{social.name}</span>
<DynamicIcon class="inline-block" icon={social.icon} />
<DynamicIcon className="inline-block" icon={social.icon} />
</a>
</li>
))
+1 -1
View File
@@ -1,4 +1,4 @@
import React, { FC } from "react";
import React, { type FC } from "react";
import type { IconType } from "react-icons";
import * as FaIcons from "react-icons/fa6/index.js";
// import * as AiIcons from "react-icons/ai/index.js";
-10
View File
@@ -1,10 +0,0 @@
---
import { getCollection } from "astro:content";
export const getSinglePage = async (collection: any) => {
const allPage = await getCollection(collection);
const removeIndex = allPage.filter((data: any) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data: any) => !data.data.draft);
return removeDrafts;
};
---
+11 -2
View File
@@ -1,8 +1,16 @@
---
import { getSinglePage } from "./contentParser.astro";
import { getCollection } from "astro:content";
import { slugify } from "./utils/textConverter";
// get all taxonomies from frontmatter
// get all pages from collection
export const getSinglePage = async (collection: any) => {
const allPage = await getCollection(collection);
const removeIndex = allPage.filter((data: any) => data.id.match(/^(?!-)/));
const removeDrafts = removeIndex.filter((data: any) => !data.data.draft);
return removeDrafts;
};
// get taxonomy from frontmatter
export const getTaxonomy = async (collection: string, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
@@ -17,6 +25,7 @@ export const getTaxonomy = async (collection: string, name: string) => {
return taxonomy;
};
// get all taxonomies from frontmatter
export const getAllTaxonomy = async (collection: string, name: string) => {
const singlePages = await getSinglePage(collection);
const taxonomyPages = singlePages.map((page: any) => page.data[name]);
+6 -4
View File
@@ -1,5 +1,5 @@
// similer products
const similerItems = (currentItem: any, allItems: any, slug: string) => {
// similar products
const similarItems = (currentItem: any, allItems: any[]) => {
let categories: string[] = [];
let tags: string[] = [];
@@ -27,9 +27,11 @@ const similerItems = (currentItem: any, allItems: any, slug: string) => {
const mergedItems = [...new Set([...filterByCategories, ...filterByTags])];
// filter by slug
const filterBySlug = mergedItems.filter((product) => product.slug !== slug);
const filterBySlug = mergedItems.filter(
(product) => product.slug !== currentItem.slug,
);
return filterBySlug;
};
export default similerItems;
export default similarItems;
+7 -2
View File
@@ -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: {
+10 -5
View File
@@ -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),
);
+8 -4
View File
@@ -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}>
+6 -3
View File
@@ -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: {
+12 -9
View File
@@ -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}
/>
+17 -10
View File
@@ -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}
/>
+7 -7
View File
@@ -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!);
---
+4 -4
View File
@@ -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"}>
+7 -8
View File
@@ -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>
+9 -6
View File
@@ -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>
+4 -4
View File
@@ -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"}>
-1
View File
@@ -11,7 +11,6 @@
"isolatedModules": true,
"incremental": true,
"allowSyntheticDefaultImports": true,
"types": ["@astrojs/image/client"],
"paths": {
"@/components/*": ["./src/layouts/components/*"],
"@/shortcodes/*": ["./src/layouts/shortcodes/*"],