Skip to content

Commit 68bc467

Browse files
committed
feat: hook up to katharostech directus.
1 parent 3f13d16 commit 68bc467

File tree

12 files changed

+5429
-227
lines changed

12 files changed

+5429
-227
lines changed

deno.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"imports": {
3+
"crypto": "node:crypto"
4+
}
5+
}

deno.lock

+5,082
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
"@astrojs/sitemap": "^3.2.1",
2727
"@astrolib/analytics": "^0.6.1",
2828
"@astrolib/seo": "^1.0.0-beta.8",
29+
"@directus/sdk": "^19.0.0",
2930
"@fontsource-variable/inter": "^5.1.1",
3031
"astro": "^5.1.8",
3132
"astro-embed": "^0.9.0",
3233
"astro-icon": "^1.1.5",
3334
"limax": "4.1.0",
3435
"lodash.merge": "^4.6.2",
36+
"marked": "^15.0.6",
3537
"unpic": "^3.22.0"
3638
},
3739
"devDependencies": {

src/components/blog/SinglePost.astro

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Icon } from 'astro-icon/components';
33
44
import Image from '~/components/common/Image.astro';
55
import PostTags from '~/components/blog/Tags.astro';
6-
import SocialShare from '~/components/common/SocialShare.astro';
6+
// import SocialShare from '~/components/common/SocialShare.astro';
77
88
import { getPermalink } from '~/utils/permalinks';
99
import { getFormattedDate } from '~/utils/utils';
@@ -15,7 +15,7 @@ export interface Props {
1515
url: string | URL;
1616
}
1717
18-
const { post, url } = Astro.props;
18+
const { post /*, url*/ } = Astro.props;
1919
---
2020

2121
<section class="py-8 sm:py-16 lg:py-20 mx-auto">
@@ -97,7 +97,7 @@ const { post, url } = Astro.props;
9797
</div>
9898
<div class="mx-auto px-6 sm:px-6 max-w-3xl mt-8 flex justify-between flex-col sm:flex-row">
9999
<PostTags tags={post.tags} class="mr-5 rtl:mr-0 rtl:ml-5" />
100-
<SocialShare url={url} text={post.title} class="mt-5 sm:mt-1 align-middle text-gray-500 dark:text-slate-600" />
100+
<!-- <SocialShare url={url} text={post.title} class="mt-5 sm:mt-1 align-middle text-gray-500 dark:text-slate-600" /> -->
101101
</div>
102102
</article>
103103
</section>

src/config.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
site:
2-
name: AstroWind
3-
site: 'https://astrowind.vercel.app'
2+
name: KTech Studio
3+
site: 'https://ktech.studio'
44
base: '/'
55
trailingSlash: false
66

7-
googleSiteVerificationId: orcPxI47GSa-cRvY11tUe6iGg2IO_RPvnA1q95iEM3M
7+
# googleSiteVerificationId: orcPxI47GSa-cRvY11tUe6iGg2IO_RPvnA1q95iEM3M
88

99
# Default SEO metadata
1010
metadata:
1111
title:
12-
default: AstroWind
13-
template: '%s — AstroWind'
14-
description: "\U0001F680 Suitable for Startups, Small Business, Sass Websites, Professional Portfolios, Marketing Websites, Landing Pages & Blogs."
12+
default: KTech Studio
13+
template: '%s — KTech Studio'
14+
description: "Indie game development."
1515
robots:
1616
index: true
1717
follow: true
1818
openGraph:
19-
site_name: AstroWind
19+
site_name: KTech Studio
2020
images:
2121
- url: '~/assets/images/default.png'
2222
width: 1200
@@ -69,4 +69,4 @@ analytics:
6969
id: null # or "G-XXXXXXXXXX"
7070

7171
ui:
72-
theme: 'system' # Values: "system" | "light" | "dark" | "light:only" | "dark:only"
72+
theme: 'dark:only' # Values: "system" | "light" | "dark" | "light:only" | "dark:only"

src/content/config.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z, defineCollection } from 'astro:content';
2-
import { glob } from 'astro/loaders';
2+
import { marked } from 'marked';
3+
import { getArticles } from '~/lib/directus';
34

45
const metadataDefinition = () =>
56
z
@@ -47,7 +48,26 @@ const metadataDefinition = () =>
4748
.optional();
4849

4950
const postCollection = defineCollection({
50-
loader: glob({ pattern: ['*.md', '*.mdx'], base: 'src/data/post' }),
51+
loader: async () => {
52+
const data = await getArticles();
53+
54+
return data.articles.map((x) => {
55+
const findEnglish = (t: { languages_id: { code: string } }) => t.languages_id.code.startsWith('en');
56+
const translation = x.translations.find(findEnglish)!;
57+
return {
58+
id: x.slug,
59+
title: translation.title,
60+
publishDate: new Date(x.published_date),
61+
content: marked(translation.body),
62+
tags: x.tags.map((tag) => tag.tags_id.slug),
63+
image: translation.feature_image?.id
64+
? `https://directus.katharostech.com/assets/${translation.feature_image.id}`
65+
: undefined,
66+
};
67+
});
68+
},
69+
// loader: glob({ pattern: ['*.md', '*.mdx'], base: 'src/data/post' }),
70+
5171
schema: z.object({
5272
publishDate: z.date().optional(),
5373
updateDate: z.date().optional(),
@@ -60,6 +80,7 @@ const postCollection = defineCollection({
6080
category: z.string().optional(),
6181
tags: z.array(z.string()).optional(),
6282
author: z.string().optional(),
83+
content: z.string(),
6384

6485
metadata: metadataDefinition(),
6586
}),

src/layouts/PageLayout.astro

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Layout from '~/layouts/Layout.astro';
33
import Header from '~/components/widgets/Header.astro';
44
import Footer from '~/components/widgets/Footer.astro';
5-
import Announcement from '~/components/widgets/Announcement.astro';
5+
// import Announcement from '~/components/widgets/Announcement.astro';
66
77
import { headerData, footerData } from '~/navigation';
88
@@ -17,7 +17,7 @@ const { metadata } = Astro.props;
1717

1818
<Layout metadata={metadata}>
1919
<slot name="announcement">
20-
<Announcement />
20+
<!-- <Announcement /> -->
2121
</slot>
2222
<slot name="header">
2323
<Header {...headerData} isSticky showRssFeed showToggleTheme />

src/lib/directus.ts

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { createDirectus, graphql } from '@directus/sdk';
2+
3+
type Author = {
4+
directus_users_id: {
5+
display_name: string;
6+
slug: string;
7+
};
8+
};
9+
10+
type ArticleTranslation = {
11+
title: string;
12+
body: string;
13+
feature_image: {
14+
id: string;
15+
};
16+
languages_id: {
17+
code: string,
18+
}
19+
};
20+
21+
type Tag = {
22+
id: string;
23+
tags_id: {
24+
slug: string;
25+
translations: {
26+
title: string;
27+
languages_code: {
28+
code: string;
29+
};
30+
}[];
31+
};
32+
};
33+
34+
type Article = {
35+
id: string;
36+
slug: string;
37+
published_date: string;
38+
authors: Author[];
39+
tags: Tag[];
40+
translations: ArticleTranslation[];
41+
};
42+
43+
type Schema = {
44+
articles: Article[];
45+
};
46+
47+
const directus = createDirectus<Schema>('https://directus.katharostech.com').with(graphql());
48+
49+
export default directus;
50+
51+
export async function getArticles() {
52+
return await directus.query<{ articles: Article[] }>(`
53+
query {
54+
articles {
55+
id
56+
slug
57+
published_date
58+
authors {
59+
directus_users_id {
60+
display_name
61+
slug
62+
}
63+
}
64+
tags {
65+
id
66+
tags_id {
67+
slug
68+
translations {
69+
title
70+
languages_code {
71+
code
72+
}
73+
}
74+
}
75+
}
76+
translations {
77+
title
78+
body
79+
feature_image {
80+
id
81+
}
82+
languages_id {
83+
code
84+
}
85+
}
86+
}
87+
}
88+
`);
89+
}

0 commit comments

Comments
 (0)