Skip to content

Commit

Permalink
refactor: 博客内容重构
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrickill committed Feb 6, 2024
1 parent e31ac59 commit f003b88
Show file tree
Hide file tree
Showing 64 changed files with 934 additions and 847 deletions.
86 changes: 1 addition & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1 @@
![img.png](img.png)

# Tailwind Astro Starter Project
[![GitHub Repo stars](https://img.shields.io/github/stars/wanoo21/tailwind-astro-starting-blog?style=social)](https://GitHub.com/wanoo21/tailwind-astro-starting-blog/stargazers/)
[![GitHub forks](https://img.shields.io/github/forks/wanoo21/tailwind-astro-starting-blog?style=social)](https://GitHub.com/wanoo21/tailwind-astro-starting-blog/network/)
[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fipwanciu)](https://twitter.com/ipwanciu)

[//]: # ([![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/timlrx)](https://github.com/sponsors/timlrx))

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/wanoo21/tailwind-astro-starting-blog)


This template is perfect for those who want to use Tailwind CSS and Astro to build a blog.

It is inspired by the [Tailwind Next.js Starter Blog](https://github.com/timlrx/tailwind-nextjs-starter-blog) - one of the most popular Next.js blogging templates.

Feature request or Facing issue? Check the [discussion page](https://github.com/wanoo21/tailwind-astro-starting-blog/discussions) to see if it has been brought up previously. Otherwise, feel free to start a new discussion thread. All ideas are welcomed!

## Demo

[Live Demo](https://tasb.yon.fun/) - Deployed on Vercel.

## Features

- Astro with Typescript
- Astro MDX support
- Easy styling customization with [Tailwind 3.3](https://tailwindcss.com/blog/tailwindcss-v3-3) and primary color attribute
- ~~Perfect lighthouse score~~ - Still have to make some improvements
- Mobile-friendly view
- Light and dark theme
- ~~Font optimization~~ - Not yet implemented
- Automatic image optimization via Astro image component
- Support for tags - each unique tag will be its own page
- Support for multiple authors
- ~~3 different blog layouts~~ - Only 2 for now
- ~~2 different blog listing layouts~~ - Only 1 for now
- Support for nested routing of blog posts
- Projects page
- ~~SEO friendly~~ still working on this, but already supports RSS feed, sitemaps and more!

Even thought these features looks the same as the original template, they are implemented in a different way, and there are more to come.

However, there are some features that are not in the original template, like:

- Support for multiple authors pages - **each author will have** its own page, with a list of all the posts written by him/her.
- Support for multiple tags pages - **each tag has its own page with custom description**, that can be customized with markdown.
- Related posts - **each post has** a list of related posts, provided by the author inside the markdown file.
- Pagination inside blog/tags pages - **each blog/tags page has** a pagination.
- Cool animations provided by Astro.
- And many more that would come in the future.

## Extend / Customize

`src/consts.ts` contains a list of constants that you can customize to your liking, including the blog title, description, author, social media links, etc.

`src/functions.ts` contains a list of functions that changes the default behavior of the template, including default post sorting and exclude draft posts.

`src/content/authors/default.mdx` contains the default author information. You can add more authors by adding more `.mdx` files in the `src/content/authors` folder.

`src/content/tags/default.mdx` contains the default tag information. You can add more tags by adding more `.mdx` files in the `src/content/tags` folder.

`src/content/config.ts` contains all fields for author, blog and tags pages. Check what's required and what's not. You can also add more fields if you want to.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

### 🐳 Docker Commands

All Docker commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------------------ | :------------------------------------------------------- |
| `docker build -t app:1.0.0 .` | Build the Docker image for the Astro application. |
| `docker run -p 80:4321 app:1.0.0` | Run a Docker container with the built Astro application. |
| `docker pull edwardb11/app:2.0.0` | Download the Docker image from Docker Hub. |
一个astro构建的个人博客
Binary file removed img.png
Binary file not shown.
58 changes: 49 additions & 9 deletions public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
9 changes: 0 additions & 9 deletions public/static/favicons/browserconfig.xml

This file was deleted.

Empty file.
Empty file.
Empty file removed public/static/favicons/favicon.ico
Empty file.
Empty file.
21 changes: 0 additions & 21 deletions public/static/favicons/safari-pinned-tab.svg

This file was deleted.

14 changes: 0 additions & 14 deletions public/static/favicons/site.webmanifest

This file was deleted.

Binary file modified public/static/images/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Empty file.
Binary file removed public/static/images/google.png
Binary file not shown.
Binary file modified public/static/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file removed public/static/images/ocean.jpeg
Empty file.
Binary file added public/static/images/qqQr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Binary file removed public/static/images/time-machine.jpg
Binary file not shown.
Empty file.
Binary file added public/static/images/wxQr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 67 additions & 45 deletions src/components/BaseHead.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
// Import the global.css file here so that it is included on
// all pages through the use of the <BaseHead /> component.
import '@/styles/global.css';
import {SITE_METADATA} from "@/consts";
import {ViewTransitions} from 'astro:transitions';
import "@/styles/global.css";
import { SITE_METADATA } from "@/consts";
import { ViewTransitions } from "astro:transitions";
interface Props {
title: string;
Expand All @@ -13,56 +13,78 @@ interface Props {
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
const {title, description, image = '/blog-placeholder-1.jpg'} = Astro.props;
const { title, description, image = "/blog-placeholder-1.jpg" } = Astro.props;
---

<head>
<!-- Global Metadata -->
<meta charset="utf-8" lang={SITE_METADATA.language}/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="icon" type="image/svg+xml" href="/favicon.svg"/>
<meta name="generator" content={Astro.generator}/>
<!-- Global Metadata -->
<meta charset="utf-8" lang={SITE_METADATA.language} />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />

<!-- Font preloads -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Font preloads -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />

<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap"
rel="stylesheet" crossorigin>
<!--<link rel="preload" href="/fonts/atkinson-regular.woff" as="font" type="font/woff" crossorigin />-->
<!--<link rel="preload" href="/fonts/atkinson-bold.woff" as="font" type="font/woff" crossorigin />-->
<link
href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
crossorigin
/>
<!--<link rel="preload" href="/fonts/atkinson-regular.woff" as="font" type="font/woff" crossorigin />-->
<!--<link rel="preload" href="/fonts/atkinson-bold.woff" as="font" type="font/woff" crossorigin />-->

<!-- Canonical URL -->
<link rel="canonical" href={canonicalURL}/>
<!-- Canonical URL -->
<link rel="canonical" href={canonicalURL} />

<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="description" content={description}/>
<!-- Primary Meta Tags -->
<title>{title}</title>
<meta name="description" content={description} />

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website"/>
<meta property="og:url" content={Astro.url}/>
<meta property="og:title" content={title}/>
<meta property="og:description" content={description}/>
<meta property="og:image" content={new URL(image, Astro.url)}/>
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={new URL(image, Astro.url)} />

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image"/>
<meta property="twitter:url" content={Astro.url}/>
<meta property="twitter:title" content={title}/>
<meta property="twitter:description" content={description}/>
<meta property="twitter:image" content={new URL(image, Astro.url)}/>
<!-- Favicons -->
<link
rel="apple-touch-icon"
sizes="76x76"
href="/static/favicons/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/static/favicons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/static/favicons/favicon-16x16.png"
/>
<link rel="manifest" href="/static/favicons/site.webmanifest" />
<link
rel="mask-icon"
href="/static/favicons/safari-pinned-tab.svg"
color="#5bbad5"
/>
<meta name="msapplication-TileColor" content="#000000" />
<meta
name="theme-color"
media="(prefers-color-scheme: light)"
content="#fff"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="#000"
/>
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />

<!-- Favicons -->
<link rel="apple-touch-icon" sizes="76x76" href="/static/favicons/apple-touch-icon.png"/>
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicons/favicon-32x32.png"/>
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicons/favicon-16x16.png"/>
<link rel="manifest" href="/static/favicons/site.webmanifest"/>
<link rel="mask-icon" href="/static/favicons/safari-pinned-tab.svg" color="#5bbad5"/>
<meta name="msapplication-TileColor" content="#000000"/>
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fff"/>
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000"/>
<link rel="alternate" type="application/rss+xml" href="/rss.xml"/>

<ViewTransitions/>
<ViewTransitions />
</head>
50 changes: 20 additions & 30 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,38 +1,28 @@
---
import SocialIcon from '@/components/social-icons/index.astro'
import {SITE_METADATA} from '@/consts'
import SocialIcon from "@/components/social-icons/index.astro";
import { SITE_METADATA } from "@/consts";
import Link from "./Link.astro";
---

<footer>
<div class="mt-16 flex flex-col items-center">
<div class="mb-3 flex space-x-4">
<SocialIcon kind="mail" href={`mailto:${SITE_METADATA.email}`} size={6}/>
<SocialIcon kind="github" href={SITE_METADATA.github} size={6}/>
<SocialIcon kind="facebook" href={SITE_METADATA.facebook} size={6}/>
<SocialIcon kind="youtube" href={SITE_METADATA.youtube} size={6}/>
<SocialIcon kind="linkedin" href={SITE_METADATA.linkedin} size={6}/>
<SocialIcon kind="twitter" href={SITE_METADATA.twitter} size={6}/>
</div>
<div class="mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400">
<Link href="/about">{SITE_METADATA.author}</Link>
<div>{``}</div>
<div>{`© ${new Date().getFullYear()}`}</div>
<div>{``}</div>
<Link href="/">{SITE_METADATA.title}</Link>
</div>
<div class="mb-8 text-sm text-gray-500 dark:text-gray-400">
<Link href={SITE_METADATA.siteRepo}>
{SITE_METADATA.title} {` is open source. `}
{` View `}
<span class="underline">the source</span>
{` code on `}
<span class="underline">GitHub</span>
{` and `}
<span class="underline">give it a star</span>
{` if you like it.`}
</Link>
</div>
<div class="mt-16 flex flex-col items-center">
<div class="mb-3 flex space-x-4">
<SocialIcon kind="github" href={SITE_METADATA.github} size={6} />
<SocialIcon kind="wx" href="/contact" size={6} />
<SocialIcon kind="qq" href="/contact" size={6} />
</div>
<div class="mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400">
<Link href="/about">{SITE_METADATA.author}</Link>
<div>{``}</div>
<div>{`© ${new Date().getFullYear()}`}</div>
<div>{``}</div>
<Link href="/">{SITE_METADATA.title}</Link>
</div>
<div class="mb-8 text-sm text-gray-500 dark:text-gray-400">
<Link href={SITE_METADATA.siteRepo}>
{"博客源码地址"}
</Link>
</div>
</div>
</footer>
Loading

0 comments on commit f003b88

Please sign in to comment.