Skip to content

Commit

Permalink
Merge pull request #8 from shaniit-org/dev
Browse files Browse the repository at this point in the history
404 page added
  • Loading branch information
Riley1101 authored Nov 24, 2023
2 parents 8f9d3b8 + 124dde9 commit 1c79018
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 103 deletions.
130 changes: 65 additions & 65 deletions src/lib/studio/schema/pages/home/document.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
import { FaHome } from 'react-icons/fa';

export default {
id: 'homePage',
icon: FaHome,
title: 'Home Page',
name: 'homePage',
type: 'document',
fields: [
{
title: 'SEO',
name: 'seo',
type: 'seo'
},
{
title: 'Sections',
name: 'sections',
type: 'array',
of: [
{
name: 'Hero',
type: 'homePage.hero'
},
{
title: 'Highlight',
name: 'Highlight',
type: 'reference',
to: [
{
type: 'news'
},
{
type: 'event'
}
]
},
{
name: 'News',
type: 'homePage.news'
},
{
name: 'Donate',
title: 'Donate',
type: 'banner'
},
{
name: 'Events',
type: 'homePage.events'
}
]
}
],
preview: {
select: {
title: 'seo.title',
media: 'seo.ogImage'
},
/**
* @param {import('sanity').PreviewProps} props
*/
prepare({ title, media, subtitle }) {
return {
title: title || 'Home Page',
subtitle: subtitle,
media
};
}
}
id: 'homePage',
icon: FaHome,
title: 'Home Page',
name: 'homePage',
type: 'document',
fields: [
{
title: 'SEO',
name: 'seo',
type: 'seo'
},
{
title: 'Sections',
name: 'sections',
type: 'array',
of: [
{
name: 'Hero',
type: 'homePage.hero'
},
{
title: 'Highlight',
name: 'Highlight',
type: 'reference',
to: [
{
type: 'news'
},
{
type: 'event'
}
]
},
{
name: 'News',
type: 'homePage.news'
},
{
name: 'Donate',
title: 'Donate',
type: 'banner'
},
{
name: 'Events',
type: 'homePage.events'
}
]
}
],
preview: {
select: {
title: 'seo.title',
media: 'seo.ogImage'
},
/**
* @param {import('sanity').PreviewProps} props
*/
prepare({ title, media, subtitle }) {
return {
title: title || 'Home Page',
subtitle: subtitle,
media
};
}
}
};
60 changes: 30 additions & 30 deletions src/lib/types/homePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,53 @@ import type { Term } from '.';
import type { News, Event } from '.';

export interface HomePageHero {
_type: 'Hero';
title: string;
heroImage: SanityImage;
_type: 'Hero';
title: string;
heroImage: SanityImage;
}
export interface HighLightNews extends News {
_type: 'Highlight';
title: string;
description: string;
slug: string;
authors: any;
_type: 'Highlight';
title: string;
description: string;
slug: string;
authors: any;
}

export interface HomePageNews {
_type: 'News';
title: string;
description: string;
_type: 'News';
title: string;
description: string;
}

export interface HomePageEvents {
_type: 'Events';
title: string;
description: string;
_type: 'Events';
title: string;
description: string;
}

export interface HomePageDonate {
_type: 'Donate';
title: string;
description: string;
link: Link;
_type: 'Donate';
title: string;
description: string;
link: Link;
}

export interface HomePage {
_type: 'homePage';
term: Term;
seo: BaseMetaData;
sections: HomePageSections[];
_type: 'homePage';
term: Term;
seo: BaseMetaData;
sections: HomePageSections[];
}

type HomePageSections =
| HomePageHero
| HomePageNews
| HomePageEvents
| HomePageDonate
| HighLightNews;
| HomePageHero
| HomePageNews
| HomePageEvents
| HomePageDonate
| HighLightNews;

export interface HomePageData {
homePage: HomePage;
news: News[];
events: Event[];
homePage: HomePage;
news: News[];
events: Event[];
}
42 changes: 42 additions & 0 deletions src/routes/+error.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script>
import { page } from '$app/stores';
import SubHero from '$lib/components/common/SubHero.svelte';
import { Link } from 'carbon-icons-svelte';
import { Button } from 'carbon-components-svelte';
$: meta = {
title: 'SIIT - Shan Institute of Information Technology',
description: $page && $page?.error?.message
};
$: domain = import.meta.env.VITE_PUBLIC_DOMAIN;
</script>
<svelte:head>
<title>{meta.title}</title>
<meta name="title" content={meta.title} />
<meta name="description" content={meta.description} />
<meta property="og:type" content="website" />
<meta property="og:url" content={domain} />
<meta property="og:title" content={meta.title} />
<meta property="og:description" content={meta.description} />
<meta property="og:image" content={'/images/siit.png'} />
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:url" content={domain} />
<meta property="twitter:title" content={meta.title} />
<meta property="twitter:description" content={meta.description} />
<meta property="twitter:image" content="/images/siit.png" />
</svelte:head>
<SubHero title={'Oops 😥'} />
<div class="section-container box">
<div>
<p class="mb-4 text-sm lg:text-4xl lg:leading-[2]">
Page you are looking does not exist or has been removed.
</p>
<Button size="field" href="/" class="text-white border border-blue-500 max-w-max" icon={Link}
>Go to Home</Button
>
</div>
</div>
16 changes: 8 additions & 8 deletions src/routes/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const query = `{
* @type {import('@sveltejs/kit').Load}
*/
export const load = async () => {
/**
* @type {import('$lib/types/homePage').HomePageData}
*/
const data = await getPageData(query);
if (!data.homePage) throw error(404, 'Not Found');
return {
data
};
/**
* @type {import('$lib/types/homePage').HomePageData}
*/
const data = await getPageData(query);
if (!data.homePage) throw error(404, 'Not Found');
return {
data
};
};
File renamed without changes.
File renamed without changes.
Binary file added static/images/siit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1c79018

Please sign in to comment.