Skip to content

Commit fbb7a3e

Browse files
committed
allow drafts
1 parent 3870abc commit fbb7a3e

11 files changed

Lines changed: 74 additions & 92 deletions

File tree

apps/codingcatdev/src/content/course/next-js/index.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/codingcatdev/src/content/course/next-js/lesson/next-js-introduction.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

apps/codingcatdev/src/content/course/next-js/lesson/nextjs-basic-features-data-fetching.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/codingcatdev/src/content/course/next-js/lesson/nextjs-basic-features-pages.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/codingcatdev/src/content/course/next-js/lesson/nextjs-firebase.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

apps/codingcatdev/src/content/course/next-js/lesson/nextjs-getting-started.md

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
cloudinary_convert: false
3+
cover:
4+
excerpt: 'Learn how to use Svelte Kit and Firebase to build high-performance, scalable web applications.'
5+
published: draft
6+
slug: sveltekit-firebase
7+
start: April 17, 2023
8+
title: 'Learn Svelte Kit and Firebase: The Complete Guide'
9+
youtube:
10+
---
11+
12+
Svelte Kit is a modern JavaScript framework that is quickly gaining popularity among developers. It is known for its performance, simplicity, and ease of use. Firebase is a cloud-based platform that provides a variety of services for web and mobile development, including authentication, database, storage, and hosting.
13+
14+
In this course, you will learn how to use Svelte Kit and Firebase to build high-performance, scalable web applications. You will start by learning the basics of Svelte Kit, including how to create components, use state, handle events, and file based routing plus much more. You will then learn how to use Firebase to add authentication, and database to your application.
15+
16+
By the end of this course, you will be able to use Svelte Kit and Firebase to build any type of web application you can imagine.
17+
18+
This course is perfect for developers who want to learn how to use Svelte Kit and Firebase to build high-performance, scalable web applications. No prior experience with Svelte Kit or Firebase is required.
19+
20+
I hope you enjoy the course!
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
cloudinary_convert: false
3+
cover:
4+
excerpt:
5+
published: draft
6+
slug: intro
7+
start: April 17, 2023
8+
section: Intro
9+
title: Introduction to Svelte Kit and Firebase
10+
weight: 1
11+
youtube: https://youtu.be/Z_DAxhYbjyM
12+
---

apps/codingcatdev/src/lib/components/content/CloudinaryImage.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
1212
let bindImage: HTMLImageElement | null = null;
1313
onMount(() => {
14+
const match = src.match(/upload\/(?:v\d+\/)?(.+?)\.[^\.]+$/)?.at(1);
15+
const removeFront = src.replace('https://media.codingcat.dev/image/upload/', '');
1416
const newImage = new CloudinaryImage(
15-
src.match(/upload\/(?:v\d+\/)?(.+?)\.[^\.]+$/)?.at(1),
17+
match || removeFront,
1618
{ cloudName: 'none' },
1719
{ secureDistribution: 'media.codingcat.dev', privateCdn: true, secure: true }
1820
)

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

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
import { ContentType, ContentPublished, type Lesson } from '$lib/types';
22
import type { Content, Course } from '$lib/types';
3+
import { env } from '$env/dynamic/private';
34

45
const LIMIT = 20;
56

7+
// Force PREVIEW off by setting false in .env
8+
const preview = env.PREVIEW === "false" ? false : import.meta.env.DEV;
9+
610
export const parseModules = async (modules: Record<string, () => Promise<unknown>>) => {
711
const contentList: Content[] = [];
812
for (const path in modules) {
913
await modules[path]().then((mod) => {
1014
const splitPath = path.split('/');
11-
const type = splitPath.at(-2);
15+
const courseType = splitPath.at(-3);
16+
const normalType = splitPath.at(-2);
1217
const slug = splitPath.at(-1);
18+
const type = courseType === 'content' ? normalType : courseType;
1319

14-
console.log(`Precompiling: ${type}/${slug}`);
20+
if (courseType === 'content') {
21+
console.log(`Precompiling: ${type}/${slug}`);
22+
} else {
23+
console.log(`Precompiling: ${type}/${normalType}`);
24+
}
1525

1626
if (!type || !slug) {
1727
console.error('Missing name or type');
@@ -44,8 +54,6 @@ export const parseModules = async (modules: Record<string, () => Promise<unknown
4454
return contentList;
4555
}
4656

47-
console.log('Add Lessons to courses');
48-
4957
export const parseLessonModules = async ({ lessonModules, courses }: { lessonModules: Record<string, () => Promise<unknown>>, courses: Course[] }) => {
5058
for (const path in lessonModules) {
5159
await lessonModules[path]().then((mod) => {
@@ -54,7 +62,7 @@ export const parseLessonModules = async ({ lessonModules, courses }: { lessonMod
5462
const slug = splitPath.at(-3);
5563
const lessonSlug = splitPath?.at(-1)?.replace(/\.[^/.]+$/, '');
5664

57-
console.log(`Precompiling Lesson: ${type}/${slug}`);
65+
console.log(`Precompiling Lesson: ${type}/${slug}/lesson/${lessonSlug}`);
5866

5967
if (!type || !slug || !lessonSlug) {
6068
console.error('Lesson Param missing');
@@ -117,7 +125,7 @@ export const listContent = async ({
117125
console.log(`List limit of ${theLimit}`);
118126

119127
const fullContent = contentItems
120-
.filter(contentFilter)
128+
.filter(preview ? () => true : contentFilter)
121129
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf());
122130

123131
const content = fullContent.slice(0 + theAfter, theLimit + theAfter);
@@ -140,10 +148,14 @@ export const getContentBySlug = async ({
140148

141149
const doc = contentItems
142150
.filter(
143-
(c) =>
144-
c.slug == slug &&
145-
new Date(c.start) <= new Date() &&
146-
c.published === ContentPublished.published
151+
preview ?
152+
(c) =>
153+
c.slug == slug
154+
:
155+
(c) =>
156+
c.slug == slug &&
157+
new Date(c.start) <= new Date() &&
158+
c.published === ContentPublished.published
147159
)
148160
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf())
149161
.slice(0, 1)
@@ -152,7 +164,10 @@ export const getContentBySlug = async ({
152164
...c,
153165
lesson: c?.lesson
154166
?.filter(
155-
(l) => new Date(l.start) <= new Date() && l.published === ContentPublished.published
167+
preview ?
168+
() => true
169+
:
170+
(l) => new Date(l.start) <= new Date() && l.published === ContentPublished.published
156171
)
157172
.sort((a, b) => b.weight || 99 - (a.weight || 1))
158173
};
@@ -186,10 +201,14 @@ export const getLessonFromCourseSlug = async ({ courseSlug, slug, courseItems }:
186201
// TODO: ADD Pro check?
187202
const doc = course
188203
?.lesson?.filter(
189-
(l) =>
190-
l.slug == slug &&
191-
new Date(l.start) <= new Date() &&
192-
l.published === ContentPublished.published
204+
preview ?
205+
(l) =>
206+
l.slug == slug
207+
:
208+
(l) =>
209+
l.slug == slug &&
210+
new Date(l.start) <= new Date() &&
211+
l.published === ContentPublished.published
193212
)
194213
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf())
195214
.slice(0, 1)

0 commit comments

Comments
 (0)