From f6672ce070ead59b9e820de8966c302e81627bb4 Mon Sep 17 00:00:00 2001 From: prototypa Date: Fri, 6 Jan 2023 16:01:06 -0500 Subject: [PATCH] Refactor and add more configuration to src/config.mjs --- README.md | 57 ++++++++++++++++------------- package.json | 2 +- src/components/blog/GridItem.astro | 23 ++++++++---- src/components/blog/ListItem.astro | 27 +++++++++----- src/components/common/Tags.astro | 3 +- src/config.mjs | 53 ++++++++++++++------------- src/pages/[...blog]/[...page].astro | 4 +- src/utils/permalinks.ts | 2 +- 8 files changed, 99 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 9cd831d..df00dd3 100644 --- a/README.md +++ b/README.md @@ -143,44 +143,51 @@ All commands are run from the root of the project, from a terminal: Basic configuration file: `./src/config.mjs` ```javascript -export const SITE = { - name: 'Example', +const CONFIG = { + name: 'Example', origin: 'https://example.com', basePathname: '/', // Change this if you need to deploy to Github Pages, for example trailingSlash: false, // Generate permalinks with or without "/" at the end - title: 'Example - This is the homepage title of Example', - description: 'This is the homepage description of Example', + title: 'Example - This is the homepage title of Example', // default seo title + description: 'This is the homepage description of Example', // default seo description + defaultImage: "image.jpg", // default seo image + + defaultTheme: 'system', // Values: "system" | "light" | "dark" | "light:only" | "dark:only" googleAnalyticsId: false, // or "G-XXXXXXXXXX", googleSiteVerificationId: false, // or some value, -}; -export const BLOG = { - disabled: false, - postsPerPage: 4, + blog: { + disabled: false, + postsPerPage: 4, - blog: { - disabled: false, - pathname: 'blog', // blog main path, you can change this to "articles" (/articles) - }, + list: { + pathname: 'blog', // blog main path, you can change this to "articles" (/articles) + noindex: false, + disabled: false, + }, - post: { - disabled: false, - pathname: '', // empty for /some-post, value for /pathname/some-post - }, + post: { + pathname: '', // empty for /some-post, value for /pathname/some-post + noindex: false, + disabled: false, + }, - category: { - disabled: false, - pathname: 'category', // set empty to change from /category/some-category to /some-category - }, + category: { + pathname: 'category', // set empty to change from /category/some-category to /some-category + noindex: true, + disabled: false, + }, - tag: { - disabled: false, - pathname: 'tag', // set empty to change from /tag/some-tag to /some-tag - }, -}; + tag: { + pathname: 'tag', // set empty to change from /tag/some-tag to /some-tag + noindex: true, + disabled: false, + }, + }, +} ```
diff --git a/package.json b/package.json index 929d9da..80ad837 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@onwidget/astrowind", "description": "A template to make your website using Astro + Tailwind CSS.", - "version": "0.9.3", + "version": "0.9.4", "private": true, "scripts": { "dev": "astro dev", diff --git a/src/components/blog/GridItem.astro b/src/components/blog/GridItem.astro index e3cd7b0..32e5407 100644 --- a/src/components/blog/GridItem.astro +++ b/src/components/blog/GridItem.astro @@ -1,11 +1,12 @@ --- import { Picture } from '@astrojs/image/components'; +import { BLOG } from '~/config.mjs'; +import type { Post } from '~/types'; + import { findImage } from '~/utils/images'; import { getPermalink } from '~/utils/permalinks'; -import type { Post } from '~/types'; - export interface Props { post: Post; } @@ -30,12 +31,18 @@ const image = await findImage(post.image); }

- - {post.title} - + { + BLOG?.post?.disabled ? ( + post.title + ) : ( + + {post.title} + + ) + }

{post.excerpt || post.description}

diff --git a/src/components/blog/ListItem.astro b/src/components/blog/ListItem.astro index f56137d..70db6da 100644 --- a/src/components/blog/ListItem.astro +++ b/src/components/blog/ListItem.astro @@ -2,24 +2,27 @@ import { Picture } from '@astrojs/image/components'; import PostTags from '~/components/common/Tags.astro'; +import { BLOG } from '~/config.mjs'; +import type { Post } from '~/types'; + import { getPermalink } from '~/utils/permalinks'; import { findImage } from '~/utils/images'; import { getFormattedDate } from '~/utils/utils'; -import type { Post } from '~/types'; - export interface Props { post: Post; } const { post } = Astro.props; const image = await findImage(post.image); + +const link = !BLOG?.post?.disabled ? getPermalink(post.slug, 'post') : ''; ---
{ image && ( - +