diff --git a/package.json b/package.json index 034e38d..79ea906 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@playwright/test": "^1.28.1", "@rgossiaux/svelte-headlessui": "^1.0.2", "@sveltejs/adapter-auto": "^1.0.0", + "@sveltejs/adapter-static": "^2.0.0", "@sveltejs/adapter-vercel": "^1.0.5", "@sveltejs/kit": "^1.0.0", "@types/postcss-preset-env": "^8.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 53a0e4f..cdc50fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,6 +9,7 @@ specifiers: '@playwright/test': ^1.28.1 '@rgossiaux/svelte-headlessui': ^1.0.2 '@sveltejs/adapter-auto': ^1.0.0 + '@sveltejs/adapter-static': ^2.0.0 '@sveltejs/adapter-vercel': ^1.0.5 '@sveltejs/kit': ^1.0.0 '@types/postcss-preset-env': ^8.0.0 @@ -48,6 +49,7 @@ devDependencies: '@playwright/test': 1.29.2 '@rgossiaux/svelte-headlessui': 1.0.2_svelte@3.55.1 '@sveltejs/adapter-auto': 1.0.2_@sveltejs+kit@1.2.2 + '@sveltejs/adapter-static': 2.0.0_@sveltejs+kit@1.2.2 '@sveltejs/adapter-vercel': 1.0.5_@sveltejs+kit@1.2.2 '@sveltejs/kit': 1.2.2_svelte@3.55.1+vite@4.0.4 '@types/postcss-preset-env': 8.0.0_postcss@8.4.21 @@ -696,6 +698,14 @@ packages: import-meta-resolve: 2.2.1 dev: true + /@sveltejs/adapter-static/2.0.0_@sveltejs+kit@1.2.2: + resolution: {integrity: sha512-M9F8EyCIdVcpZu0zvS7U7v+rc7elNNDUkMHLsOkJYlfQ9rDdif3fqteMqddcrq1lFPEGH1ErdTjpsXdb3k1e8w==} + peerDependencies: + '@sveltejs/kit': ^1.5.0 + dependencies: + '@sveltejs/kit': 1.2.2_svelte@3.55.1+vite@4.0.4 + dev: true + /@sveltejs/adapter-vercel/1.0.5_@sveltejs+kit@1.2.2: resolution: {integrity: sha512-TnFw+2ZwUuzguIeh013h0eiFmHylBuL1aV3jcUWbJmBLRo6YA0Ti8X8VXgFP4izP7XGuLKdpUIMg7HaZe21LbA==} peerDependencies: diff --git a/src/lib/components/SEO.svelte b/src/lib/components/SEO.svelte index 0c9e83f..74ec8a7 100644 --- a/src/lib/components/SEO.svelte +++ b/src/lib/components/SEO.svelte @@ -14,7 +14,7 @@ export let image = defaultMetadata.defaultImage; export let location: string = ''; - const seo = { + $: seo = { title, description, image: `${siteUrl}${image}`, @@ -23,7 +23,7 @@ - {`${seo.title} - ${defaultMetadata.defaultTitle}`} + {`${seo.title} | ${defaultMetadata.defaultTitle}`} diff --git a/src/lib/components/footer/index.svelte b/src/lib/components/footer/index.svelte index 73f0bb3..51aadec 100644 --- a/src/lib/components/footer/index.svelte +++ b/src/lib/components/footer/index.svelte @@ -16,7 +16,7 @@ Portfolio Uses Privacy - Favorite Articles + Favorite Articles

diff --git a/src/lib/components/pagination/index.svelte b/src/lib/components/pagination/index.svelte new file mode 100644 index 0000000..29803fa --- /dev/null +++ b/src/lib/components/pagination/index.svelte @@ -0,0 +1,78 @@ + + +

+ + ← Prev + + {#each { length: totalPages } as _, i} + + {i + 1} + + {/each} + + Next → + +
+ + \ No newline at end of file diff --git a/src/lib/stores/articleStore.ts b/src/lib/stores/articleStore.ts index 927fa38..f782b60 100644 --- a/src/lib/stores/articleStore.ts +++ b/src/lib/stores/articleStore.ts @@ -6,6 +6,7 @@ const state = () => { const { subscribe, set, update } = writable([]); function addAll(articles: Article[]) { + // console.log(typeof articles); for (const article of articles) { add(article); } diff --git a/src/lib/types/pageQuery.ts b/src/lib/types/pageQuery.ts index f03201a..57bfb5f 100644 --- a/src/lib/types/pageQuery.ts +++ b/src/lib/types/pageQuery.ts @@ -1,5 +1,8 @@ -export type PageQuery { +export type PageQuery = { sort: string; perPage: number; since: number; -} \ No newline at end of file + page: number; + tags: string; + content: 'metadata' | 'full'; +}; diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts deleted file mode 100644 index ca7eae2..0000000 --- a/src/routes/+layout.server.ts +++ /dev/null @@ -1,24 +0,0 @@ -export const prerender = true; -import { type ServerLoad } from '@sveltejs/kit'; - -export const load: ServerLoad = async ({ isDataRequest, cookies, params, setHeaders }) => { - const queryParams = { - // ids: `${params?.id}`, - // fields: - // 'id,name,price,min_age,min_players,max_players,thumb_url,playtime,min_playtime,max_playtime,min_age,description,year_published,url,image_url' - }; - - const initialRequest = !isDataRequest; - console.log(`Is initialRequest: ${initialRequest}`); - - const cacheValue = `${initialRequest ? +new Date() : cookies.get('articles-cache')}`; - console.log(`Cache Value: ${cacheValue}`); - - if (initialRequest) { - cookies.set('articles-cache', cacheValue, { path: '/', httpOnly: false }); - } - - return { - articlesCacheBust: cacheValue - }; -}; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 243f824..3c58e7f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,8 +1,7 @@ - - - -
-

Favorite Tech Articles

- -
- {#each articles as article (article.hashed_url)} -
-
-

- - {article.title} - -

-
-
-

Reading time: {article.reading_time} minutes

-
-

Tags:

- {#each article.tags as tag} -

{tag}

- {/each} -
-
-
- {/each} -
- -
- - \ No newline at end of file +

Articles

\ No newline at end of file diff --git a/src/routes/articles/+page.ts b/src/routes/articles/+page.ts index e0445d4..4f6aabd 100644 --- a/src/routes/articles/+page.ts +++ b/src/routes/articles/+page.ts @@ -1,17 +1,6 @@ -import { getCurrentCookieValue } from '$lib/util/cookieUtils'; -import type { Article } from '$root/lib/types/article'; -import type { PageLoad } from './$types'; +import { redirect } from '@sveltejs/kit'; +import type { PageServerLoad } from './$types'; -export const load: PageLoad = async ({ fetch, parent, url, setHeaders }) => { - const parentData = await parent(); - - const cacheBust = getCurrentCookieValue('articles-cache') || parentData.articlesCacheBust; - // const search = url.searchParams.get('search') || ''; - - const resp = await fetch(`/api/articles?cache=${cacheBust}`); - const articles: Article[] = await resp.json(); - - return { - articles - }; +export const load = async () => { + throw redirect(302, '/articles/1'); }; diff --git a/src/routes/articles/[page]/+page.server.ts b/src/routes/articles/[page]/+page.server.ts new file mode 100644 index 0000000..2440a62 --- /dev/null +++ b/src/routes/articles/[page]/+page.server.ts @@ -0,0 +1,24 @@ +import type { PageServerLoad } from './$types'; +import type { Article } from '$root/lib/types/article'; + +export type ArticlePageLoad = { + articles: Article[]; + currentPage: number; + totalPages: number; + limit: number; + totalArticles: number; +}; + +export const load: PageServerLoad = async ({ fetch, params }) => { + const { page } = params; + const resp = await fetch(`/api/articles?page=${page}`); + const { articles, currentPage, totalPages, limit, totalArticles }: ArticlePageLoad = + await resp.json(); + return { + articles, + currentPage, + totalPages, + limit, + totalArticles + }; +}; diff --git a/src/routes/articles/[page]/+page.svelte b/src/routes/articles/[page]/+page.svelte new file mode 100644 index 0000000..44052ad --- /dev/null +++ b/src/routes/articles/[page]/+page.svelte @@ -0,0 +1,123 @@ + + + + +
+

Favorite Tech Articles

+ +
+ {#each articles as article (article.hashed_url)} +
+
+

+ + {article.title} + +

+
+
+

Reading time: {article.reading_time} minutes

+
+

Tags:

+ {#each article.tags as tag} +

{tag}

+ {/each} +
+
+
+ {/each} +
+ +
+ + \ No newline at end of file diff --git a/src/routes/portfolio/+page.server.ts b/src/routes/portfolio/+page.server.ts deleted file mode 100644 index 189f71e..0000000 --- a/src/routes/portfolio/+page.server.ts +++ /dev/null @@ -1 +0,0 @@ -export const prerender = true; diff --git a/src/routes/privacy/+page.server.ts b/src/routes/privacy/+page.server.ts deleted file mode 100644 index 189f71e..0000000 --- a/src/routes/privacy/+page.server.ts +++ /dev/null @@ -1 +0,0 @@ -export const prerender = true; diff --git a/src/routes/privacy/+page.svelte b/src/routes/privacy/+page.svelte index 48201e6..8ad688c 100644 --- a/src/routes/privacy/+page.svelte +++ b/src/routes/privacy/+page.svelte @@ -5,216 +5,217 @@
-
-

Privacy

-

- Long story short, I believe everyone should know who has your personal - data, how it is being collected/stored, and what it is being used for. -

-

- However, it is ultimately up to each person to determine how much data - they are willing to give to any business/entity. -

-

- For the sake of transparency I am using{' '} +

Privacy

+

+ Long story short, I believe everyone should know who has your personal + data, how it is being collected/stored, and what it is being used for. +

+

+ However, it is ultimately up to each person to determine how much data + they are willing to give to any business/entity. +

+

+ For the sake of transparency I am using{' '} + + Umami Analytics + {' '} + to anonymously track visits to my site. You can completely block this + if you want by either using an AdBlocker like{' '} + + uBlock Origin + {' '} + and/or set your browser to send "Do Not Track" requests as I honor + them. +

+
+
+

Useful Resources

+

+ Here are a few sites/lists of privacy oriented software for you to + check out: +

+ +
+
+

Privacy Centric Paid Services I use:

+ +
+
+

NAS Servers for Self Hosting:

+
    +
  • + + Synology + + : An easy, not cheap, local solution for Google Services like Drive, + Drive, Photos, Calendar, other services using Docker, etc. (Yes I + should use{' '} + + NextCloud + + ...maybe eventually) +
  • +
  • + Mac Mini: Used as a{' '} + + Plex Server {' '} - and/or set your browser to send "Do Not Track" requests as I honor - them. -

    -
-
-

Useful Resources

-

- Here are a few sites/lists of privacy oriented software for you to - check out: -

- -
-
-

Privacy Centric Paid Services I use:

- -
-
-

NAS Servers for Self Hosting:

-
    -
  • - - Synology - - : An easy, not cheap, local solution for Google Services like Drive, - Drive, Photos, Calendar, other services using Docker, etc. (Yes I - should use{' '} - - NextCloud - - ...maybe eventually) -
  • -
  • - Mac Mini: Used as a{' '} - - Plex Server - {' '} - for my Movies/TV/Music until I build a dedicated NAS and maybe - switch to{' '} - - JellyFin - {' '} - once it is more mature. -
  • -
-
-
-

Software Deployed:

- -
+ for my Movies/TV/Music until I build a dedicated NAS and maybe + switch to{' '} + + JellyFin + {' '} + once it is more mature. + + +
+
+

Software Deployed:

+
\ No newline at end of file diff --git a/src/routes/uses/+page.server.ts b/src/routes/uses/+page.server.ts deleted file mode 100644 index 189f71e..0000000 --- a/src/routes/uses/+page.server.ts +++ /dev/null @@ -1 +0,0 @@ -export const prerender = true;