Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions apps/svelte.dev/src/routes/+layout.server.js

This file was deleted.

64 changes: 64 additions & 0 deletions apps/svelte.dev/src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { docs, index } from '$lib/server/content';
import { fetchBanner } from '@sveltejs/site-kit/components';
import type { NavigationLink } from '@sveltejs/site-kit';

const nav_links: NavigationLink[] = [
{
title: 'Docs',
slug: 'docs',
sections: Object.values(docs.topics)
.map((topic) => ({
title: topic.metadata.title,
path: '/' + topic.slug, // this will make the UI show a flyout menu for the docs nav entry
sections: topic.children.map((section) => ({
title: section.metadata.title,
sections: section.children.map((page) => ({
title: page.metadata.title,
path: '/' + page.slug
}))
}))
}))
.sort((a, b) => a.title.localeCompare(b.title)) // Svelte first
},
{
title: 'Tutorial',
slug: 'tutorial',
sections: index.tutorial.children.map((topic) => ({
title: topic.metadata.title,
sections: topic.children.map((section) => ({
title: section.metadata.title,
sections: section.children.map((page) => ({
title: page.metadata.title,
path: '/tutorial/' + page.slug.split('/').pop()
}))
}))
}))
},
{
title: 'Playground',
slug: 'playground'
},
{
title: 'Blog',
slug: 'blog'
}
];

const sections: Record<string, string> = {
docs: 'Docs',
playground: 'Playground',
blog: 'Blog',
tutorial: 'Tutorial',
search: 'Search'
};

export const load = async ({ url, fetch }) => {
const banner = await fetchBanner('svelte.dev', fetch);
const nav_title = sections[url.pathname.split('/')[1]!] ?? '';

return {
nav_title,
nav_links,
banner
};
};
61 changes: 0 additions & 61 deletions apps/svelte.dev/src/routes/nav.json/+server.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/site-kit/src/lib/components/LinksDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<Dropdown>
<a
href={link.pathname}
aria-current={$page.url.pathname.startsWith(`/${link.prefix}`) ? 'page' : undefined}
href="/{link.slug}"
aria-current={$page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : undefined}
>
{link.title}

Expand Down
4 changes: 2 additions & 2 deletions packages/site-kit/src/lib/nav/Menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
open_store.set(true);

const segment = get(page).url.pathname.split('/')[1];
current_menu_view.set(get(links_store).find((link) => link.prefix === segment));
current_menu_view.set(get(links_store).find((link) => link.slug === segment));

show_context_menu.set(!!get(current_menu_view)?.sections && !!get(current_menu_view));
}
Expand Down Expand Up @@ -188,7 +188,7 @@
<div class="contents" bind:clientHeight={universal_menu_inner_height}>
{#each links as link}
<div class="link-item" style:--button-width={link.sections ? '4rem' : '0'}>
<a href={link.pathname}>
<a href="/{link.slug}">
{link.title}
</a>

Expand Down
4 changes: 2 additions & 2 deletions packages/site-kit/src/lib/nav/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ Top navigation bar for the application. It provides a slot for the left side, th
<LinksDropdown {link} />
{:else}
<a
href={link.pathname}
aria-current={$page.url.pathname.startsWith(`/${link.prefix}`) ? 'page' : null}
href="/{link.slug}"
aria-current={$page.url.pathname.startsWith(`/${link.slug}`) ? 'page' : null}
>
{link.title}
</a>
Expand Down
3 changes: 1 addition & 2 deletions packages/site-kit/src/lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export interface NavigationLink {
title: string;
prefix: string;
pathname: string;
slug: string;
sections?: {
title: string;
path?: string;
Expand Down
Loading