Skip to content

Commit

Permalink
fix route, add codeblock component
Browse files Browse the repository at this point in the history
  • Loading branch information
stromseng committed Oct 4, 2023
1 parent d78fd14 commit 6b98972
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/lib/components/CodeTags.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script lang="ts">
export let tags: string[];
let finalString: string = '';
for (let i = 0; i < tags.length; i++) {
if (i < tags.length - 1) {
finalString += tags[i] + ', ';
} else {
finalString += tags[i];
}
}
</script>

<code class="code whitespace-normal"> {finalString}</code>
3 changes: 2 additions & 1 deletion src/lib/components/ProjectCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import imageUrlBuilder from '@sanity/image-url';
import type { Image, Project } from '$lib/types/sanity';
import CodeTags from './CodeTags.svelte';
// Get a pre-configured url-builder from your sanity client
const builder = imageUrlBuilder(client);
Expand Down Expand Up @@ -35,7 +36,7 @@
<div class="p-4">
<div class="mb-2">
<h3 class="h3" data-toc-ignore>{project.title}</h3>
<code class="code whitespace-normal">{project.tags}</code>
<CodeTags tags={project.tags} />
</div>
<article>
<p>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/ProjectHeader.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script lang="ts">
import type { Project } from '$lib/types/sanity';
import CodeTags from './CodeTags.svelte';
export let project: Project;
</script>

<div class="">
<h1 class="h1">{project.title}</h1>

<div class="mb-1"><code class="code">{project.tags} </code></div>
<div class="mb-1"><CodeTags tags={project.tags} /></div>
{#if project.githubLink}
<a href={project.githubLink}>
<div class="chip variant-soft-primary p-1">
Expand Down
9 changes: 3 additions & 6 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
// The ordering of these imports is critical to your app working properly
import '@skeletonlabs/skeleton/themes/theme-rocket.css';
// If you have source.organizeImports set to true in VSCode, then it will auto change this ordering
Expand All @@ -26,8 +25,6 @@
import NavBar from '$lib/components/navbar/NavBar.svelte';
import NavBarItem from '$lib/components/navbar/NavBarItem.svelte';
// Drawer Handler
function drawerOpen(): void {
const s: DrawerSettings = {
Expand Down Expand Up @@ -140,16 +137,16 @@
</svelte:fragment>
<!-- Page Route Content -->
<slot />

<!-- (footer) -->
<svelte:fragment slot="pageFooter">
<AppBar gridColumns="grid-cols-1" slotDefault="place-self-center" class="w-full mt-10">
<div>
This website was built using <a class="anchor" href="https://svelte.dev">Svelte</a>,
This website was built using <a class="anchor" href="https://www.sanity.io/">Svelte</a>,
<a class="anchor" href="https://svelte.dev">Sanity</a>,
<a class="anchor" href="https://vitejs.dev">Vite</a>,
<a class="anchor" href="https://www.skeleton.dev">Skeleton-UI</a>
and <a class="anchor" href="https://fontawesome.com">Fontawesome</a>
</div>
</AppBar>
</svelte:fragment>
<!-- (footer) -->
</AppShell>
19 changes: 19 additions & 0 deletions src/routes/projects/+page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @type {import('./$types').PageLoad} */

import client from '$lib/sanityClient';

export async function load({ params }) {
const data = await client.fetch(`*[_type == "project"]`);
if (data) {
console.log('Projects found');
console.log(data);
return {
projects: data
};
}
console.log('No projects found');
return {
status: 500,
body: new Error('Internal Server Error in Sanity load function. No projects found')
};
}
9 changes: 8 additions & 1 deletion src/routes/projects/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
import { Avatar } from '@skeletonlabs/skeleton';
import ProjectCard from '$lib/components/ProjectCard.svelte';
import ProjectCardsGrid from '$lib/components/ProjectCardsGrid.svelte';
import type { Project } from '$lib/types/sanity';
let ProfilePic = '/images/profile-pic.jpg';
interface sanityData {
projects: Project[];
}
export let data: sanityData;
</script>

<BodyDiv>
<h1 class="h1">Projects</h1>
<ProjectCardsGrid />
<ProjectCardsGrid projects={data.projects} />
</BodyDiv>

0 comments on commit 6b98972

Please sign in to comment.