From 8e336b8bd7daf81c6f3d81c42a61b777ccdf64d5 Mon Sep 17 00:00:00 2001
From: xHyroM
Date: Sat, 25 Feb 2023 11:01:29 +0100
Subject: [PATCH] feat: add prettier-astro and schema.org
add schema.org schema to main page, projects page, every blbog post for better SEO
---
.prettierrc.cjs | 11 +
package.json | 2 +-
pnpm-lock.yaml | 2 +-
src/components/widgets/Head.astro | 20 +-
src/components/widgets/blog/PostHead.astro | 42 +++-
src/layouts/Layout.astro | 50 ++--
src/layouts/blog/PostLayout.astro | 37 +--
src/pages/index.astro | 20 +-
src/pages/projects.astro | 273 +++++++++++----------
9 files changed, 263 insertions(+), 194 deletions(-)
create mode 100644 .prettierrc.cjs
diff --git a/.prettierrc.cjs b/.prettierrc.cjs
new file mode 100644
index 0000000..4a49707
--- /dev/null
+++ b/.prettierrc.cjs
@@ -0,0 +1,11 @@
+module.exports = {
+ plugins: [require.resolve("prettier-plugin-astro")],
+ overrides: [
+ {
+ files: "*.astro",
+ options: {
+ parser: "astro",
+ },
+ },
+ ],
+};
diff --git a/package.json b/package.json
index 83c1212..27c04bf 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"devDependencies": {
"@types/html-minifier": "^4.0.2",
"prettier": "2.8.1",
- "prettier-plugin-astro": "^0.7.1",
+ "prettier-plugin-astro": "^0.7.2",
"prettier-plugin-tailwindcss": "^0.2.1"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fa64f42..35d89d6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -13,7 +13,7 @@ specifiers:
fireworks-js: ^2.10.0
html-minifier: ^4.0.0
prettier: 2.8.1
- prettier-plugin-astro: ^0.7.1
+ prettier-plugin-astro: ^0.7.2
prettier-plugin-tailwindcss: ^0.2.1
tailwind: ^4.0.0
tailwindcss: ^3.2.4
diff --git a/src/components/widgets/Head.astro b/src/components/widgets/Head.astro
index e5a28f1..e79b7ff 100644
--- a/src/components/widgets/Head.astro
+++ b/src/components/widgets/Head.astro
@@ -1,13 +1,17 @@
+---
+const { schemaOrg } = Astro.props;
+---
+
xHyroM
-
+
-
+
@@ -25,6 +29,12 @@
\ No newline at end of file
+ http-equiv="Content-Security-Policy"
+ content="img-src 'self'; font-src *; style-src 'self' 'unsafe-inline' fonts.googleapis.com; script-src 'self' 'unsafe-inline'; object-src 'none'"
+/>
+
+{
+ schemaOrg && (
+
+ )
+}
diff --git a/src/components/widgets/blog/PostHead.astro b/src/components/widgets/blog/PostHead.astro
index 82bd09c..53fda9b 100644
--- a/src/components/widgets/blog/PostHead.astro
+++ b/src/components/widgets/blog/PostHead.astro
@@ -1,6 +1,6 @@
---
const url = Astro.url.pathname;
-const { title } = Astro.props;
+const { title, date } = Astro.props;
---
@@ -9,10 +9,10 @@ const { title } = Astro.props;
xHyroM
-
+
-
+
@@ -30,6 +30,36 @@ const { title } = Astro.props;
\ No newline at end of file
+ http-equiv="Content-Security-Policy"
+ content="img-src 'self'; font-src *; style-src 'self' 'unsafe-inline' fonts.googleapis.com; script-src 'self' 'unsafe-inline'; object-src 'none'"
+/>
+
+
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro
index 6d6c0bf..c988450 100644
--- a/src/layouts/Layout.astro
+++ b/src/layouts/Layout.astro
@@ -6,11 +6,11 @@ import DefaultHead from "../components/widgets/Head.astro";
const date = new Date();
const fireworks =
- (date.getMonth() === 11 && date.getDate() === 31) ||
- (date.getMonth() === 0 && date.getDate() <= 3);
+ (date.getMonth() === 11 && date.getDate() === 31) ||
+ (date.getMonth() === 0 && date.getDate() <= 3);
const snow =
- (date.getMonth() === 11 && date.getDate() === 10) ||
- (date.getMonth() === 0 && date.getDate() <= 3);
+ (date.getMonth() === 11 && date.getDate() === 10) ||
+ (date.getMonth() === 0 && date.getDate() <= 3);
const { head } = Astro.props;
const Head = head || DefaultHead;
@@ -18,30 +18,28 @@ const Head = head || DefaultHead;
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/layouts/blog/PostLayout.astro b/src/layouts/blog/PostLayout.astro
index e4bb3aa..6c4853b 100644
--- a/src/layouts/blog/PostLayout.astro
+++ b/src/layouts/blog/PostLayout.astro
@@ -2,30 +2,31 @@
import PostHead from "../../components/widgets/blog/PostHead.astro";
import Container from "../../components/atoms/Container.astro";
import Navbar from "../../components/widgets/Navbar.astro";
-import Layout from "../Layout.astro"
+import Layout from "../Layout.astro";
export interface Props {
- content: {
- title: string;
- };
+ content: {
+ title: string;
+ date: string;
+ };
}
const {
- content: { title },
+ content: { title, date },
} = Astro.props;
---
-
-
-
+
+
+
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
diff --git a/src/pages/index.astro b/src/pages/index.astro
index b8c7a1c..61c5720 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -4,7 +4,21 @@ import Hero from "../components/widgets/index/Hero.astro";
import Navbar from "../components/widgets/Navbar.astro";
---
-
-
-
+
+
+
diff --git a/src/pages/projects.astro b/src/pages/projects.astro
index 9f34f7e..772b27a 100644
--- a/src/pages/projects.astro
+++ b/src/pages/projects.astro
@@ -4,150 +4,155 @@ import Navbar from "../components/widgets/Navbar.astro";
import Container from "../components/atoms/Container.astro";
interface Project {
- name: string;
- link: string;
- desc: string;
- stats?: {
- forks: number;
- stars: number;
- };
+ name: string;
+ link: string;
+ desc: string;
+ stats?: {
+ forks: number;
+ stars: number;
+ };
}
const projects: Project[] = [
- {
- name: "HyLib",
- link: "https://github.com/xHyroM/HyLib",
- desc: "Source code for HyLib, a paper plugin and powerful library.",
- },
- {
- name: "HyChat",
- link: "https://github.com/xHyroM/HyChat",
- desc: "Source code for HyChat, a paper plugin.",
- },
- {
- name: "HyX",
- link: "https://github.com/xHyroM/HyX",
- desc: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Cumque, quaerat.",
- },
- {
- name: "Mashe",
- link: "https://github.com/xHyroM/mashe",
- desc: "Simple, fast, and easy to use Event Handling for Java.",
- },
- {
- name: "Mumblum",
- link: "https://github.com/xHyroM/mumblum",
- desc: "Mumblum is a simple, modern discord bot in JDA.",
- },
- {
- name: "setup-bun",
- link: "https://github.com/xHyroM/setup-bun",
- desc: "Set up your GitHub Actions workflow with a specific version of Bun.",
- },
- {
- name: "Roles Bot",
- link: "https://github.com/xHyroM/roles-bot",
- desc: 'Discord bot for "button" roles, using Cloudflare Workers.',
- },
- {
- name: "Bun Discord Bot",
- link: "https://github.com/xHyroM/bun-discord-bot",
- desc: "Official serverless discord bot for bun discord server.",
- },
- {
- name: "hykord",
- link: "https://github.com/xHyroM/hykord",
- desc: "My @discord client modification.",
- },
- {
- name: "frog",
- link: "https://github.com/xHyroM/frog",
- desc: "Frog is an extremely simple language based on the monkey language.",
- },
+ {
+ name: "HyLib",
+ link: "https://github.com/xHyroM/HyLib",
+ desc: "Source code for HyLib, a paper plugin and powerful library.",
+ },
+ {
+ name: "HyChat",
+ link: "https://github.com/xHyroM/HyChat",
+ desc: "Source code for HyChat, a paper plugin.",
+ },
+ {
+ name: "HyX",
+ link: "https://github.com/xHyroM/HyX",
+ desc: "Lorem ipsum dolor sit amet consectetur adipisicing elit. Cumque, quaerat.",
+ },
+ {
+ name: "Mashe",
+ link: "https://github.com/xHyroM/mashe",
+ desc: "Simple, fast, and easy to use Event Handling for Java.",
+ },
+ {
+ name: "Mumblum",
+ link: "https://github.com/xHyroM/mumblum",
+ desc: "Mumblum is a simple, modern discord bot in JDA.",
+ },
+ {
+ name: "setup-bun",
+ link: "https://github.com/xHyroM/setup-bun",
+ desc: "Set up your GitHub Actions workflow with a specific version of Bun.",
+ },
+ {
+ name: "Roles Bot",
+ link: "https://github.com/xHyroM/roles-bot",
+ desc: 'Discord bot for "button" roles, using Cloudflare Workers.',
+ },
+ {
+ name: "Bun Discord Bot",
+ link: "https://github.com/xHyroM/bun-discord-bot",
+ desc: "Official serverless discord bot for bun discord server.",
+ },
+ {
+ name: "hykord",
+ link: "https://github.com/xHyroM/hykord",
+ desc: "My @discord client modification.",
+ },
+ {
+ name: "frog",
+ link: "https://github.com/xHyroM/frog",
+ desc: "Frog is an extremely simple language based on the monkey language.",
+ },
];
for (const project of projects) {
- const repository = await (
- await fetch(`https://api.github.com/repos/${project.link.slice(19)}`, {
- headers: {
- Authorization: `Bearer ${import.meta.env.GITHUB_ACCESS_TOKEN}`,
- },
- })
- ).json();
+ const repository = await (
+ await fetch(`https://api.github.com/repos/${project.link.slice(19)}`, {
+ headers: {
+ Authorization: `Bearer ${import.meta.env.GITHUB_ACCESS_TOKEN}`,
+ },
+ })
+ ).json();
- project.stats = {
- forks: repository.forks,
- stars: repository.stargazers_count,
- };
+ project.stats = {
+ forks: repository.forks,
+ stars: repository.stargazers_count,
+ };
}
---
-
-
-
+ ({
+ "@type": "ListItem",
+ position: i + 1,
+ name: project.name,
+ url: project.link,
+ })),
+ }}
+>
+
+
-
-
- {
- projects.map((project) => (
-
-
-
- {project.name}
-
-
-
-
-
{project.stats!.stars}
-
-
- {" "}
-
-
{project.stats!.forks}
-
-
-
+
+
+ {
+ projects.map((project) => (
+
+
+
+ {project.name}
+
+
+
+
+
{project.stats!.stars}
+
+
+ {" "}
+
+
{project.stats!.forks}
+
+
+
-
- {project.desc}
-
-
-
- ))
- }
-
-
+ {project.desc}
+
+
+ ))
+ }
+
+