mirror of
https://github.com/10h30/astroplate.git
synced 2026-07-19 22:53:36 +09:00
added type definitions
This commit is contained in:
@@ -3,7 +3,7 @@ import Base from "@/layouts/Base.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
export async function getStaticPaths(): Promise<{params: {regular: string}}[]> {
|
||||
const pages = await getSinglePage("pages");
|
||||
|
||||
const paths = pages.map((page) => ({
|
||||
|
||||
@@ -6,8 +6,9 @@ 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 type { Blog_folder } from "types";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
export async function getStaticPaths(): Promise<{params: {single: string}, props: {author: string}}[]> {
|
||||
const authors = await getSinglePage("authors");
|
||||
|
||||
const paths = authors.map((author) => ({
|
||||
@@ -19,7 +20,7 @@ export async function getStaticPaths() {
|
||||
return paths;
|
||||
}
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
const { blog_folder }: Blog_folder = config.settings;
|
||||
const { author } = Astro.props;
|
||||
const { title, social, meta_title, description, image } = author.data;
|
||||
const { Content } = await author.render();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getTaxonomy } from "@/lib/taxonomyParser.astro";
|
||||
import taxonomyFilter from "@/lib/utils/taxonomyFilter";
|
||||
import PageHeader from "@/partials/PageHeader.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
export async function getStaticPaths(): Promise<{params: {category: string}}[]> {
|
||||
const categories = await getTaxonomy(
|
||||
config.settings.blog_folder,
|
||||
"categories"
|
||||
@@ -22,7 +22,7 @@ export async function getStaticPaths() {
|
||||
|
||||
const { category } = Astro.params;
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const filterByCategories = taxonomyFilter(posts, "categories", category);
|
||||
const filterByCategories = taxonomyFilter(posts, "categories", category!);
|
||||
---
|
||||
|
||||
<Base title={category}>
|
||||
|
||||
@@ -4,8 +4,9 @@ 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";
|
||||
import type { Blog_folder } from "types";
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
const { blog_folder }: Blog_folder = config.settings;
|
||||
const categories = await getTaxonomy(blog_folder, "categories");
|
||||
const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
---
|
||||
@@ -16,7 +17,7 @@ const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
<div class="container text-center">
|
||||
<ul>
|
||||
{
|
||||
categories.map((category: any) => {
|
||||
categories.map((category: string) => {
|
||||
const count = allCategories.filter((c) => c === category).length;
|
||||
return (
|
||||
<li class="m-3 inline-block">
|
||||
|
||||
@@ -5,7 +5,7 @@ import PageHeader from "@/partials/PageHeader.astro";
|
||||
import { getEntryBySlug } from "astro:content";
|
||||
|
||||
const entry = await getEntryBySlug("pages", "contact");
|
||||
const { contact_form_action } = config.params;
|
||||
const { contact_form_action }: {contact_form_action: string} = config.params;
|
||||
const { title, description, meta_title, image } = entry.data;
|
||||
---
|
||||
|
||||
|
||||
+13
-8
@@ -6,11 +6,22 @@ import Testimonial from "@/partials/Testimonial.astro";
|
||||
import { Image } from "@astrojs/image/components";
|
||||
import { getEntryBySlug } from "astro:content";
|
||||
import { FaCheck } from "react-icons/fa/index.js";
|
||||
import type { Button, Feature } from "types";
|
||||
|
||||
interface Homepage {
|
||||
banner: {
|
||||
title: string
|
||||
content: string,
|
||||
image: string,
|
||||
button: Button,
|
||||
}
|
||||
features: Feature[]
|
||||
}
|
||||
|
||||
const homepage = await getEntryBySlug("homepage", "index");
|
||||
const testimonial = await getEntryBySlug("sections", "testimonial");
|
||||
const call_to_action = await getEntryBySlug("sections", "call-to-action");
|
||||
const { banner, features } = homepage.data;
|
||||
const { banner, features }: Homepage = homepage.data;
|
||||
---
|
||||
|
||||
<Base>
|
||||
@@ -50,13 +61,7 @@ const { banner, features } = homepage.data;
|
||||
{
|
||||
features.map(
|
||||
(
|
||||
feature: {
|
||||
button: any;
|
||||
image: string;
|
||||
bulletpoints: any;
|
||||
content: string;
|
||||
title: string;
|
||||
},
|
||||
feature,
|
||||
index: number
|
||||
) => (
|
||||
<section class={`section-sm ${index % 2 === 0 && "bg-gradient"}`}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import Base from "@/layouts/Base.astro";
|
||||
import PostSingle from "@/layouts/PostSingle.astro";
|
||||
import { getSinglePage } from "@/lib/contentParser.astro";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
export async function getStaticPaths(): Promise<{params: {single: string}, props: {post: any}}[]> {
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
|
||||
const paths = posts.map((post) => ({
|
||||
|
||||
@@ -17,7 +17,7 @@ const allCategories = await getAllTaxonomy(blog_folder, "categories");
|
||||
const categories = await getTaxonomy(blog_folder, "categories");
|
||||
const tags = await getTaxonomy(blog_folder, "tags");
|
||||
const sortedPosts = sortByDate(posts);
|
||||
const totalPages = Math.ceil(posts.length / config.settings.pagination);
|
||||
const totalPages: number = Math.ceil(posts.length / config.settings.pagination);
|
||||
const currentPosts = sortedPosts.slice(0, config.settings.pagination);
|
||||
---
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function getStaticPaths() {
|
||||
|
||||
const { tag } = Astro.params;
|
||||
const posts = await getSinglePage(config.settings.blog_folder);
|
||||
const filterByCategories = taxonomyFilter(posts, "tags", tag);
|
||||
const filterByCategories = taxonomyFilter(posts, "tags", tag!);
|
||||
---
|
||||
|
||||
<Base title={tag}>
|
||||
|
||||
@@ -4,8 +4,9 @@ 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";
|
||||
import type { Blog_folder } from "types";
|
||||
|
||||
const { blog_folder } = config.settings;
|
||||
const { blog_folder }: Blog_folder = config.settings;
|
||||
const tags = await getTaxonomy(blog_folder, "tags");
|
||||
const allTags = await getAllTaxonomy(blog_folder, "tags");
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user