Skip to content

Commit

Permalink
feat: new version and design (#68)
Browse files Browse the repository at this point in the history
* Update about section in English and Spanish translations

* Update user main design

* Update main container padding

* Refactor SocialMedia component

* Add schema.org metadata to +page.svelte

* create a Bentogrids and create the design for the first item

* chore: add 2 item of the bento grid

* create the 3 item of the grid

* Update styling for note cards

* Fix note links in +page.svelte

* Update SocialMedia and +page components

* Add title attribute to dark mode button

* Update copyright year in footer

* Update note URLs in +page.svelte

* Refactor page layout and metadata in notes component

* Update styling in +page and +page notes

* Remove unused imports and update meta tags in +page.svelte

* Update Header and Page styles

* Update background color in page links

* Update font size and margin in homepage notes section

* Update package.json version to 5.0.0

* Capacity on main route

* Refactor language selection links in Header.svelte and +page.svelte

* Add Notion service and client code

* Update import paths for Note types

* Add type definitions for ProjectResponse and update project transformer

* Refactor Entry and projects page components

* Update layout styles in notes and projects pages

* Refactor Entry component and note list layout

* Update import statement in sitemap.xml server file

* Update sitemap routes

* Update font size in homepage section

* Update language settings

* Update i18n-util imports and use baseLocale

* Add new routes to sitemap.xml server file

* Refactor sitemap generation and add support for multiple languages

* Swap notesSlugsEn and notesSlugsEs in generateRoutes function
  • Loading branch information
Michael-Liendo authored Jan 19, 2024
1 parent 3b4d586 commit 4d13866
Show file tree
Hide file tree
Showing 41 changed files with 1,058 additions and 559 deletions.
3 changes: 3 additions & 0 deletions .typesafe-i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseLocale": "es"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "michaelliendo.com",
"version": "4.1.1",
"version": "5.0.0",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
22 changes: 12 additions & 10 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div class="text-black dark:text-white" style="display: contents">%sveltekit.body%</div>
</body>
<html lang="%lang%">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div class="text-black dark:text-white" style="display: contents">
%sveltekit.body%
</div>
</body>
</html>
14 changes: 2 additions & 12 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { initAcceptLanguageHeaderDetector } from 'typesafe-i18n/detectors';

import { loadAllLocales } from '$i18n/i18n-util.sync';
import { detectLocale, i18n, isLocale } from '$i18n/i18n-util';
import { baseLocale, detectLocale, i18n, isLocale } from '$i18n/i18n-util';

import type { Handle, RequestEvent } from '@sveltejs/kit';
import type { Locales } from '$i18n/i18n-types';
Expand All @@ -13,18 +13,8 @@ export const handle: Handle = async ({ event, resolve }) => {
// read language slug
const [, lang] = event.url.pathname.split('/');

// redirect to base locale if no locale slug was found
if (!lang) {
const locale = getPreferredLocale(event);

return new Response(null, {
status: 302,
headers: { Location: `/${locale}` },
});
}

// if slug is not a locale, use base locale (e.g. api endpoints)
const locale = isLocale(lang) ? (lang as Locales) : getPreferredLocale(event);
const locale = isLocale(lang) ? (lang as Locales) : baseLocale;
const LL = L[locale];

// bind locale and translation functions to current request
Expand Down
4 changes: 2 additions & 2 deletions src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const en = {
PROJECTS: 'Projects',
},
FOOTER: {
COPYRIGHT: 'Made with ❤️ by Michael Liendo © {year:number}',
COPYRIGHT: 'Made with ❤️ by Michael Liendo © {startYear:number} - {year:number}',
},
},
HOMEPAGE: {
HI: `Hi I'm {name:string} {surname:string},`,
ABOUT: `I'm a Software Developer focused on Svelte and TypeScript with a passion for Web Development. I enjoy working on challenging projects and value collaboration and problem-solving.`,
ABOUT: `I'm a <strong>Software Developer</strong> focused on Svelte and TypeScript with a passion for Web Development. I enjoy working on challenging projects, value collaboration and problem-solving.`,
LATEST_NOTES: 'Latest Notes',
},
} satisfies BaseTranslation;
Expand Down
4 changes: 2 additions & 2 deletions src/i18n/es/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const es = {
PROJECTS: 'Proyectos',
},
FOOTER: {
COPYRIGHT: 'Hecho con ❤️ por Michael Liendo © {year:number}',
COPYRIGHT: 'Hecho con ❤️ por Michael Liendo © {startYear:number} - {year:number}',
},
},
HOMEPAGE: {
HI: 'Hola soy {name:string} {surname:string},',
ABOUT:
'Soy un Desarrollador de Software enfocado en Svelte y TypeScript apasionado por el Desarrollo Web. Disfruto trabajar en proyectos desafiantes y valoro la colaboración y la resolución de problemas.',
'Soy un <strong>Desarrollador de Software</strong> enfocado en Svelte y TypeScript apasionado por el Desarrollo Web. Disfruto trabajar en proyectos desafiantes, valoro la colaboración y la resolución de problemas.',
LATEST_NOTES: 'Últimas notas',
},
} satisfies BaseTranslation;
Expand Down
35 changes: 18 additions & 17 deletions src/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { BaseTranslation as BaseTranslationType, LocalizedString, RequiredParams } from 'typesafe-i18n'

export type BaseTranslation = BaseTranslationType
export type BaseLocale = 'en'
export type BaseLocale = 'es'

export type Locales =
| 'en'
Expand All @@ -17,39 +17,40 @@ type RootTranslation = {
LAYOUT: {
NAV: {
/**
* H​o​m​e
* I​n​i​c​i​o
*/
HOME: string
/**
* N​o​t​e​s
* N​o​t​a​s
*/
NOTES: string
/**
* P​r​o​j​e​c​t​s
* P​r​o​y​e​c​t​o​s
*/
PROJECTS: string
}
FOOTER: {
/**
* M​a​d​e​ ​w​i​t​h​ ​❤​️​ ​b​y​ ​M​i​c​h​a​e​l​ ​L​i​e​n​d​o​ ​©​ ​{​y​e​a​r​}
* H​e​c​h​o​ ​c​o​n​ ​❤​️​ ​p​o​r​ ​M​i​c​h​a​e​l​ ​L​i​e​n​d​o​ ​©​ ​{​s​t​a​r​t​Y​e​a​r​}​ ​-​ ​{​y​e​a​r​}
* @param {number} startYear
* @param {number} year
*/
COPYRIGHT: RequiredParams<'year'>
COPYRIGHT: RequiredParams<'startYear' | 'year'>
}
}
HOMEPAGE: {
/**
* H​i​ ​I​'​m​ ​{​n​a​m​e​}​ ​{​s​u​r​n​a​m​e​}​,
* H​o​l​a​ ​s​o​y​ ​{​n​a​m​e​}​ ​{​s​u​r​n​a​m​e​}​,
* @param {string} name
* @param {string} surname
*/
HI: RequiredParams<'name' | 'surname'>
/**
* I​'​m​ ​a​ ​S​o​f​t​w​a​r​e​ ​D​e​v​e​l​o​p​e​r​ ​f​o​c​u​s​e​d​ ​o​n​ ​S​v​e​l​t​e​ ​a​n​d​ ​T​y​p​e​S​c​r​i​p​t​ ​w​i​t​h​ ​a​ ​p​a​s​s​i​o​n​ ​f​o​r​ ​W​e​b​ ​D​e​v​e​l​o​p​m​e​n​t​.​ ​I​ ​e​n​j​o​y​ ​w​o​r​k​i​n​g​ ​o​n​ ​c​h​a​l​l​e​n​g​i​n​g​ ​p​r​o​j​e​c​t​s​ ​a​n​d​ ​v​a​l​u​e​ ​c​o​l​l​a​b​o​r​a​t​i​o​n​ ​a​n​d​ ​p​r​o​b​l​e​m​-​s​o​l​v​i​n​g​.
* S​o​y​ ​u​n​ ​<​s​t​r​o​n​g​>​D​e​s​a​r​r​o​l​l​a​d​o​r​ ​d​e​ ​S​o​f​t​w​a​r​e​<​/​s​t​r​o​n​g​>​ ​e​n​f​o​c​a​d​o​ ​e​n​ ​S​v​e​l​t​e​ ​y​ ​T​y​p​e​S​c​r​i​p​t​ ​a​p​a​s​i​o​n​a​d​o​ ​p​o​r​ ​e​l​ ​D​e​s​a​r​r​o​l​l​o​ ​W​e​b​.​ ​D​i​s​f​r​u​t​o​ ​t​r​a​b​a​j​a​r​ ​e​n​ ​p​r​o​y​e​c​t​o​s​ ​d​e​s​a​f​i​a​n​t​e​s​,​ ​v​a​l​o​r​o​ ​l​a​ ​c​o​l​a​b​o​r​a​c​i​ó​n​ ​y​ ​l​a​ ​r​e​s​o​l​u​c​i​ó​n​ ​d​e​ ​p​r​o​b​l​e​m​a​s​.
*/
ABOUT: string
/**
* L​a​t​e​s​t​ ​N​o​t​e​s
* Ú​l​t​i​m​a​s​ ​n​o​t​a​s
*/
LATEST_NOTES: string
}
Expand All @@ -59,36 +60,36 @@ export type TranslationFunctions = {
LAYOUT: {
NAV: {
/**
* Home
* Inicio
*/
HOME: () => LocalizedString
/**
* Notes
* Notas
*/
NOTES: () => LocalizedString
/**
* Projects
* Proyectos
*/
PROJECTS: () => LocalizedString
}
FOOTER: {
/**
* Made with ❤️ by Michael Liendo © {year}
* Hecho con ❤️ por Michael Liendo © {startYear} - {year}
*/
COPYRIGHT: (arg: { year: number }) => LocalizedString
COPYRIGHT: (arg: { startYear: number, year: number }) => LocalizedString
}
}
HOMEPAGE: {
/**
* Hi I'm {name} {surname},
* Hola soy {name} {surname},
*/
HI: (arg: { name: string, surname: string }) => LocalizedString
/**
* I'm a Software Developer focused on Svelte and TypeScript with a passion for Web Development. I enjoy working on challenging projects and value collaboration and problem-solving.
* Soy un <strong>Desarrollador de Software</strong> enfocado en Svelte y TypeScript apasionado por el Desarrollo Web. Disfruto trabajar en proyectos desafiantes, valoro la colaboración y la resolución de problemas.
*/
ABOUT: () => LocalizedString
/**
* Latest Notes
* Últimas notas
*/
LATEST_NOTES: () => LocalizedString
}
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/i18n-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { detectLocale as detectLocaleFn } from 'typesafe-i18n/detectors'
import { initExtendDictionary } from 'typesafe-i18n/utils'
import type { Formatters, Locales, Translations, TranslationFunctions } from './i18n-types'

export const baseLocale: Locales = 'en'
export const baseLocale: Locales = 'es'

export const locales: Locales[] = [
'en',
Expand Down
116 changes: 66 additions & 50 deletions src/lib/components/Entry.svelte
Original file line number Diff line number Diff line change
@@ -1,57 +1,73 @@
<script lang="ts">
import { page } from '$app/stores';
import type { MultiSelectEntity } from '$lib/utils/Notion/Notes/types';
import Calendar from '~icons/mdi/calendar-month';
import { page } from '$app/stores';
import { locale } from '$i18n/i18n-svelte';
import Calendar from '~icons/mdi/calendar-month';
import { baseLocale } from '$i18n/i18n-util';
export let title = '';
export let description = '';
export let publishDate: Date;
export let tags: MultiSelectEntity[] = [];
export let slug = '';
export let previewImageUrl: string | null = '';
import type { MultiSelectEntity } from '$lib/services/Notion/Notes/notes';
let formattedDate = new Date(publishDate).toLocaleDateString(`${$page.data.locale}-us`, {
month: 'long',
day: '2-digit',
year: 'numeric'
});
export let title = '';
export let description = '';
export let publishDate: Date;
export let tags: MultiSelectEntity[] = [];
export let slug = '';
export let previewImageUrl: string | null = '';
const baseLocaleUrl = $locale === baseLocale ? '' : `/${$locale}`;
let formattedDate = new Date(publishDate).toLocaleDateString(
`${$page.data.locale}-us`,
{
month: 'long',
day: '2-digit',
year: 'numeric',
}
);
</script>

<li class="mb-4 md:mb-0 last-of-type:mb-0">
<a href="/{$page.params.lang}/notes/{slug}">
<figure class="rounded overflow-hidden pb-4 flex justify-center items-center h-[150px]">
<img alt={title} src={previewImageUrl} width="350" height="100" />
</figure>
<header>
<h1 class="text-xl py-4 font-extrabold cursor-pointer hover:text-link hover:underline">
{title}
</h1>
</header>
<main class="pb-4">
<p>{description}</p>
</main>
<footer class="flex flex-col">
<div class="flex mb-2">
<span class="flex items-center mr-2">
<figure class="mr-2">
<Calendar class="text-gray-800 dark:text-white h-4 w-4" />
</figure>
<time class="text-sm mr-2" datetime={publishDate.toString()}>{formattedDate}</time>
</span>
</div>
<ul class="flex flex-wrap">
{#each tags as tag}
<li
class="text-sm mr-2 mb-2 bg-light-background dark:bg-dark-background rounded py-1 px-2"
>
<span
class="inline-block mr-1 rounded-full h-2 w-2"
style="background-color: {tag.color};"
/>
{tag.name}
</li>
{/each}
</ul>
</footer>
</a>
<a href="{baseLocaleUrl}/notes/{slug}">
<figure class="rounded-md mb-10 h-[200px]">
<img
alt={title}
class="rounded-md"
src={previewImageUrl}
width="350"
height="100"
/>
</figure>
<header>
<h1 class="text-xl font-extrabold hover:text-link hover:underline">
{title}
</h1>
</header>
<main class="pb-4">
<p>{description}</p>
</main>
<footer class="flex flex-col">
<div class="flex mb-2">
<span class="flex items-center mr-2">
<figure class="mr-2">
<Calendar class="text-gray-800 dark:text-white h-4 w-4" />
</figure>
<time class="text-sm mr-2" datetime={publishDate.toString()}
>{formattedDate}</time
>
</span>
</div>
<ul class="flex flex-wrap">
{#each tags as tag}
<li
class="text-sm mr-2 mb-2 bg-light-background dark:bg-dark-background rounded py-1 px-2"
>
<span
class="inline-block mr-1 rounded-full h-2 w-2"
style="background-color: {tag.color};"
/>
{tag.name}
</li>
{/each}
</ul>
</footer>
</a>
</li>
25 changes: 17 additions & 8 deletions src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
<script lang="ts">
import LL from '$i18n/i18n-svelte';
import LL from '$i18n/i18n-svelte';
const currentYear = new Date().getFullYear();
const currentYear = new Date().getFullYear();
</script>

<footer class="w-full px-4 flex items-center justify-center">
<div class="h-[70px] flex items-center justify-center">
<small>
{$LL.LAYOUT.FOOTER.COPYRIGHT({ year: currentYear })}
</small>
</div>
<footer class="w-full mt-5 px-4 py-5">
<div class=" flex items-center justify-center">
<small>
{$LL.LAYOUT.FOOTER.COPYRIGHT({ year: currentYear, startYear: 2021 })}
</small>
</div>
<div class="flex justify-center">
<small
><a
class="underline"
href="https://github.com/Michael-Liendo/michaelliendo.com"
>Source code</a
></small
>
</div>
</footer>
Loading

0 comments on commit 4d13866

Please sign in to comment.