mirror of
https://github.com/BradNut/personal-website-sveltekit
synced 2025-09-08 23:20:18 +00:00
Make SEO reactive and remove console logs, add types for returns.
This commit is contained in:
parent
0e1ce7cc4a
commit
c322ce6b33
3 changed files with 19 additions and 26 deletions
|
|
@ -9,12 +9,12 @@
|
||||||
siteUrl,
|
siteUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
export let title: string;
|
export let title = defaultMetadata.defaultTitle;
|
||||||
export let description = defaultMetadata.defaultDescription;
|
export let description = defaultMetadata.defaultDescription;
|
||||||
export let image = defaultMetadata.defaultImage;
|
export let image = defaultMetadata.defaultImage;
|
||||||
export let location: string = '';
|
export let location: string = '';
|
||||||
|
|
||||||
const seo = {
|
$: seo = {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
image: `${siteUrl}${image}`,
|
image: `${siteUrl}${image}`,
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,19 @@
|
||||||
import type { PageServerLoad } from './$types';
|
import type { PageServerLoad } from './$types';
|
||||||
import type { Article } from '$root/lib/types/article';
|
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 }) => {
|
export const load: PageServerLoad = async ({ fetch, params }) => {
|
||||||
const { page } = params;
|
const { page } = params;
|
||||||
const resp = await fetch(`/api/articles?page=${page}`);
|
const resp = await fetch(`/api/articles?page=${page}`);
|
||||||
const {
|
const { articles, currentPage, totalPages, limit, totalArticles }: ArticlePageLoad =
|
||||||
articles,
|
await resp.json();
|
||||||
currentPage,
|
|
||||||
totalPages,
|
|
||||||
limit,
|
|
||||||
totalArticles
|
|
||||||
}: {
|
|
||||||
articles: Article[];
|
|
||||||
currentPage: number;
|
|
||||||
totalPages: number;
|
|
||||||
limit: number;
|
|
||||||
totalArticles: number;
|
|
||||||
} = await resp.json();
|
|
||||||
return {
|
return {
|
||||||
articles,
|
articles,
|
||||||
currentPage,
|
currentPage,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from "$app/stores";
|
|
||||||
import { articleStore } from "$lib/stores/articleStore";
|
|
||||||
import { ArticleTag } from "$lib/types/articleTag";
|
|
||||||
import Pagination from "$lib/components/pagination/index.svelte";
|
import Pagination from "$lib/components/pagination/index.svelte";
|
||||||
import SEO from "$root/lib/components/SEO.svelte";
|
import SEO from "$root/lib/components/SEO.svelte";
|
||||||
import type { Article } from "$root/lib/types/article";
|
import type { Article } from "$root/lib/types/article";
|
||||||
|
|
@ -9,15 +6,14 @@
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
let articles: Article[];
|
let articles: Article[];
|
||||||
|
let currentPage: number;
|
||||||
|
let totalPages: number;
|
||||||
|
let totalArticles: number;
|
||||||
|
let limit: number;
|
||||||
$: ({ articles, currentPage, totalPages, totalArticles, limit } = data);
|
$: ({ articles, currentPage, totalPages, totalArticles, limit } = data);
|
||||||
console.log(`Article +page currentPage: ${currentPage}`);
|
|
||||||
console.log({ articles, currentPage, totalPages, totalArticles, limit });
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<SEO title={`Tech Articles - Page ${currentPage}`} />
|
||||||
<title>{`Tech Articles - Page ${currentPage} | Bradley Shellnut`}</title>
|
|
||||||
<meta name="og:site_name" content={`Tech Articles - Page ${currentPage}`} />
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<div class="pageStyles">
|
<div class="pageStyles">
|
||||||
<h1 style="margin-bottom: 2rem">Favorite Tech Articles</h1>
|
<h1 style="margin-bottom: 2rem">Favorite Tech Articles</h1>
|
||||||
|
|
@ -26,7 +22,7 @@
|
||||||
pageSize={limit}
|
pageSize={limit}
|
||||||
totalCount={totalArticles}
|
totalCount={totalArticles}
|
||||||
currentPage={currentPage || 1}
|
currentPage={currentPage || 1}
|
||||||
skip={page}
|
skip={currentPage}
|
||||||
base="/articles"
|
base="/articles"
|
||||||
/>
|
/>
|
||||||
<div class="articlesStyles">
|
<div class="articlesStyles">
|
||||||
|
|
@ -61,7 +57,7 @@
|
||||||
pageSize={limit}
|
pageSize={limit}
|
||||||
totalCount={totalPages}
|
totalCount={totalPages}
|
||||||
currentPage={currentPage || 1}
|
currentPage={currentPage || 1}
|
||||||
skip={page}
|
skip={currentPage}
|
||||||
base="/articles"
|
base="/articles"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue