We are half way there

This commit is contained in:
2023-01-17 20:57:28 +01:00
parent 145a5571c3
commit dad51ddb33
22 changed files with 2107 additions and 2079 deletions

20
src/routes/+layout.svelte Normal file
View File

@ -0,0 +1,20 @@
<script lang="ts">
import type { LayoutData } from "./$types"
import Nav from '../components/Nav.svelte'
import Footer from '../components/Footer.svelte'
import 'modern-normalize/modern-normalize.css'
import '$lib/styles/global.css'
import { mainContentClass } from './layout.css'
export let data: LayoutData
export let latestPosts = data.latestPosts
</script>
<div class="app-content">
<Nav />
<main class={mainContentClass}>
<slot />
</main>
<Footer {latestPosts} />
</div>

12
src/routes/+layout.ts Normal file
View File

@ -0,0 +1,12 @@
import type { LayoutLoad } from './$types';
export const load = (async ({ fetch, url }) => {
const blogPostsResponse = await fetch(`/blog/articles/pageSize/5.json`)
const blogPostsContent = await blogPostsResponse.json()
return {
latestPosts: blogPostsContent.posts.items,
// TODO Check if not bugged FIXME
segment: '',
}
}) satisfies LayoutLoad

View File

@ -1,37 +0,0 @@
<script context="module" lang="ts">
import { take } from 'ramda'
import type { LoadInput, LoadOutput } from '@sveltejs/kit/types/page'
export async function load({ fetch, url }: LoadInput): Promise<LoadOutput> {
const blogPostsResponse = await fetch(`/blog/articles/pageSize/5.json`)
const blogPostsContent = await blogPostsResponse.json()
return {
props: {
latestPosts: blogPostsContent.posts.items,
// TODO Check if not bugged FIXME
// TODO remove console.logs
segment: '',
},
}
}
</script>
<script lang="ts">
import Nav from '../components/Nav.svelte'
import Footer from '../components/Footer.svelte'
import 'modern-normalize/modern-normalize.css'
import '$lib/styles/global.css'
import { mainContentClass } from './layout.css'
export let segment
export let latestPosts
</script>
<div class="app-content">
<Nav {segment} />
<main class={mainContentClass}>
<slot />
</main>
<Footer {latestPosts} />
</div>

View File

@ -25,7 +25,7 @@
import ArticleFooter from '../../components/blog/ArticleFooter.svelte'
import Paginator from '../../components/paginator/Paginator.svelte'
import { postListClass, seeAllClass } from './index.css'
import type { PostContent } from './_content'
import type { PostContent } from './content'
import type { PaginationResult } from '$lib/pagination/pagination'
export let posts: PaginationResult<PostContent>

View File

@ -2,7 +2,7 @@ import { readFile } from 'fs'
import { promisify } from 'util'
import fm from 'front-matter'
import { parseField } from '../../markdown/parse-markdown'
import type { PostAttributes } from './_content'
import type { PostAttributes } from './content'
import type { Request, Response } from '@sveltejs/kit'
export interface SinglePost {

View File

@ -2,9 +2,11 @@ import {
getDropTakeFromPageParams,
parseParams,
} from '$lib/pagination/dropTakeParams'
import { getBlogListing } from '../_content'
import { json } from '@sveltejs/kit'
import { getBlogListing } from '../../content'
import type { RequestHandler } from './$types'
export async function get({ params }) {
export const GET = (async ({ params }) => {
console.log('article-params', params)
const handledParams = params.params === 'index' ? '' : params.params
const { page = 1, pageSize = 7, ...filters } = parseParams(handledParams)
@ -15,10 +17,7 @@ export async function get({ params }) {
const paginationQuery = { ...paginationParams, filters }
const filteredContents = await getBlogListing(paginationQuery)
return {
status: 200,
body: {
posts: filteredContents,
},
}
}
return json({
posts: filteredContents,
})
}) satisfies RequestHandler

View File

@ -1,5 +1,5 @@
import { Feed } from 'feed'
import { getBlogListing } from '../blog/_content'
import { getBlogListing } from '../blog/content'
export async function getFeed() {
const feed = new Feed({

View File

@ -3,6 +3,7 @@ import { promisify } from 'util'
import fm from 'front-matter'
import marked from 'marked'
import { parseField } from '../../markdown/parse-markdown'
import type { PageServerLoad } from './$types'
export interface RecordAttributes {
name: string
@ -50,16 +51,8 @@ export type PortfolioContent = {
body: string
}
export async function get() {
let pageSource: string
try {
pageSource = await promisify(readFile)('_pages/portfolio.md', 'utf-8')
} catch (e) {
return {
status: 500,
body: 'Error loading portfolio source file. \n' + e.toString(),
}
}
export const load = (async () => {
const pageSource = await promisify(readFile)('_pages/portfolio.md', 'utf-8')
const parsed = fm<PortfolioAttributes>(pageSource)
const workHistory = (parsed.attributes.work_history || [])
@ -85,8 +78,5 @@ export async function get() {
presentations,
}
return {
status: 200,
body: response,
}
}
return response;
}) satisfies PageServerLoad

View File

@ -1,30 +1,16 @@
<script lang="ts" context="module">
/**
* @type {import('@sveltejs/kit').Load}
*/
export async function load({ fetch }) {
const res = await fetch('portfolio.json')
const content = await res.json()
return {
props: {
content,
},
}
}
</script>
<script lang="ts">
import Work from '../../components/portfolio/work.svelte'
import Project from '../../components/portfolio/project.svelte'
import Presentation from '../../components/portfolio/presentation.svelte'
import type { PortfolioContent } from './index.json'
import type { PageData } from './$types'
import { listClass, listItemClass, nameTagClass } from './index.css'
export let content: PortfolioContent
export let data: PageData
</script>
<svelte:head>
<title>{content.title}</title>
<title>{data.title}</title>
</svelte:head>
<h1 class="name-tag {nameTagClass}">Michal Vanko</h1>
@ -34,16 +20,16 @@
</h2>
<section id="personal-information">
{@html content.body}
{@html data.body}
</section>
<section id="work-history">
<h2>Work experience</h2>
<section class="work-history-prelude">
{@html content.workHistoryPrelude}
{@html data.workHistoryPrelude}
</section>
<ul class={listClass}>
{#each content.workHistory as work}
{#each data.workHistory as work}
<li class={listItemClass}>
<Work {work} />
</li>
@ -54,7 +40,7 @@
<section id="projects">
<h2>Projects</h2>
<ul class={listClass}>
{#each content.projects as project}
{#each data.projects as project}
<li class={listItemClass}>
<Project {project} />
</li>
@ -65,7 +51,7 @@
<section id="presentations">
<h2>Presentations</h2>
<ul class="">
{#each content.presentations as presentation}
{#each data.presentations as presentation}
<li class="">
<Presentation {presentation} />
</li>
@ -76,7 +62,7 @@
<section id="education">
<h2>Education</h2>
<ul class={listClass}>
{#each content.education as work}
{#each data.education as work}
<li class={listItemClass}>
<Work {work} />
</li>

View File

@ -0,0 +1,9 @@
import type { PageLoad } from './$types'
export const load = (async () => {
const res = await fetch('/portfolio.json')
const content = await res.json()
return {
content,
}
}) satisfies PageLoad