Skip to content

Commit

Permalink
sitemap, robots
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaByte committed Jan 6, 2024
1 parent 59df0e2 commit b454f53
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 9 deletions.
1 change: 1 addition & 0 deletions components/EditButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default function EditButton({ slug }: { slug: string }) {
target="_blank"
href={`https://github.com/TeaByte/NakhlahJS/edit/main/courses/${slug}.md`}
class="pl-3 flex items-center gap-1 hover:opacity-75"
title="تعديل الملف"
>
<svg
xmlns="http://www.w3.org/2000/svg"
Expand Down
8 changes: 6 additions & 2 deletions components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ export default function NavBar() {
<div class="flex items-center flex-1">
<div class="flex items-center gap-1">
<img
title="NakhlahJS Logo"
title="نخله جي اس"
alt="Website logo"
src="/logo.webp"
class="h-8 w-8"
/>
<a href="/" class="text-2xl ml-1 font-bold hover:animate-pulse">
<a
href="/"
title="نخله جي اس"
class="text-2xl ml-1 font-bold hover:animate-pulse"
>
NakhlahJS
</a>
</div>
Expand Down
2 changes: 0 additions & 2 deletions courses/strings/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ console.log(sampleStr);
Hello
World
```

<!-- quiz <a href=\"http://www.example.com\" target=\"_blank\">Link</a> -->
31 changes: 30 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,33 @@ import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import config from "./fresh.config.ts";

await start(manifest, config);
import { freshSEOPlugin } from "https://deno.land/x/fresh_seo/mod.ts";
import { walk } from "https://deno.land/std/fs/mod.ts";

async function getAllPaths(directory: string): Promise<string[]> {
const paths: string[] = [];
for await (const entry of walk(directory, { includeDirs: false })) {
if (entry.isFile && entry.name.endsWith(".md")) {
const relativePath = entry.path.replace(/^courses[\\/]/, "").replace(
/\.md$/,
"",
);
if (!relativePath.endsWith(".json")) {
paths.push(btoa(relativePath));
}
}
}
return paths;
}

const allPaths = await getAllPaths("courses");
const coursesPath = allPaths.slice(1);
console.log(coursesPath);

await start(manifest, {
plugins: [
freshSEOPlugin(manifest, {
include: [...coursesPath],
}),
],
});
2 changes: 1 addition & 1 deletion routes/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function CoursePage(props: PageProps<Course>) {
<Head>
<title>Nakhlahjs - {course.title}</title>
<meta name="description" content={course.snippet} />
<meta name="keywords" content={course.title} />
<meta name="keywords" content={`${course.title}, ${course.snippet}`} />
<meta property="og:title" content={course.title} />
<meta property="og:description" content={course.snippet} />

Expand Down
4 changes: 3 additions & 1 deletion routes/_404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export default function Error404() {
<p class="my-4">
الصفحة التي تبحث عنها غير موجودة.
</p>
<a href="/" class="underline">العودى الى الصفحة الرئيسية</a>
<a title="العودى الى الصفحة الرئيسية" href="/" class="underline">
العودى الى الصفحة الرئيسية
</a>
</div>
</div>
</>
Expand Down
6 changes: 4 additions & 2 deletions routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ export default function BlogIndexPage(
return (
<>
<Head>
<title>الصفحه غير موجوده</title>
<meta
name="description"
content="وجهتك الأمثل لاكتساب مهارات جافاسكربت بسهولة وفعالية. رحلة تعليمية شيقة تمتد من الأساسيات إلى المستويات المتقدمة"
/>
<meta name="keywords" content="JavaScript" />
<meta
name="keywords"
content="Nakhlahjs, Nakhlah, تعلم جافاسكربت, جافاسكربت, تعليم جافاسكربت, كورس جافاسربت, كورس جافاسكربت مجاني, كورس جافاسكربت"
/>
<meta property="og:title" content="Nakhlahjs" />
<meta
property="og:description"
Expand Down
17 changes: 17 additions & 0 deletions static/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
User-agent: All
Allow: /*

User-agent: Googlebot
Allow: /*

User-agent: Googlebot-Video
Allow: /*

User-agent: Googlebot-Image
Allow: /*

User-agent: Mediapartners-Google
Allow: /*

User-agent: Googlebot-Mobile
Allow: /*

0 comments on commit b454f53

Please sign in to comment.