Skip to content

Commit be13a94

Browse files
committed
initial md move and rename
1 parent 65fdcc6 commit be13a94

11 files changed

Lines changed: 65 additions & 31 deletions

‎apps/codingcatdev/src/lib/server/content.ts‎

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { dev } from '$app/environment';
2+
13
import { PUBLIC_FB_PROJECT_ID } from '$env/static/public';
24
import { PRIVATE_FB_PRIVATE_KEY, PRIVATE_FB_CLIENT_EMAIL } from '$env/static/private';
35

@@ -17,21 +19,23 @@ import { ContentType } from '$lib/types';
1719

1820
const LIMIT = 20;
1921

20-
if (!PUBLIC_FB_PROJECT_ID || !PRIVATE_FB_CLIENT_EMAIL || !PRIVATE_FB_PRIVATE_KEY) {
21-
throw new Error('Missing Firebase Admin Environment Varialbles');
22-
}
23-
let app = getApps().at(0);
24-
if (!app) {
25-
app = initializeApp({
26-
credential: cert({
27-
projectId: PUBLIC_FB_PROJECT_ID,
28-
clientEmail: PRIVATE_FB_CLIENT_EMAIL,
29-
privateKey: PRIVATE_FB_PRIVATE_KEY
30-
})
31-
});
32-
}
22+
const myFirstore = () => {
23+
if (!PUBLIC_FB_PROJECT_ID || !PRIVATE_FB_CLIENT_EMAIL || !PRIVATE_FB_PRIVATE_KEY) {
24+
throw new Error('Missing Firebase Admin Environment Varialbles');
25+
}
26+
let app = getApps().at(0);
27+
if (!app) {
28+
app = initializeApp({
29+
credential: cert({
30+
projectId: PUBLIC_FB_PROJECT_ID,
31+
clientEmail: PRIVATE_FB_CLIENT_EMAIL,
32+
privateKey: PRIVATE_FB_PRIVATE_KEY
33+
})
34+
});
35+
}
3336

34-
const firestore = getFirestore(app);
37+
return getFirestore(app);
38+
};
3539

3640
/**
3741
* List all content from specified content type
@@ -51,11 +55,34 @@ export const listContent = async ({
5155
};
5256
limit?: number;
5357
}) => {
58+
// In Dev Mode read directly from content directory
59+
if (dev) {
60+
let contentFiles;
61+
switch (contentType) {
62+
case ContentType.post:
63+
contentFiles = import.meta.glob('../../../../../content/post/*.md');
64+
break;
65+
case ContentType.tutorial:
66+
contentFiles = import.meta.glob('../../../../../content/podcast/*.md');
67+
break;
68+
}
69+
if (!contentFiles) return [];
70+
71+
for (const path in contentFiles) {
72+
console.log(path);
73+
contentFiles[path]().then((mod) => {
74+
console.log(path, mod);
75+
});
76+
}
77+
78+
return contentFiles;
79+
}
80+
5481
const theLimit = limit || LIMIT;
5582
console.log(`List for type: ${contentType}, limit of ${theLimit}`);
5683

5784
// All query need a start date
58-
let query = firestore
85+
let query = myFirstore()
5986
.collection(contentType)
6087
.where('start', '<=', Timestamp.fromDate(new Date()))
6188
.orderBy('start', 'desc');
@@ -107,7 +134,7 @@ export const listContent = async ({
107134
export const getContentBySlug = async (contentType: ContentType, slug: string) => {
108135
console.debug(`Searching for content type: ${contentType} slug: ${slug}`);
109136

110-
let query = firestore
137+
let query = myFirstore()
111138
.collection(contentType)
112139
.where('slug', '==', slug)
113140
.where('start', '<=', Timestamp.fromDate(new Date()))
@@ -116,7 +143,7 @@ export const getContentBySlug = async (contentType: ContentType, slug: string) =
116143
.limit(1);
117144

118145
if (contentType === ContentType.podcast) {
119-
query = firestore
146+
query = myFirstore()
120147
.collection(contentType)
121148
.where('slug', '==', slug)
122149
.where('start', '<=', Timestamp.fromDate(new Date()))
@@ -162,7 +189,7 @@ export const getContentBySlug = async (contentType: ContentType, slug: string) =
162189
export const getLessonFromCourseSlug = async (courseSlug: string, slug: string) => {
163190
console.debug(`Searching for course: ${courseSlug} lesson slug: ${slug}`);
164191

165-
const courseQuery = firestore
192+
const courseQuery = myFirstore()
166193
.collection(ContentType.course)
167194
.where('slug', '==', courseSlug)
168195
.where('start', '<=', Timestamp.fromDate(new Date()))
@@ -178,7 +205,7 @@ export const getLessonFromCourseSlug = async (courseSlug: string, slug: string)
178205
return null;
179206
}
180207

181-
const query = firestore
208+
const query = myFirstore()
182209
.collection(ContentType.course)
183210
.doc(course.id)
184211
.collection(ContentType.lesson)
@@ -195,7 +222,7 @@ export const getLessonFromCourseSlug = async (courseSlug: string, slug: string)
195222
return null;
196223
}
197224

198-
const lessonQuery = firestore
225+
const lessonQuery = myFirstore()
199226
.collection(ContentType.course)
200227
.doc(course.id)
201228
.collection(ContentType.lesson)

‎apps/codingcatdev/svelte.config.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import preprocess from 'svelte-preprocess';
22
import adapter from '@sveltejs/adapter-auto';
33

4+
console.log('environment: ', process.env.NODE_ENV);
5+
46
/** @type {import('@sveltejs/kit').Config} */
57
const config = {
68
kit: {

‎content/course/Intro to Svelte/lesson/Intro to Svelte.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ published: published
66
section: Intro
77
slug: intro-to-svelte
88
start: June 1, 2022
9-
section: Intro
109
title: Intro to Svelte
1110
weight: 1
1211
youtube: https://youtu.be/76QeCZVTS4Y

‎content/package.json‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"name": "codingcatdev-content",
33
"version": "2.0.0",
4-
"description": "Content for CodingCat.dev"
4+
"description": "Content for CodingCat.dev",
5+
"dependencies": {
6+
"gray-matter": "^4.0.3"
7+
}
58
}

‎content/podcast/0-9-Clerk dev Auth with Appwrite.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ preview: https://codingcat.dev/api/preview?secret=7tjQhb1qQlS3FtyV3b0I&selection
1212
title: Clerk.dev
1313
slug: live-0-9-clerk-with-appwrite
1414
youtube: https://youtu.be/4P_ax04-T4c
15-
15+
---
1616
## Questions
1717

18-
1. Can you tell us more about yourself?
19-
2.
18+
1. Can you tell us more about yourself?

‎content/podcast/1-12-Agility CMS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ spotify: https://open.spotify.com/episode/7nlWjCmTBh3ph9gE1enrIv?si=Ia4K1KnYQkKm
1515
start: March 17, 2021
1616
title: Agility CMS
1717
youtube: https://www.youtube.com/watch?v=oOr-11AO9ms
18-
18+
---
1919
## Joel Varty
2020

2121
### Links

‎content/podcast/2-2-Using No-Code with Builder - Part 2.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spotify: https://open.spotify.com/episode/4Mf5Xbb4akKngafgwcNbe0?si=xr5ca4_sTLWb
1717
start: January 12, 2022
1818
title: Using No-Code with Builder - Part 2
1919
youtube: https://www.youtube.com/watch?v=xEJa5W1_y_A
20-
20+
---
2121
## Questions
2222

2323
1. How do blocks work in builder?

‎content/podcast/2-3-Supabase an Open Source Alternative.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spotify: https://open.spotify.com/episode/25WaQEHbRXAfo2ueiVf3xP?si=BhNeQHVnQQqQ
1717
start: January 19, 2022
1818
title: Supabase an Open Source Alternative
1919
youtube: https://www.youtube.com/watch?v=OCxifrifiU0
20-
20+
---
2121
## Questions
2222

2323
1. What was the inspiration behind creating Supabase?

‎content/podcast/2-44-Storyblok and achieving better Accessibility from Developer Experience.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spotify: https://open.spotify.com/episode/7HghjPmPWz34g48L6quVkX?si=RisJUtzYTl-z
2121
start: October 19, 2022 12:00 PM
2222
title: Storyblok and achieving better Accessibility from Developer Experience
2323
youtube: https://youtu.be/QBCUuaD2d7g
24-
24+
---
2525
## Questions
2626

2727
1. Can you tell us more about yourself?

‎content/post/Updated Changing the Channel for YouTube Engagemen 6204b920280c410ba9bab762ac704089.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ preview: https://codingcat.dev/api/preview?secret=7tjQhb1qQlS3FtyV3b0I&selection
88
published: published
99
slug: changing-the-channel-for-youtube-engagement
1010
start: March 20, 2022
11-
title: Updated: Changing the Channel for YouTube Engagement was a bad idea
11+
title: -Updated- Changing the Channel for YouTube Engagement was a bad idea
1212
---
13+
1314
## UPDATE: Moving channel was a bad idea
1415

1516
I thought it was such a great move moving channels as it increased our CTR for educational videos. In reality what happened was it confused our user base. What I found out the hard way was that we needed to keep all of our content in one place and actually update [Purrfect.dev](http://Purrfect.dev) to become [CodingCat.dev Podcast](https://codingcat.dev/podcasts) as well. Now our branding is all surrounding the CodingCat brand going forward, on a single channel.

0 commit comments

Comments
 (0)