Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/TeaByte/NakhlahJS
Browse files Browse the repository at this point in the history
  • Loading branch information
m7medVision committed Jan 23, 2024
2 parents 43eeecc + f4dc129 commit 881cde5
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 46 deletions.
4 changes: 2 additions & 2 deletions components/Collapse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function Collapse(
<div class="collapse-title text-xl font-medium">
{title}
</div>
<div class="collapse-content flex flex-col">
<div class="collapse-content flex flex-col gap-2">
{courses.map((course) => (
<div key={course.slug}>
<a
Expand All @@ -19,7 +19,7 @@ export default function Collapse(
class="gray-200 hover:opacity-75 list-none"
style={{ order: course.order }}
>
<h3 class="text-gray-500 font-bold flex gap-1 items-centerrounded-btn mt-2 flex gap-1 items-center">
<h3 class="text-gray-500 font-bold flex gap-1 items-centerrounded-btn flex gap-1 items-center">
<ProgressCheck slug={course.slug} />
{course.title}
</h3>
Expand Down
2 changes: 1 addition & 1 deletion components/Courses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function Courses(
total={total}
/>
</div>
<SW />
{/* <SW /> Self-DOS :) */}
<section class="flex flex-col gap-2 mb-4 mt-6">
{courses.map((course, index) => {
// Group of courses
Expand Down
2 changes: 1 addition & 1 deletion components/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Drawer(
<a
title={course.title}
href={`/${course.slug}`}
class="py-2 gray-200 hover:opacity-75 list-none"
class="gray-200 hover:opacity-75 list-none bg-base-100 rounded-btn py-4"
style={{ order: course.order }}
>
<h3 class="text-gray-500 font-bold flex gap-1 items-center">
Expand Down
2 changes: 1 addition & 1 deletion components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function Footer() {
href="https://t.me/NakhlahChat"
target="_blank"
>
المجتمع
جروب التلغرام
</a>
</li>
</ul>
Expand Down
4 changes: 4 additions & 0 deletions courses/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ order: 2
الهدف من التعليمات البرمجية الخاصة بك، سواء بالنسبة للآخرين أو لنفسك في
المستقبل.
</mark>

<div class="quiz">
قم بكتابه تعليق واضغط على اختبار
</div>
2 changes: 1 addition & 1 deletion routes/[...slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function CoursePage(
return (
<>
<Head>
<title>نخلة - {course.title}</title>
<title>{course.title}</title>
<meta name="description" content={course.snippet} />
<meta name="keywords" content={`${course.title}, ${course.snippet}`} />
<meta property="og:title" content={course.title} />
Expand Down
10 changes: 9 additions & 1 deletion routes/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { FreshContext, Handlers, type PageProps } from "$fresh/server.ts";
import NavBar from "../components/Nav.tsx";
import Toast from "../islands/Toast.tsx";
import { populateCache } from "../utils/course-cache.ts";

import { populateCache } from "../utils/course-cache.ts";
populateCache();

export default async function Layout(req: Request, ctx: FreshContext) {
return (
// Don't delete data-theme="dracula", used for defult theme and styles
Expand All @@ -22,6 +23,13 @@ export default async function Layout(req: Request, ctx: FreshContext) {
href="https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;700&display=swap"
rel="stylesheet"
/>

<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-TDHJL7ZT23"
>
</script>

<link rel="manifest" href="/manifest.json" />
<script src="/theme-loader.js"></script>
<script type="module" src="/sw-rg.js"></script>
Expand Down
23 changes: 17 additions & 6 deletions routes/group/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import { PageProps } from "$fresh/server.ts";
import { Course, CourseGroup } from "../../utils/types.ts";
import { cache } from "../../utils/course-cache.ts";

import CourseCard from "../../components/CourseCard.tsx";
import Footer from "../../components/Footer.tsx";

import IconChevronDown from "https://deno.land/x/[email protected]/tsx/chevron-down.tsx";
import ProgressCheck from "@/islands/ProgressCheck.tsx";

interface Props {
courses: CourseGroup;
}
export const handler: Handlers<Props> = {
async GET(_req, ctx) {
GET(_req, ctx) {
let foundCourseGroup: CourseGroup | Course | undefined = undefined;
const toFind = decodeURIComponent(ctx.params.slug);
foundCourseGroup = cache.courses.find((c) => {
Expand All @@ -28,7 +29,7 @@ export const handler: Handlers<Props> = {
};

export default function CoursePage(props: PageProps<Props>) {
const {courses:foundCourseGroup} = props.data;
const { courses: foundCourseGroup } = props.data;
return (
<>
<Head>
Expand All @@ -44,9 +45,19 @@ export default function CoursePage(props: PageProps<Props>) {
</h2>
<IconChevronDown />
</div>
<div class="flex flex-col mt-2 pr-3">
{foundCourseGroup.courses.map((innerCourse) => (
<CourseCard key={innerCourse.slug} course={innerCourse} />
<div class="flex flex-col mt-2 pr-3 gap-3">
{foundCourseGroup.courses.map((course) => (
<a
title={course.title}
href={`/${course.slug}`}
class="gray-200 hover:opacity-75 list-none"
style={{ order: course.order }}
>
<h3 class="text-gray-500 font-bold flex gap-1 items-center rounded-btn">
<ProgressCheck slug={course.slug} />
{course.title}
</h3>
</a>
))}
</div>
</div>
Expand Down
7 changes: 3 additions & 4 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Head } from "$fresh/runtime.ts";
import { Handlers } from "$fresh/server.ts";
import { PageProps } from "$fresh/server.ts";

import { getCourses } from "../utils/course.ts";
import { Course, CourseGroup } from "../utils/types.ts";
import { cache } from "../utils/course-cache.ts";

Expand All @@ -16,19 +15,19 @@ interface Props {
}
export const handler: Handlers<Props> = {
async GET(_req, ctx) {
const courses = await getCourses(cache);
const courses = cache.courses;
const total = await getNumberOfCourses();
return ctx.render({
total,
courses: courses.courses,
courses: courses,
});
},
};

export default function BlogIndexPage(
props: PageProps<Props>,
) {
const { courses,total } = props.data;
const { courses, total } = props.data;
return (
<>
<Head>
Expand Down
1 change: 1 addition & 0 deletions static/google29ae9dd15993e53e.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: google29ae9dd15993e53e.html
55 changes: 30 additions & 25 deletions static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
{
"theme_color": "#8936FF",
"background_color": "#2EC6FE",
"icons": [
{
"purpose": "maskable",
"sizes": "512x512",
"src": "icon512_maskable.png",
"type": "image/png"
},
{
"purpose": "any",
"sizes": "512x512",
"src": "icon512_rounded.png",
"type": "image/png"
}
],
"orientation": "any",
"display": "standalone",
"dir": "auto",
"lang": "ar",
"short_name": "nakhlahjs",
"name": "",
"start_url": "/",
"form_factor": "narrow"
}
"theme_color": "#1f202a",
"background_color": "#282a36",
"icons": [
{
"purpose": "maskable",
"sizes": "512x512",
"src": "icon512_maskable.png",
"type": "image/png"
},
{
"purpose": "any",
"sizes": "512x512",
"src": "icon512_rounded.png",
"type": "image/png"
}
],
"orientation": "any",
"display": "standalone",
"dir": "auto",
"lang": "ar",
"short_name": "تطبيق نخلة",
"name": "تطبيق نخلة",
"start_url": "/",
"form_factor": "narrow",
"id": "nakhlahjs1.0",
"description": "اكتساب مهارات جافاسكربت بسهولة وفعالية",
"categories": [
"education"
]
}
2 changes: 1 addition & 1 deletion static/resizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ document.addEventListener("DOMContentLoaded", function () {
window.testPassedEffect = function () {
const duration = 15 * 200,
animationEnd = Date.now() + duration,
defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 999 };

function randomInRange(min, max) {
return Math.random() * (max - min) + min;
Expand Down
5 changes: 5 additions & 0 deletions static/theme-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ if (storedTheme) {
} else {
localStorage.setItem("selectedTheme", "dracula");
}

window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-TDHJL7ZT23');
6 changes: 3 additions & 3 deletions utils/course.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from "$std/path/mod.ts";
import { readJson } from "https://deno.land/[email protected]/fs/read_json.ts";
import { extract } from "https://deno.land/[email protected]/encoding/front_matter.ts";

import { cache as CourceCache } from "@/utils/course-cache.ts";
import { Course, CourseAttributes, CourseGroup } from "../utils/types.ts";

export let CoursesCount = 0;
Expand Down Expand Up @@ -105,7 +105,7 @@ export async function getCourses(
cache.courses = merged;

const endTime = performance.now();
// console.log(`Caching data took ${(endTime - startTime) / 1000} seconds`);
console.log(`Caching data took ${(endTime - startTime) / 1000} seconds`);
return cache;
}

Expand All @@ -114,7 +114,7 @@ export async function getFlatSlugs() {
// console.log("Using cache");
return FlatSlugsCache;
}
const { courses } = await getCourses();
const courses = CourceCache.courses;
const slugs = courses.map((c) => {
if ("courses" in c) {
c.courses.sort((a, b) => a.order - b.order);
Expand Down

0 comments on commit 881cde5

Please sign in to comment.