Skip to content

Commit f4e57ac

Browse files
authored
Merge pull request CodingCatDev#427 from CodingCatDev/v2-draft-capabilities
V2 draft capabilities
2 parents 7ebc4b0 + aab0d0c commit f4e57ac

12 files changed

Lines changed: 80 additions & 95 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: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
import { ContentType, ContentPublished } from '$lib/types';
1+
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+
// Will show for vercel previews unless forced to false
9+
const preview = env.PREVIEW === "false" ? false : env.VERCEL_ENV === "preview" || import.meta.env.DEV;
10+
611
export const parseModules = async (modules: Record<string, () => Promise<unknown>>) => {
712
const contentList: Content[] = [];
813
for (const path in modules) {
914
await modules[path]().then((mod) => {
1015
const splitPath = path.split('/');
11-
const type = splitPath.at(-2);
16+
const courseType = splitPath.at(-3);
17+
const normalType = splitPath.at(-2);
1218
const slug = splitPath.at(-1);
19+
const type = courseType === 'content' ? normalType : courseType;
1320

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

1627
if (!type || !slug) {
1728
console.error('Missing name or type');
@@ -44,8 +55,6 @@ export const parseModules = async (modules: Record<string, () => Promise<unknown
4455
return contentList;
4556
}
4657

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

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

5968
if (!type || !slug || !lessonSlug) {
6069
console.error('Lesson Param missing');
@@ -65,7 +74,7 @@ export const parseLessonModules = async ({ lessonModules, courses }: { lessonMod
6574
default: {
6675
render: () => { html: string };
6776
};
68-
metadata: Content;
77+
metadata: Lesson;
6978
};
7079
const { html } = mdsvx.default.render();
7180
/**
@@ -81,7 +90,8 @@ export const parseLessonModules = async ({ lessonModules, courses }: { lessonMod
8190
html,
8291
weight: mdsvx?.metadata?.weight ? mdsvx?.metadata?.weight : 0,
8392
published: mdsvx?.metadata?.published ? mdsvx?.metadata?.published : 'draft',
84-
start: mdsvx?.metadata?.start ? new Date(mdsvx?.metadata?.start) : new Date('Jan 01, 1900')
93+
start: mdsvx?.metadata?.start ? new Date(mdsvx?.metadata?.start) : new Date('Jan 01, 1900'),
94+
locked: mdsvx?.metadata?.locked || false,
8595
};
8696

8797
courses
@@ -116,7 +126,7 @@ export const listContent = async ({
116126
console.log(`List limit of ${theLimit}`);
117127

118128
const fullContent = contentItems
119-
.filter(contentFilter)
129+
.filter(preview ? () => true : contentFilter)
120130
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf());
121131

122132
const content = fullContent.slice(0 + theAfter, theLimit + theAfter);
@@ -139,10 +149,14 @@ export const getContentBySlug = async ({
139149

140150
const doc = contentItems
141151
.filter(
142-
(c) =>
143-
c.slug == slug &&
144-
new Date(c.start) <= new Date() &&
145-
c.published === ContentPublished.published
152+
preview ?
153+
(c) =>
154+
c.slug == slug
155+
:
156+
(c) =>
157+
c.slug == slug &&
158+
new Date(c.start) <= new Date() &&
159+
c.published === ContentPublished.published
146160
)
147161
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf())
148162
.slice(0, 1)
@@ -151,7 +165,10 @@ export const getContentBySlug = async ({
151165
...c,
152166
lesson: c?.lesson
153167
?.filter(
154-
(l) => new Date(l.start) <= new Date() && l.published === ContentPublished.published
168+
preview ?
169+
() => true
170+
:
171+
(l) => new Date(l.start) <= new Date() && l.published === ContentPublished.published
155172
)
156173
.sort((a, b) => b.weight || 99 - (a.weight || 1))
157174
};
@@ -185,10 +202,14 @@ export const getLessonFromCourseSlug = async ({ courseSlug, slug, courseItems }:
185202
// TODO: ADD Pro check?
186203
const doc = course
187204
?.lesson?.filter(
188-
(l) =>
189-
l.slug == slug &&
190-
new Date(l.start) <= new Date() &&
191-
l.published === ContentPublished.published
205+
preview ?
206+
(l) =>
207+
l.slug == slug
208+
:
209+
(l) =>
210+
l.slug == slug &&
211+
new Date(l.start) <= new Date() &&
212+
l.published === ContentPublished.published
192213
)
193214
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf())
194215
.slice(0, 1)

0 commit comments

Comments
 (0)