mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
Replace env variable with SITE config object
This commit is contained in:
+2
-1
@@ -1,11 +1,12 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
import Footer from "@components/Footer.astro";
|
||||
import LinkButton from "@components/LinkButton.astro";
|
||||
---
|
||||
|
||||
<Layout title={`404 Not Found | ${import.meta.env.PUBLIC_SITE_TITLE}`}>
|
||||
<Layout title={`404 Not Found | ${SITE.title}`}>
|
||||
<Header />
|
||||
|
||||
<main id="main-content">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Posts from "@layouts/Posts.astro";
|
||||
import PostDetails from "@layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@utils/getSortedPosts";
|
||||
@@ -59,8 +60,8 @@ const currentPage =
|
||||
slug && !isNaN(Number(slug)) && totalPages.includes(Number(slug))
|
||||
? Number(slug)
|
||||
: 0;
|
||||
const lastPost = currentPage * import.meta.env.PUBLIC_POST_PER_PAGE;
|
||||
const startPost = lastPost - import.meta.env.PUBLIC_POST_PER_PAGE;
|
||||
const lastPost = currentPage * SITE.postPerPage;
|
||||
const startPost = lastPost - SITE.postPerPage;
|
||||
|
||||
const paginatedPosts = sortedPosts.slice(startPost, lastPost);
|
||||
---
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Posts from "@layouts/Posts.astro";
|
||||
import getSortedPosts from "@utils/getSortedPosts";
|
||||
import getPageNumbers from "@utils/getPageNumbers";
|
||||
import type { Frontmatter } from "@utils/types";
|
||||
import type { Frontmatter } from "src/types";
|
||||
|
||||
const posts = await Astro.glob<Frontmatter>("../../contents/*.md");
|
||||
|
||||
@@ -10,10 +11,7 @@ const sortedPosts = getSortedPosts(posts);
|
||||
|
||||
const totalPages = getPageNumbers(posts.length);
|
||||
|
||||
const paginatedPosts = sortedPosts.slice(
|
||||
0,
|
||||
import.meta.env.PUBLIC_POST_PER_PAGE
|
||||
);
|
||||
const paginatedPosts = sortedPosts.slice(0, SITE.postPerPage);
|
||||
---
|
||||
|
||||
<Posts posts={paginatedPosts} pageNum={1} totalPages={totalPages.length} />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SITE } from "src/config";
|
||||
import rss from "@astrojs/rss";
|
||||
import type { Frontmatter } from "src/types";
|
||||
import type { MarkdownInstance } from "astro";
|
||||
@@ -12,9 +13,9 @@ const posts = Object.values(postImportResult);
|
||||
|
||||
export const get = () =>
|
||||
rss({
|
||||
title: import.meta.env.PUBLIC_SITE_TITLE,
|
||||
description: import.meta.env.PUBLIC_SITE_DESC,
|
||||
site: import.meta.env.SITE,
|
||||
title: SITE.title,
|
||||
description: SITE.desc,
|
||||
site: SITE.website,
|
||||
items: posts.map(({ frontmatter }) => ({
|
||||
link: frontmatter.slug,
|
||||
title: frontmatter.title,
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
import Footer from "@components/Footer.astro";
|
||||
import Search from "@components/Search";
|
||||
import type { Frontmatter } from "@utils/types";
|
||||
import type { Frontmatter } from "src/types";
|
||||
|
||||
localStorage.setItem("myCat", "Tom");
|
||||
|
||||
@@ -20,7 +21,7 @@ const searchList = posts.map(({ frontmatter }) => ({
|
||||
}));
|
||||
---
|
||||
|
||||
<Layout title={`Search | ${import.meta.env.PUBLIC_SITE_TITLE}`}>
|
||||
<Layout title={`Search | ${SITE.title}`}>
|
||||
<Header activeNav="search" />
|
||||
<Main pageTitle="Search" pageDesc="Search any article ...">
|
||||
<Search client:load searchList={searchList} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
@@ -42,7 +43,7 @@ const posts: MarkdownInstance<Frontmatter>[] = await Astro.glob(
|
||||
const tagPosts = getPostsByTag(posts, tag);
|
||||
---
|
||||
|
||||
<Layout title={`Tag:${tag} | ${import.meta.env.PUBLIC_SITE_TITLE}`}>
|
||||
<Layout title={`Tag:${tag} | ${SITE.title}`}>
|
||||
<Header activeNav="tags" />
|
||||
<Main
|
||||
pageTitle={`Tag:${tag}`}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
---
|
||||
import { SITE } from "src/config";
|
||||
import Header from "@components/Header.astro";
|
||||
import Footer from "@components/Footer.astro";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Tag from "@components/Tag.astro";
|
||||
import getUniqueTags from "@utils/getUniqueTags";
|
||||
import type { Frontmatter } from "@utils/types";
|
||||
import type { Frontmatter } from "src/types";
|
||||
|
||||
const posts = await Astro.glob<Frontmatter>("../../contents/*.md");
|
||||
|
||||
let tags = getUniqueTags(posts);
|
||||
---
|
||||
|
||||
<Layout title={`Tags | ${import.meta.env.PUBLIC_SITE_TITLE}`}>
|
||||
<Layout title={`Tags | ${SITE.title}`}>
|
||||
<Header activeNav="tags" />
|
||||
<Main pageTitle="Tags" pageDesc="All the tags used in posts.">
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user