add carbon rating
This commit is contained in:
@@ -13,4 +13,7 @@ interface Props {}
|
|||||||
<p>
|
<p>
|
||||||
<a href="/rss.xml"> Subscribe with RSS</a>
|
<a href="/rss.xml"> Subscribe with RSS</a>
|
||||||
</p>
|
</p>
|
||||||
|
<div id="wcb" class="carbonbadge"></div>
|
||||||
</footer>
|
</footer>
|
||||||
|
<script src="https://unpkg.com/website-carbon-badges@1.1.3/b.min.js" defer
|
||||||
|
></script>
|
||||||
|
|||||||
@@ -6,6 +6,12 @@ const { pathname } = Astro.url;
|
|||||||
|
|
||||||
interface Props {}
|
interface Props {}
|
||||||
|
|
||||||
|
interface NavLink {
|
||||||
|
label: string;
|
||||||
|
icon: string;
|
||||||
|
path: string;
|
||||||
|
}
|
||||||
|
|
||||||
const navLinks: NavLink[] = [
|
const navLinks: NavLink[] = [
|
||||||
{ label: 'Blog', icon: 'pen', path: '/' },
|
{ label: 'Blog', icon: 'pen', path: '/' },
|
||||||
{ label: 'About', icon: 'person', path: '/about/' },
|
{ label: 'About', icon: 'person', path: '/about/' },
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { z, defineCollection } from 'astro:content';
|
import { z, defineCollection } from 'astro:content';
|
||||||
import { Tag } from 'src/types';
|
|
||||||
|
|
||||||
const blogCollection = defineCollection({
|
const blogCollection = defineCollection({
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
pubDate: z.string().transform((str: string) => new Date(str)),
|
pubDate: z.string().transform((str: string) => new Date(str)),
|
||||||
tags: z.array(z.nativeEnum(Tag)),
|
tags: z.array(z.string()),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
---
|
---
|
||||||
import { format, add } from 'date-fns';
|
import { format, add } from 'date-fns';
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
import { Tag as TagEnum } from '../../types';
|
|
||||||
|
|
||||||
import Layout from '@layouts/Layout.astro';
|
import Layout from '@layouts/Layout.astro';
|
||||||
|
|
||||||
export const prerender = false;
|
export const prerender = false;
|
||||||
|
|
||||||
const { tag }: { tag?: TagEnum } = Astro.params;
|
const { tag }: { tag?: string } = Astro.params;
|
||||||
|
|
||||||
const posts = await getCollection('blog', ({ data }) => {
|
const posts = await getCollection('blog', ({ data }) => {
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag === TagEnum.all) {
|
if (tag === 'all') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
// navigation links
|
|
||||||
export type NavLink = {
|
|
||||||
label: string;
|
|
||||||
icon: string;
|
|
||||||
path: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
// blog tags
|
|
||||||
export enum Tag {
|
|
||||||
'Apps' = 'Apps',
|
|
||||||
'Digital Life' = 'Digital Life',
|
|
||||||
'Gaming' = 'Gaming',
|
|
||||||
'Learning' = 'Learning',
|
|
||||||
'Life' = 'Life',
|
|
||||||
'MacOS' = 'MacOS',
|
|
||||||
'Music' = 'Music',
|
|
||||||
'Making Stuff' = 'Making Stuff',
|
|
||||||
'Mental Health' = 'Mental Health',
|
|
||||||
'Movies & TV' = 'Movies & TV',
|
|
||||||
'Programming' = 'Programming',
|
|
||||||
'Tech' = 'Tech',
|
|
||||||
'Tutorial' = 'Tutorial',
|
|
||||||
'Web Dev' = 'Web Dev',
|
|
||||||
// only for filtering
|
|
||||||
all = 'all',
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user