Skip to content

Commit 4dd5b31

Browse files
committed
additional lesson layout fixes
1 parent 0900f9e commit 4dd5b31

7 files changed

Lines changed: 30 additions & 8 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export const parseLessonModules = async ({ lessonModules, courses }: { lessonMod
8585
...mdsvx?.metadata,
8686
cover: mdsvx?.metadata?.cover ? decodeURI(mdsvx?.metadata?.cover) : '',
8787
type: ContentType.lesson,
88-
slug: lessonSlug,
8988
courseSlug: slug,
9089
html,
9190
weight: mdsvx?.metadata?.weight ? mdsvx?.metadata?.weight : 0,

‎apps/codingcatdev/src/lib/types/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface Content {
1111
published?: string;
1212
slug: string;
1313
start: Date;
14+
stackblitz?: string;
1415
type: ContentType;
1516
title?: string;
1617
updated: Date;

‎apps/codingcatdev/src/routes/(content-single)/(non-course)/+layout.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { listContent, parseModules } from '$lib/server/content';
22

33
export const load = (async () => {
44

5-
const courseModules = import.meta.glob(['../../../content/course/*.md']);
5+
const courseModules = import.meta.glob(['../../../content/course/*/*.md']);
66
const tutorialModules = import.meta.glob(['../../../content/tutorial/*.md']);
77
const podcastModules = import.meta.glob(['../../../content/podcast/*.md']);
88
const postModules = import.meta.glob(['../../../content/post/*.md']);

‎apps/codingcatdev/src/routes/(content-single)/(non-course)/+layout.svelte‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { AppShell, TableOfContents } from '@codingcatdev/blackcatui';
33
import RecentPostsList from './RecentPostsList.svelte';
44
import { ContentType } from '$lib/types';
5+
import { storeCurrentUrl } from '$lib/stores/stores';
56
67
export let data;
78
</script>
@@ -19,7 +20,9 @@
1920
<div class="w-[19.5rem] xl:w-96" />
2021
<div class="fixed top-[5.125rem] bottom-24 w-[19.5rem] xl:w-96 py-10 overflow-y-auto">
2122
<div class="flex flex-col gap-2 px-8 md:gap-8">
22-
<TableOfContents target=".markdown" />
23+
{#key $storeCurrentUrl}
24+
<TableOfContents target=".markdown" />
25+
{/key}
2326
<RecentPostsList contentType={ContentType.course} list={data.course} />
2427
<RecentPostsList contentType={ContentType.tutorial} list={data.tutorial} />
2528
<RecentPostsList contentType={ContentType.podcast} list={data.podcast} />

‎apps/codingcatdev/src/routes/(content-single)/course/[slug]/lesson/[lessonSlug]/+page.server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const load = (async ({ params, parent, url }) => {
1616
});
1717
}
1818

19-
if (!user?.uid) {
19+
if (content.locked && !user?.uid) {
2020
throw redirect(307, `/login?redirectTo=${url.pathname}`);
2121
}
2222

‎apps/codingcatdev/src/routes/(content-single)/course/[slug]/lesson/[lessonSlug]/Lesson.svelte‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import 'prism-themes/themes/prism-shades-of-purple.min.css';
33
import Video from '$lib/components/content/Video.svelte';
44
import type { Lesson, Course } from '$lib/types';
5+
import { browser } from '$app/environment';
6+
import CopyCodeInjector from '$lib/components/content/CopyCodeInjector.svelte';
57
export let data: {
68
course: Course;
79
content: Lesson;
@@ -10,7 +12,7 @@
1012

1113
{#if data?.content}
1214
<div class="flex justify-center">
13-
<section class="flex flex-col xl:flex-row gap-8 justify-center p-1 xl:p-8 w-full">
15+
<section class="flex flex-col xl:flex-row gap-8 justify-center p-2 xl:p-8 w-full">
1416
<div class="flex flex-col gap-2 md:gap-8 max-w-7xl w-full">
1517
<ol class="bcu-breadcrumb">
1618
<li class="bcu-crumb"><a href="/courses">Courses</a></li>
@@ -31,8 +33,24 @@
3133
]}
3234
/>
3335
{/if}
34-
<section class="flex-grow w-full markdown flex flex-col gap-2 md:gap-8">
35-
{@html data.content.html}
36+
{#if data?.content?.title}
37+
<h1>{data?.content?.title}</h1>
38+
{/if}
39+
{#if browser && data?.content?.stackblitz}
40+
<section class=" aspect-video">
41+
<iframe
42+
title={`repo for ${data?.content?.title}`}
43+
src={data.content.stackblitz}
44+
frameborder="0"
45+
height="100%"
46+
width="100%"
47+
/>
48+
</section>
49+
{/if}
50+
<section class="flex flex-col flex-grow w-full gap-2 markdown md:gap-8">
51+
<CopyCodeInjector>
52+
{@html data.content.html}
53+
</CopyCodeInjector>
3654
</section>
3755
</div>
3856
</section>

‎apps/codingcatdev/src/routes/+layout.svelte‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
2525
// Scroll heading into view
2626
function scrollHeadingIntoView(): void {
27+
console.log(window.location);
2728
if (!window.location.hash) return;
2829
const elemTarget: HTMLElement | null = document.querySelector(window.location.hash);
2930
if (elemTarget) elemTarget.scrollIntoView({ behavior: 'smooth' });
@@ -41,7 +42,7 @@
4142
storeCurrentUrl.set($page.url.pathname);
4243
// Scroll to top
4344
const isNewPage: boolean =
44-
params.from && params.to && params.from.route.id !== params.to.route.id;
45+
params.from && params.to && params.from.url.pathname !== params.to.url.pathname;
4546
const elemPage = document.querySelector('#bcu-app-shell-page');
4647
if (isNewPage && elemPage !== null) {
4748
elemPage.scrollTop = 0;

0 commit comments

Comments
 (0)