Add variables to config and minimal refactor

This commit is contained in:
prototypa
2022-08-28 20:31:06 -04:00
parent 06bf8df636
commit 19b4a25012
9 changed files with 33 additions and 35 deletions

View File

@ -2,6 +2,8 @@
import { getImage } from "@astrojs/image"; import { getImage } from "@astrojs/image";
import { getRelativeUrlByFilePath } from "~/utils/getRelativeUrlByFilePath"; import { getRelativeUrlByFilePath } from "~/utils/getRelativeUrlByFilePath";
import { SITE } from "~/config.mjs";
const { src: defaultImage } = await getImage({ const { src: defaultImage } = await getImage({
src: import("~/assets/images/default.png"), src: import("~/assets/images/default.png"),
width: 1200, width: 1200,
@ -9,7 +11,7 @@ const { src: defaultImage } = await getImage({
}); });
const { const {
title = "AstroWind", title = SITE.name,
description = "", description = "",
image: _image = defaultImage, image: _image = defaultImage,
canonical, canonical,
@ -60,4 +62,4 @@ const image =
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;700&display=swap" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;700&display=swap" rel="stylesheet" />
<!-- Google Site Verification --> <!-- Google Site Verification -->
<meta name="google-site-verification" content="orcPxI47GSa-cRvY11tUe6iGg2IO_RPvnA1q95iEM3M" /> {SITE.googleSiteVerificationId && <meta name="google-site-verification" content={SITE.googleSiteVerificationId} />}

View File

@ -1,9 +1,12 @@
export const SITE = { export const SITE = {
name: "AstroWind", name: "AstroWind",
domain: "https://astrowind.vercel.app", domain: "https://astrowind.vercel.app",
github: "https://github.com/onwidget/astrowind",
title: "AstroWind — Your website with Astro + Tailwind CSS",
description: "🚀 AstroWind is a free and ready to start template to make your website using Astro and Tailwind CSS.",
postsPerPage: 6, postsPerPage: 6,
googleAnalyticsId: false, // or "G-XXXXXXXXXX" googleAnalyticsId: false, // or "G-XXXXXXXXXX",
googleSiteVerificationId: "orcPxI47GSa-cRvY11tUe6iGg2IO_RPvnA1q95iEM3M",
}; };

View File

@ -16,7 +16,8 @@ const { googleAnalyticsId = false } = SITE;
<head> <head>
<MetaTags {...meta} /> <MetaTags {...meta} />
{googleAnalyticsId && <Analytics id={googleAnalyticsId} />} {googleAnalyticsId &&
<Analytics id={googleAnalyticsId} />}
</head> </head>
<body class="antialiased text-gray-900 dark:text-slate-300 tracking-tight bg-white dark:bg-slate-900"> <body class="antialiased text-gray-900 dark:text-slate-300 tracking-tight bg-white dark:bg-slate-900">
@ -24,4 +25,4 @@ const { googleAnalyticsId = false } = SITE;
<BasicScripts /> <BasicScripts />
</body> </body>
</html> </html>

View File

@ -9,6 +9,8 @@ const { meta } = Astro.props;
<Layout meta={meta}> <Layout meta={meta}>
<Header /> <Header />
<slot /> <main>
<slot />
</main>
<Footer /> <Footer />
</Layout> </Layout>

View File

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

View File

@ -18,14 +18,11 @@ const { page } = Astro.props;
const currentPage = page.currentPage ?? 1; const currentPage = page.currentPage ?? 1;
const title = `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name const title = `Blog ${currentPage > 1 ? `— Page ${currentPage} ` : ""}— ${SITE.name}`;
}`; const description = SITE.description;
const description = "News and step-by-step guides about AstroWind";
const canonical = new URL(page.url.current, Astro.site); const canonical = new URL(page.url.current, Astro.site);
--- ---
<Layout meta={{ title, description, canonical }}> <Layout meta={{ title, description, canonical }}>
<main> <BlogList page={page} />
<BlogList page={page} />
</main>
</Layout> </Layout>

View File

@ -25,7 +25,5 @@ const image = await findImage(post.image);
--- ---
<Layout meta={{ title, description, canonical, image, }}> <Layout meta={{ title, description, canonical, image, }}>
<main> <BlogPost post={{ ...post, image }} />
<BlogPost post={{ ...post, image }} />
</main>
</Layout> </Layout>

View File

@ -13,22 +13,19 @@ import StepsLeft from "~/components/widgets/StepsLeft.astro";
import HighlightedPosts from "~/components/widgets/HighlightedPosts.astro"; import HighlightedPosts from "~/components/widgets/HighlightedPosts.astro";
import Stats from "~/components/widgets/Stats.astro"; import Stats from "~/components/widgets/Stats.astro";
const title = `${SITE.name} — Your website with Astro + Tailwind CSS`; const title = SITE.title;
const description = const description = SITE.description;
"🚀 AstroWind is a free and Ready to Start template to make your website using Astro and Tailwind CSS.";
const canonical = new URL("", Astro.site); const canonical = new URL("", Astro.site);
--- ---
<Layout meta={{ title, description, canonical }}> <Layout meta={{ title, description, canonical }}>
<main> <Hero />
<Hero /> <BasicFeatures />
<BasicFeatures /> <StepsLeft />
<StepsLeft /> <TwoColsFeatures />
<TwoColsFeatures /> <StepsFeatures />
<StepsFeatures /> <HighlightedPosts />
<HighlightedPosts /> <FAQs />
<FAQs /> <Stats />
<Stats /> <BasicCTA />
<BasicCTA />
</main>
</Layout> </Layout>

View File

@ -8,9 +8,9 @@ const posts = await fetchPosts();
export const get = () => export const get = () =>
rss({ rss({
title: `${SITE.name}s Blog`, title: `${SITE.name}s Blog`,
description: description: SITE.description,
"A ready to start template to make your website using Astro and Tailwind CSS.",
site: import.meta.env.SITE, site: import.meta.env.SITE,
items: posts.map((post) => ({ items: posts.map((post) => ({
link: `blog/${post.slug}`, link: `blog/${post.slug}`,
title: post.title, title: post.title,