mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2025-09-05 18:20:45 +00:00
progress
This commit is contained in:
@@ -7,6 +7,8 @@ import {
|
||||
MediaItem,
|
||||
MediaItemFragment,
|
||||
Page,
|
||||
Post,
|
||||
PostFragment,
|
||||
Project,
|
||||
ProjectFragment,
|
||||
WorkFragment,
|
||||
@@ -22,7 +24,7 @@ export const get: RequestHandler = async (args) => {
|
||||
if (all) {
|
||||
const data = await Call<{ pages: { nodes: Page[] } }>(gql`
|
||||
query {
|
||||
pages {
|
||||
pages(where: {status: PUBLISH}) {
|
||||
nodes {
|
||||
${BaseAttributes}
|
||||
}
|
||||
@@ -50,7 +52,7 @@ export const get: RequestHandler = async (args) => {
|
||||
${MediaItemFragment}
|
||||
${WorkFragment}
|
||||
query {
|
||||
works {
|
||||
works(where: { status: PUBLISH }) {
|
||||
nodes {
|
||||
...WorkFragment
|
||||
}
|
||||
@@ -81,7 +83,7 @@ export const get: RequestHandler = async (args) => {
|
||||
gql`
|
||||
${ProjectFragment}
|
||||
query {
|
||||
projects {
|
||||
projects(where: { status: PUBLISH }) {
|
||||
nodes {
|
||||
...ProjectFragment
|
||||
}
|
||||
@@ -120,6 +122,38 @@ export const get: RequestHandler = async (args) => {
|
||||
)
|
||||
return { body: data.mediaItem }
|
||||
}
|
||||
|
||||
case 'posts': {
|
||||
if (all) {
|
||||
const data = await Call<{ posts: { nodes: Post[] } }>(gql`
|
||||
${PostFragment}
|
||||
${MediaItemFragment}
|
||||
{
|
||||
posts(where: { status: PUBLISH }, first: 1000000000) {
|
||||
nodes {
|
||||
...PostFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
`)
|
||||
return { body: data.posts.nodes }
|
||||
} else {
|
||||
const data = await Call<{ post: Post }>(
|
||||
gql`
|
||||
${PostFragment}
|
||||
${MediaItemFragment}
|
||||
query ($slug: ID!) {
|
||||
post(id: $slug, idType: SLUG) {
|
||||
...PostFragment
|
||||
}
|
||||
}
|
||||
`,
|
||||
{ slug }
|
||||
)
|
||||
return { body: data.post }
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return { status: 404 }
|
||||
}
|
||||
|
32
src/routes/blog/[slug].svelte
Normal file
32
src/routes/blog/[slug].svelte
Normal file
@@ -0,0 +1,32 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { Load } from '@sveltejs/kit'
|
||||
|
||||
export const prerender = true
|
||||
export const load: Load = async ({ fetch, page }) => {
|
||||
return {
|
||||
props: {
|
||||
data: await fetch(`/api/posts/${page.params.slug}.json`).then((r) => r.json()),
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Post } from '$lib/api'
|
||||
import SimplePage from '$lib/components/SimplePage.svelte'
|
||||
import PostAttributes from '$lib/components/PostAttributes.svelte'
|
||||
import WpAdapter from '$lib/components/WPAdapter.svelte'
|
||||
|
||||
export let data: Post
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Works</title>
|
||||
</svelte:head>
|
||||
|
||||
<SimplePage title={data.title}>
|
||||
<PostAttributes post={data} full />
|
||||
{#if data.content}
|
||||
<WpAdapter content={data.content} />
|
||||
{/if}
|
||||
</SimplePage>
|
30
src/routes/blog/index.svelte
Normal file
30
src/routes/blog/index.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { Load } from '@sveltejs/kit'
|
||||
|
||||
export const prerender = true
|
||||
export const load: Load = async ({ fetch }) => {
|
||||
return {
|
||||
props: {
|
||||
data: await fetch('/api/posts/*.json').then((r) => r.json()),
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Post } from '$lib/api'
|
||||
import SimplePage from '$lib/components/SimplePage.svelte'
|
||||
import PostPreview from '$lib/components/PostPreview.svelte'
|
||||
|
||||
export let data: Post[]
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Blog</title>
|
||||
</svelte:head>
|
||||
|
||||
<SimplePage title="Works">
|
||||
{#each data as post}
|
||||
<PostPreview {post} />
|
||||
{/each}
|
||||
</SimplePage>
|
@@ -1,3 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
export const prerender = true
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import IconList from '$lib/components/IconList.svelte'
|
||||
import SimplePage from '$lib/components/SimplePage.svelte'
|
||||
|
@@ -1,22 +1,13 @@
|
||||
<script lang="ts" context="module">
|
||||
import { Call, gql } from '$lib/api'
|
||||
import type { MediaItem } from '$lib/api'
|
||||
|
||||
export const prerender = true
|
||||
|
||||
type Data = Record<'signature' | 'home', { srcSet: string }>
|
||||
export const load: Load = async () => {
|
||||
const data = await Call<Data>(gql`
|
||||
query {
|
||||
signature: mediaItem(id: "signature", idType: SLUG) {
|
||||
srcSet
|
||||
}
|
||||
|
||||
home: mediaItem(id: "home", idType: SLUG) {
|
||||
srcSet
|
||||
}
|
||||
}
|
||||
`)
|
||||
return { props: { data } }
|
||||
type Data = Record<'signature' | 'home', MediaItem>
|
||||
export const load: Load = async ({ fetch }) => {
|
||||
const signature: MediaItem = await fetch('/api/media/signature.json').then((r) => r.json())
|
||||
const home: MediaItem = await fetch('/api/media/home.json').then((r) => r.json())
|
||||
return { props: { data: { signature, home } } }
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -28,7 +19,7 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Niccolo Borgioli</title>
|
||||
<title>Niccolò Borgioli</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="wrapper">
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { Load } from '@sveltejs/kit'
|
||||
|
||||
export const prerender = true
|
||||
export const load: Load = async ({ fetch }) => {
|
||||
return {
|
||||
props: {
|
||||
|
1
src/routes/search.svelte
Normal file
1
src/routes/search.svelte
Normal file
@@ -0,0 +1 @@
|
||||
Hello
|
@@ -1,3 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
export const prerender = true
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import IconList from '$lib/components/IconList.svelte'
|
||||
import SimplePage from '$lib/components/SimplePage.svelte'
|
||||
|
Reference in New Issue
Block a user