diff --git a/elixir-api/lib/routes/api/v1/tag.ex b/elixir-api/lib/routes/api/v1/tag.ex index 8675e0da7..478de8c3f 100644 --- a/elixir-api/lib/routes/api/v1/tag.ex +++ b/elixir-api/lib/routes/api/v1/tag.ex @@ -35,10 +35,10 @@ defmodule Router.Api.V1.Tag do ]) |> Query.project([ "_id", - ["'objectID'", "_id"], "_rev", "_type", "title", + "views", "publishedAt", %{ "tags[]" => [ @@ -46,7 +46,7 @@ defmodule Router.Api.V1.Tag do "title", "slug" ], - :follow => true + :join => "->" }, "slug", "body", @@ -74,17 +74,34 @@ defmodule Router.Api.V1.Tag do parsed_counts = Task.await(counts) {transformed_result, meta, code} = - transform_result_document(query, result, :tag, params, %{ - "total" => parsed_counts["result"]["total"], - "count" => parsed_counts["result"]["count"], - "id" => id, - "type" => params["type"] - }) + transform_result_document( + query, + result, + String.to_atom(params["type"] <> "s"), + params, + %{ + "total" => parsed_counts["result"]["total"], + "count" => parsed_counts["result"]["count"] + } + ) + + # parsed_counts = Task.await(counts) + + # {transformed_result, meta, code} = + # transform_result_document(query, result, :tag, params, %{ + # "total" => parsed_counts["result"]["total"], + # "count" => parsed_counts["result"]["count"], + # "id" => id, + # "type" => params["type"] + # }) update_meta_and_send_response(conn, code, transformed_result, meta, duration) end) else false -> + {:ok, params} = validate_query_params(conn, %{"type" => nil}) + Logger.info("type param: #{inspect(params["type"])}") + Logger.info("ID: #{inspect(id)}") conn |> error_res(400, "Invalid request", [%{message: "Missing ID or invalid type"}]) {:error, reason} -> diff --git a/elixir-api/lib/routes/api/v1/tags.ex b/elixir-api/lib/routes/api/v1/tags.ex index ca8979938..f29549dbf 100644 --- a/elixir-api/lib/routes/api/v1/tags.ex +++ b/elixir-api/lib/routes/api/v1/tags.ex @@ -28,8 +28,9 @@ defmodule Router.Api.V1.Tags do |> Query.project([ "_id", "_rev", - ["'objectID'", "_id"], "_type", + "_createdAt", + "_updatedAt", "title", "slug" ]) diff --git a/svelte-app/src/components/about/timeline-item.svelte b/svelte-app/src/components/about/timeline-item.svelte index 60b32e708..612be3a0f 100644 --- a/svelte-app/src/components/about/timeline-item.svelte +++ b/svelte-app/src/components/about/timeline-item.svelte @@ -18,10 +18,11 @@ class:pb-4={!last} > + class="bullet block flex-shrink-0 rounded-xs text-orange-dark dark:text-orange-light" + >→
-

+

{title}

@@ -43,13 +44,14 @@ $bulletTopMargin: 13px; $bulletSize: 6px; - $lineWidth: 2px; + $lineWidth: 1px; $lineGap: 14px; .bullet { margin-top: $bulletTopMargin; width: $bulletSize; height: $bulletSize; + line-height: $bulletSize; } .content { @@ -60,18 +62,18 @@ } &:before { - @apply absolute bg-dark/20; + @apply absolute border-l border-dashed border-neutral-200 transition-colors; $baseSpaceFromTop: $bulletTopMargin + $bulletSize; content: ''; top: #{$bulletTopMargin + $bulletSize + $lineGap}; bottom: #{0px + $lineGap - $bulletTopMargin}; - left: #{$bulletSize * 2 + $lineWidth}; + left: #{$bulletSize * 2}; width: $lineWidth; @include dark { - @apply bg-white/20; + @apply border-neutral-400; } } } diff --git a/svelte-app/src/components/about/timeline-section.svelte b/svelte-app/src/components/about/timeline-section.svelte index 0356ba87d..22c33e68d 100644 --- a/svelte-app/src/components/about/timeline-section.svelte +++ b/svelte-app/src/components/about/timeline-section.svelte @@ -15,7 +15,7 @@

{title} diff --git a/svelte-app/src/components/code-block.svelte b/svelte-app/src/components/code-block.svelte index e3f1874b3..8aace20c3 100644 --- a/svelte-app/src/components/code-block.svelte +++ b/svelte-app/src/components/code-block.svelte @@ -7,9 +7,8 @@ import { genericAsyncImport, getLangType } from '$components/code-block/imports'; import Divider from '$components/divider.svelte'; - import Icon from '$components/icon.svelte'; + import Hoverable from '$components/hoverable.svelte'; import Spinner from '$components/loading/spinner.svelte'; - import Tooltip from '$components/tooltips/tooltip.svelte'; import type { ResolvedComponentType } from '$components/code-block/imports'; import type { LanguageType as _LanguageType } from 'svelte-highlight/languages'; @@ -79,20 +78,17 @@ > {#if filename}
{filename}
{/if} - + + - +
+ {/if} +
diff --git a/svelte-app/src/components/controls/theme-toggle.svelte b/svelte-app/src/components/controls/theme-toggle.svelte index d30fb9665..2dbe43a1a 100644 --- a/svelte-app/src/components/controls/theme-toggle.svelte +++ b/svelte-app/src/components/controls/theme-toggle.svelte @@ -4,29 +4,25 @@ import Settings from '$lib/settings'; import Hoverable from '$components/hoverable.svelte'; - import Icon from '$components/icon.svelte'; - import Tooltip from '$components/tooltips/tooltip.svelte'; const { theme, modified } = Settings; - - - - + diff --git a/svelte-app/src/components/document/content/footer.svelte b/svelte-app/src/components/document/content/footer.svelte index cc0d4d660..76d41b852 100644 --- a/svelte-app/src/components/document/content/footer.svelte +++ b/svelte-app/src/components/document/content/footer.svelte @@ -25,19 +25,12 @@ {/if}
- - {#key $isMobile} - - {/key} -

{$t('Read more')}

-
-
+ />
diff --git a/svelte-app/src/components/document/content/header.svelte b/svelte-app/src/components/document/content/header.svelte index 66de42c0e..7cab77bd0 100644 --- a/svelte-app/src/components/document/content/header.svelte +++ b/svelte-app/src/components/document/content/header.svelte @@ -5,7 +5,6 @@ import BulletPoint from '$components/bullet-point.svelte'; import ArrowButton from '$components/controls/arrow-button.svelte'; - import Icon from '$components/icon.svelte'; import Image from '$components/images/image.svelte'; import Link from '$components/link.svelte'; import ImageCarousel from '$components/portable-text/image-carousel.svelte'; @@ -62,17 +61,13 @@

{#if !data.tags?.length} + /> {/if}
@@ -83,25 +78,26 @@ aria-label={$t('Tags')} > {#each data.tags as tag} - {tag.title.toLowerCase()} - + {/each} + /> {/if} @@ -110,7 +106,10 @@
- + url / {'github.com/' + data.github.split('github.com/')?.[1]} diff --git a/svelte-app/src/components/empty-content.svelte b/svelte-app/src/components/empty-content.svelte index 445b8cb42..887ecc82e 100644 --- a/svelte-app/src/components/empty-content.svelte +++ b/svelte-app/src/components/empty-content.svelte @@ -1,13 +1,10 @@ -
- -

{$t('Hm, it seems empty around here...')}

+
+

+ [!] + {$t('errors.no-content.message')} +

diff --git a/svelte-app/src/components/experiments/gol.svelte b/svelte-app/src/components/experiments/gol.svelte index ea69c7f4a..0c3ccbd7b 100644 --- a/svelte-app/src/components/experiments/gol.svelte +++ b/svelte-app/src/components/experiments/gol.svelte @@ -143,7 +143,7 @@ > {#if running} {:else} + {/each}
@@ -106,13 +105,13 @@ class="z-10 flex flex-col items-start justify-center gap-1 text-dark/90 transition-[color] dark:text-light/90" >

{data.title ?? 'Unknown title'}

{data.artist ?? ''} diff --git a/svelte-app/src/components/footer.svelte b/svelte-app/src/components/footer.svelte index c005dfe4e..4726a69a2 100644 --- a/svelte-app/src/components/footer.svelte +++ b/svelte-app/src/components/footer.svelte @@ -3,8 +3,6 @@ import { APP_VERSION } from '$lib/env'; import { t } from '$lib/i18n'; - import Hoverable from '$components/hoverable.svelte'; - import Icon from '$components/icon.svelte'; import BaseLink from '$components/nav/base-link.svelte'; import Tooltip from '$components/tooltips/tooltip.svelte'; @@ -22,56 +20,65 @@ {#if socials?.length || APP_VERSION?.length}

{/if} diff --git a/svelte-app/src/components/header.svelte b/svelte-app/src/components/header.svelte index e33a271ed..e9707017a 100644 --- a/svelte-app/src/components/header.svelte +++ b/svelte-app/src/components/header.svelte @@ -4,42 +4,49 @@ import LanguageControls from '$components/controls/language-toggle.svelte'; import ThemeToggle from '$components/controls/theme-toggle.svelte'; import NavLink from '$components/nav/header-link.svelte'; - import HeaderLogo from '$components/nav/header-logo.svelte';
- -
- -
diff --git a/svelte-app/src/components/headings/headed-block.svelte b/svelte-app/src/components/headings/headed-block.svelte index 972921fa6..016b6ad23 100644 --- a/svelte-app/src/components/headings/headed-block.svelte +++ b/svelte-app/src/components/headings/headed-block.svelte @@ -1,7 +1,8 @@
{ @@ -45,3 +49,16 @@
+ + diff --git a/svelte-app/src/components/link.svelte b/svelte-app/src/components/link.svelte index 5aa5e56ab..fbc15ba1a 100644 --- a/svelte-app/src/components/link.svelte +++ b/svelte-app/src/components/link.svelte @@ -25,13 +25,15 @@ text={tooltipText ?? (link && link.length > 50 ? `${link.slice(0, 50 - 3)}...` : link ?? $t('Visit'))} position={tooltipPosition} - inDelay={250} + inDelay={500} > -
- {#each documents as document} +
+ {#each documents as document, idx} + {#if idx < documents.length - 1} + + {/if} {/each}
diff --git a/svelte-app/src/components/lists/list-item.svelte b/svelte-app/src/components/lists/list-item.svelte index b1df9150d..aef8cc44d 100644 --- a/svelte-app/src/components/lists/list-item.svelte +++ b/svelte-app/src/components/lists/list-item.svelte @@ -19,13 +19,13 @@

@@ -33,8 +33,8 @@

{#if document.tags?.length} {document.tags[0].title.toLowerCase()}{document.tags[0].title.toLowerCase()} {:else} @@ -43,7 +43,7 @@

@@ -51,7 +51,17 @@

{#if document.desc?.length} -

{document.desc}

+

+ {document.desc} +

{/if} + +
diff --git a/svelte-app/src/components/loading/spinner.svelte b/svelte-app/src/components/loading/spinner.svelte index a1f70d69a..eea0beb2e 100644 --- a/svelte-app/src/components/loading/spinner.svelte +++ b/svelte-app/src/components/loading/spinner.svelte @@ -1,5 +1,5 @@ - - diff --git a/svelte-app/src/components/nav/header-link.svelte b/svelte-app/src/components/nav/header-link.svelte index d0ab3c7db..2b0689072 100644 --- a/svelte-app/src/components/nav/header-link.svelte +++ b/svelte-app/src/components/nav/header-link.svelte @@ -37,5 +37,9 @@ })(); - + diff --git a/svelte-app/src/components/nav/header-logo.svelte b/svelte-app/src/components/nav/header-logo.svelte index d900b9774..a1db37d95 100644 --- a/svelte-app/src/components/nav/header-logo.svelte +++ b/svelte-app/src/components/nav/header-logo.svelte @@ -21,7 +21,7 @@ - import Icon from '$components/icon.svelte'; + import Hoverable from '$components/hoverable.svelte'; export let dir: 'left' | 'right', onClick: () => void, disabled = false; - + + + diff --git a/svelte-app/src/components/portable-text/serializers/custom-highlight.svelte b/svelte-app/src/components/portable-text/serializers/custom-highlight.svelte index e69408998..abc0bc7cc 100644 --- a/svelte-app/src/components/portable-text/serializers/custom-highlight.svelte +++ b/svelte-app/src/components/portable-text/serializers/custom-highlight.svelte @@ -7,10 +7,10 @@ - + diff --git a/svelte-app/src/components/tooltips/inner.svelte b/svelte-app/src/components/tooltips/inner.svelte index ae9f17563..2b9189b54 100644 --- a/svelte-app/src/components/tooltips/inner.svelte +++ b/svelte-app/src/components/tooltips/inner.svelte @@ -149,7 +149,7 @@ aria-hidden="true" > diff --git a/svelte-app/src/languages/en.json b/svelte-app/src/languages/en.json index d05836f2c..711b283cd 100644 --- a/svelte-app/src/languages/en.json +++ b/svelte-app/src/languages/en.json @@ -4,12 +4,15 @@ "A project on kio.dev": "A project on kio.dev", "About": "About", "About me": "About me", + "All posts": "All posts", + "All topics": "All topics", "Back": "Back", "Blog": "Blog", "Click here to": "Click here to", "Code block": "Code block", "Code content": "Code content", "Copied": "Copied", + "Copy": "Copy", "Copy to clipboard": "Copy to clipboard", "Date posted": "Date posted", "Duration": "Duration", @@ -25,6 +28,9 @@ "Home": "Home", "Internal Error": "Internal Error", "Invalid date": "Invalid date", + "Language": "Language", + "Lights off": "Lights off", + "Lights on": "Lights on", "Links": "Links", "Meta": "Meta", "More": "More", @@ -43,12 +49,16 @@ "See more": "See more", "Show stack trace": "Show stack trace", "Skip to content": "Skip to content", + "Social": "Social", "Social links": "Social links", "Sorry, something went wrong. Please try again.": "Sorry, something went wrong. Please try again.", "Switch to English": "Switch to English", "Switch to French": "Switch to French", "Tags": "Tags", + "Theme": "Theme", "Thoughts": "Thoughts", + "Topic": "Topic", + "Topics": "Topics", "Unknown date": "Unknown date", "Use dark mode": "Use dark mode", "Use light mode": "Use light mode", @@ -82,6 +92,9 @@ "unauthorized": { "message": "Sorry, you don't have permission to access that resource.", "title": "Unauthorized" + }, + "no-content": { + "message": "No content." } }, "go back": "go back", @@ -101,7 +114,11 @@ }, "thoughts": { "description": "Thoughts about tech, design, and development", - "title": "Thoughts" + "title": "Thoughts", + "sections": { + "topics": "Topics", + "posts": "Recent thoughts" + } }, "work": { "description": "An overview of my work, prior roles, and open-source contributions", diff --git a/svelte-app/src/languages/fr.json b/svelte-app/src/languages/fr.json index 6d1a26607..467e6a3ef 100644 --- a/svelte-app/src/languages/fr.json +++ b/svelte-app/src/languages/fr.json @@ -4,12 +4,15 @@ "A project on kio.dev": "Un projet sur kio.dev", "About": "À propos", "About me": "À propos de moi", + "All posts": "Tous les articles", + "All topics": "Tous les sujets", "Back": "Retour", "Blog": "Blog", "Click here to": "Cliquez ici pour", "Code block": "Bloc de code", "Code content": "Contenu du code", "Copied": "Copié", + "Copy": "Copier", "Copy to clipboard": "Copier dans le presse-papiers", "Date posted": "Date de publication", "Duration": "Durée", @@ -25,6 +28,9 @@ "Home": "Accueil", "Internal Error": "Erreur interne", "Invalid date": "Date invalide", + "Language": "Langue", + "Lights off": "Lumières éteintes", + "Lights on": "Lumières allumées", "Links": "Liens", "Meta": "Plus", "More": "Plus", @@ -43,12 +49,16 @@ "See more": "Voir plus", "Show stack trace": "Afficher la trace de la pile", "Skip to content": "Passer au contenu", + "Social": "Social", "Social links": "Liens sociaux", "Sorry, something went wrong. Please try again.": "Désolé, quelque chose s'est mal passé. Veuillez réessayer.", "Switch to English": "Passer à l'Anglais", "Switch to French": "Passer au Français", "Tags": "Tags", + "Theme": "Thème", "Thoughts": "Pensées", + "Topic": "Sujet", + "Topics": "Sujets", "Unknown date": "Date inconnue", "Use dark mode": "Utiliser le mode sombre", "Use light mode": "Utiliser le mode clair", @@ -82,6 +92,9 @@ "unauthorized": { "message": "Désolé, vous n'êtes pas autorisé à accéder à cette ressource.", "title": "Non Autorisé" + }, + "no-content": { + "message": "Pas de contenu." } }, "go back": "retourner", @@ -101,7 +114,11 @@ }, "thoughts": { "description": "Pensées sur la technologie, le design et le développement", - "title": "Pensées" + "title": "Pensées", + "sections": { + "topics": "Sujets", + "posts": "Articles récents" + } }, "work": { "description": "Un aperçu de mon travail, de mes rôles précédents et de mes contributions open-source", diff --git a/svelte-app/src/lib/consts.ts b/svelte-app/src/lib/consts.ts index ed8a78e9f..9e7b6b8cc 100644 --- a/svelte-app/src/lib/consts.ts +++ b/svelte-app/src/lib/consts.ts @@ -12,7 +12,7 @@ export const MEDIA_QUERIES = { export const APP_LANGS = ['en', 'fr']; export const DEFAULT_APP_LANG = APP_LANGS[0]; -export const VALID_DOC_TYPES = ['post', 'project', 'config'] as const; +export const VALID_DOC_TYPES = ['post', 'project', 'config', 'tag'] as const; export const LOCAL_SETTINGS_KEY = 'kio-dev-settings'; diff --git a/svelte-app/src/lib/settings.ts b/svelte-app/src/lib/settings.ts index fcc728a23..ee04aa394 100644 --- a/svelte-app/src/lib/settings.ts +++ b/svelte-app/src/lib/settings.ts @@ -52,17 +52,6 @@ const useStoredSettings = (settings?: string) => { } break; } - // if ( - // key === 'theme' && - // typeof savedSetting === 'string' && - // Object.values(APP_THEMES).includes( - // savedSetting as (typeof APP_THEMES)[keyof typeof APP_THEMES] - // ) - // ) { - // themeSetting = savedSetting as (typeof APP_THEMES)[keyof typeof APP_THEMES]; - // } else if (key === 'reduce_motion' && typeof savedSetting === 'boolean') { - // reduceMotionSetting = savedSetting; - // } }); return true; @@ -83,12 +72,6 @@ if (browser) { useStoredSettings(storedSettings); -// if (!useStoredSettings(storedSettings)) { -// themeSetting = APP_THEMES.DARK; -// reduceMotionSetting = false; -// modifiedSetting = false; -// } - const settings = { theme: writable(themeSetting), reduce_motion: writable(reduceMotionSetting), diff --git a/svelte-app/src/lib/store.ts b/svelte-app/src/lib/store.ts index 7a9a61c02..a4f69aa51 100644 --- a/svelte-app/src/lib/store.ts +++ b/svelte-app/src/lib/store.ts @@ -90,7 +90,7 @@ const constructUrl = ( return `${basePath}${queryParams.length ? `?${queryParams.join('&')}` : ''}`; }; -export const incViews = ( +export const incViews = async ( fetch: RouteFetch, doc: DocumentRegistry[keyof DocumentRegistry] ) => { @@ -99,7 +99,7 @@ export const incViews = ( } try { - fetch(`${API_URL}mutate`, { + const res = await fetch(`${API_URL}mutate`, { method: 'POST', body: JSON.stringify({ id: doc._id, @@ -107,8 +107,15 @@ export const incViews = ( field: 'views' }) }); + + if (!res.ok) { + Logger.error(`Failed to increment views for ${doc._type} ${doc._id}`, { + status: res.status, + statusText: res.statusText + }); + } } catch (e) { - Logger.error('', e); + Logger.error('Error incrementing views', e); } }; @@ -131,7 +138,8 @@ const fetchData = async ( if ( !(fetchResponse?.meta && fetchResponse?.data) || - (typeof fetchResponse?.data === 'object' && + (!Array.isArray(fetchResponse?.data) && + typeof fetchResponse?.data === 'object' && Object.keys(fetchResponse.data).length === 0) || (Array.isArray(fetchResponse?.data) && !fetchResponse?.meta && @@ -177,6 +185,7 @@ const find = async ( return response; }; +// TODO: These types are a fucking mess and desperately need a refactor but honestly it _works_ and I can't be fucked const findOne = async ( fetch: RouteFetch, model: T, diff --git a/svelte-app/src/routes/+error.svelte b/svelte-app/src/routes/+error.svelte index 6845611c7..bcfdbad54 100644 --- a/svelte-app/src/routes/+error.svelte +++ b/svelte-app/src/routes/+error.svelte @@ -6,10 +6,8 @@ import { t } from '$lib/i18n'; import ArrowButton from '$components/controls/arrow-button.svelte'; - import Divider from '$components/divider.svelte'; import HeadedBlock from '$components/headings/headed-block.svelte'; - import Icon from '$components/icon.svelte'; - import ConstrainWidth from '$components/layouts/constrain-width.svelte'; + import Divider from '$components/divider.svelte'; import Link from '$components/link.svelte'; import type { LocaleKey } from '$generated'; @@ -88,41 +86,43 @@ - -
- -

- - {$page.error?.message && $page.status !== 404 ? $page.error.message : $t(message)} -

-

- {$t('Please')} - window.history.back()}>{$t('go back')}, or window.location.reload()}>{$t('refresh the page')}. -

-
+
+ +

+ + {$page.error?.message && $page.status !== 404 ? $page.error.message : $t(message)} +

+

+ {$t('Please')} + window.history.back()}>{$t('go back')}, or window.location.reload()}>{$t('refresh the page')}. +

+
- {#if causes?.length} - - (showStack = !showStack)} fullWidth> - -

{$t('See more')}

- -
-
- {#if showStack} -
+ {#if causes?.length} +
+ + (showStack = !showStack)} + /> +
+ {#if showStack} +
+
{#each causes as cause, i}{cause?.trim?.()}{#if i < causes.length - 1}
{#each causes as cause, i}{cause?.trim?.()}{#if i < causes.length - 1}
{/if}{/each}
- {/if} +
{/if} -
- + {/if} +
diff --git a/svelte-app/src/routes/+layout.svelte b/svelte-app/src/routes/+layout.svelte index 5475d822f..b0e869ffc 100644 --- a/svelte-app/src/routes/+layout.svelte +++ b/svelte-app/src/routes/+layout.svelte @@ -52,7 +52,7 @@ clearTimeout(setLoadingTimer); if (event.from !== event.to) { - setLoadingTimer = setTimeout(() => loading.set(true), 100); + setLoadingTimer = setTimeout(() => loading.set(true), 50); } }); @@ -89,8 +89,8 @@ async (res) => (HighlightStyles = res === APP_THEMES.LIGHT - ? (await import('svelte-highlight/styles/nnfx-light')).default - : (await import('svelte-highlight/styles/night-owl')).default) + ? (await import('svelte-highlight/styles/stackoverflow-light')).default + : (await import('svelte-highlight/styles/stackoverflow-dark')).default) ) ); @@ -139,7 +139,7 @@ -
+
@@ -161,7 +161,7 @@ -
+