This commit is contained in:
Jesse Winton
2024-08-27 09:43:37 -04:00
parent c9f7fc75f1
commit 562058cf0e
319 changed files with 16360 additions and 15622 deletions

View File

@@ -1,13 +1,15 @@
<script lang="ts">
import { page } from '$app/stores';
import Docs, { type DocsLayoutVariant } from '$lib/layouts/Docs.svelte';
import Sidebar from '../Sidebar.svelte';
import { page } from "$app/stores";
import Docs, { type DocsLayoutVariant } from "$lib/layouts/Docs.svelte";
import Sidebar from "../Sidebar.svelte";
$: variant =
$page.route.id === '/docs/tutorials' ? 'default' : ('two-side-navs' as DocsLayoutVariant);
$: variant =
$page.route.id === "/docs/tutorials"
? "default"
: ("two-side-navs" as DocsLayoutVariant);
</script>
<Docs {variant}>
<Sidebar />
<slot />
<Sidebar />
<slot />
</Docs>

View File

@@ -1,74 +1,76 @@
import { base } from '$app/paths';
import type { Tutorial } from '$markdoc/layouts/Tutorial.svelte';
import { base } from "$app/paths";
import type { Tutorial } from "$markdoc/layouts/Tutorial.svelte";
const framework_order = ['React', 'Vue', 'SvelteKit', 'Stripe', 'Refine'];
const framework_order = ["React", "Vue", "SvelteKit", "Stripe", "Refine"];
const category_order = [
'Web',
'Mobile and native',
'Server',
'Auth',
'Databases',
'Storage',
'Functions'
"Web",
"Mobile and native",
"Server",
"Auth",
"Databases",
"Storage",
"Functions",
];
export async function load() {
const tutorialsGlob = import.meta.glob('./**/step-1/+page.markdoc', {
eager: true
const tutorialsGlob = import.meta.glob("./**/step-1/+page.markdoc", {
eager: true,
});
const allTutorials = Object.entries(tutorialsGlob)
.map(([filepath, tutorialList]: [string, unknown]) => {
const { frontmatter } = tutorialList as {
frontmatter: Tutorial;
};
const slug = filepath
.replace("./", "")
.replace("/+page.markdoc", "")
.replace("/step-1", "");
const tutorialName = slug.slice(slug.lastIndexOf("/") + 1);
return {
title: frontmatter.title,
framework: frontmatter.framework,
draft: frontmatter.draft || false,
category: frontmatter.category,
href: `${base}/docs/tutorials/${tutorialName}`,
};
})
.filter((tutorial) => !tutorial.draft)
.sort((a, b) => {
// Sort by framework order
const frameworkIndexA = framework_order.indexOf(a.framework as string);
const frameworkIndexB = framework_order.indexOf(b.framework as string);
if (frameworkIndexA > frameworkIndexB) {
return 1;
}
if (frameworkIndexA < frameworkIndexB) {
return -1;
}
// Else, sort by title
return a.title.toLowerCase().localeCompare(b.title.toLowerCase());
});
const allTutorials = Object.entries(tutorialsGlob)
.map(([filepath, tutorialList]: [string, unknown]) => {
const { frontmatter } = tutorialList as {
frontmatter: Tutorial;
};
const slug = filepath
.replace('./', '')
.replace('/+page.markdoc', '')
.replace('/step-1', '');
const tutorialName = slug.slice(slug.lastIndexOf('/') + 1);
const tutorials = Object.entries(
allTutorials.reduce((acc: { [key: string]: any[] }, item) => {
// If the category does not exist in the accumulator, initialize it
if (!acc[item.category]) {
acc[item.category] = [];
}
return {
title: frontmatter.title,
framework: frontmatter.framework,
draft: frontmatter.draft || false,
category: frontmatter.category,
href: `${base}/docs/tutorials/${tutorialName}`
};
})
.filter((tutorial) => !tutorial.draft)
.sort((a, b) => {
// Sort by framework order
const frameworkIndexA = framework_order.indexOf(a.framework as string);
const frameworkIndexB = framework_order.indexOf(b.framework as string);
// Push the current item into the appropriate category
acc[item.category].push(item);
if (frameworkIndexA > frameworkIndexB) {
return 1;
}
if (frameworkIndexA < frameworkIndexB) {
return -1;
}
return acc;
}, {}),
).map(([title, tutorials]) => ({ title, tutorials }));
// Else, sort by title
return a.title.toLowerCase().localeCompare(b.title.toLowerCase());
});
const tutorials = Object.entries(
allTutorials.reduce((acc: { [key: string]: any[] }, item) => {
// If the category does not exist in the accumulator, initialize it
if (!acc[item.category]) {
acc[item.category] = [];
}
// Push the current item into the appropriate category
acc[item.category].push(item);
return acc;
}, {})
).map(([title, tutorials]) => ({ title, tutorials }));
tutorials.sort((a, b) => category_order.indexOf(a.title) - category_order.indexOf(b.title));
return {
tutorials
};
tutorials.sort(
(a, b) => category_order.indexOf(a.title) - category_order.indexOf(b.title),
);
return {
tutorials,
};
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/android/step-1');
redirect(303, "/docs/tutorials/android/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/apple/step-1');
redirect(303, "/docs/tutorials/apple/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit';
import { redirect } from "@sveltejs/kit";
export async function load() {
redirect(303, '/docs/tutorials/astro-ssr-auth/step-1');
redirect(303, "/docs/tutorials/astro-ssr-auth/step-1");
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/flutter/step-1');
redirect(303, "/docs/tutorials/flutter/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit';
import { redirect } from "@sveltejs/kit";
export function load() {
redirect(303, '/docs/tutorials/nextjs-ssr-auth/step-1');
redirect(303, "/docs/tutorials/nextjs-ssr-auth/step-1");
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit';
import { redirect } from "@sveltejs/kit";
export function load() {
redirect(303, '/docs/tutorials/nuxt-ssr-auth/step-1');
redirect(303, "/docs/tutorials/nuxt-ssr-auth/step-1");
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/nuxt/step-1');
redirect(303, "/docs/tutorials/nuxt/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/react-native/step-1');
redirect(303, "/docs/tutorials/react-native/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/react/step-1');
redirect(303, "/docs/tutorials/react/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/refine/step-1');
redirect(303, "/docs/tutorials/refine/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/subscriptions-with-stripe/step-1');
redirect(303, "/docs/tutorials/subscriptions-with-stripe/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/sveltekit-csr-auth/step-1');
redirect(303, "/docs/tutorials/sveltekit-csr-auth/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,5 +1,5 @@
import { redirect } from '@sveltejs/kit';
import { redirect } from "@sveltejs/kit";
export function load() {
redirect(303, '/docs/tutorials/sveltekit-ssr-auth/step-1');
redirect(303, "/docs/tutorials/sveltekit-ssr-auth/step-1");
}

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/sveltekit/step-1');
redirect(303, "/docs/tutorials/sveltekit/step-1");
};

View File

@@ -1,10 +1,10 @@
<script lang="ts">
import { globToTutorial } from '$lib/utils/tutorials.js';
import { setContext } from 'svelte';
import { globToTutorial } from "$lib/utils/tutorials.js";
import { setContext } from "svelte";
export let data;
const tutorials = globToTutorial(data);
setContext('tutorials', tutorials);
export let data;
const tutorials = globToTutorial(data);
setContext("tutorials", tutorials);
</script>
<slot />

View File

@@ -1,11 +1,11 @@
import type { LayoutLoad } from './$types';
import type { LayoutLoad } from "./$types";
export const load: LayoutLoad = ({ url }) => {
const tutorials = import.meta.glob('./**/*.markdoc', {
eager: true
});
return {
tutorials,
pathname: url.pathname
};
const tutorials = import.meta.glob("./**/*.markdoc", {
eager: true,
});
return {
tutorials,
pathname: url.pathname,
};
};

View File

@@ -1,6 +1,6 @@
import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types';
import { redirect } from "@sveltejs/kit";
import type { PageLoad } from "./$types";
export const load: PageLoad = async () => {
redirect(303, '/docs/tutorials/vue/step-1');
redirect(303, "/docs/tutorials/vue/step-1");
};