Skip to content

Commit

Permalink
Refactor SEO components
Browse files Browse the repository at this point in the history
Fixes #848
  • Loading branch information
maiertech committed Jul 28, 2024
1 parent ae3b438 commit 25f9ec3
Show file tree
Hide file tree
Showing 16 changed files with 209 additions and 344 deletions.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"format": "prettier --write ."
},
"devDependencies": {
"@maiertech/sveltekit-helpers": "^0.7.0",
"@playwright/test": "^1.45.2",
"@maiertech/sveltekit-helpers": "^0.9.0",
"@playwright/test": "^1.45.3",
"@sindresorhus/slugify": "^2.2.1",
"@stackblitz/sdk": "^1.11.0",
"@sveltejs/adapter-vercel": "^5.4.1",
Expand All @@ -22,23 +22,22 @@
"@types/rss": "^0.0.32",
"@unpic/svelte": "^0.0.53",
"@vercel/analytics": "^1.3.1",
"eslint": "^9.7.0",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^48.8.0",
"eslint-plugin-jsdoc": "^48.8.3",
"eslint-plugin-svelte": "^2.43.0",
"globals": "^15.8.0",
"iconify-icon": "^2.1.0",
"open-props": "^1.7.5",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"rss": "^1.2.2",
"schema-dts": "^1.1.2",
"svelte": "^4.2.18",
"svelte-check": "^3.8.4",
"svelte-highlight": "^7.7.0",
"sveltekit-embed": "^0.0.12",
"typescript": "^5.5.3",
"vite": "^5.3.4",
"typescript": "^5.5.4",
"vite": "^5.3.5",
"zod": "^3.23.8"
},
"type": "module"
Expand Down
372 changes: 180 additions & 192 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {
// seo: SeoData;
// }
interface PageData {
seo: SeoData;
}
// interface PageState {}
// interface Platform {}
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ export { default as Header } from './header.svelte';
export { default as Image } from './image.svelte';
export { default as PostPreview } from './post-preview.svelte';
export { default as Posts } from './posts.svelte';
export { default as SeoHomepageSupplement } from './seo-homepage-supplement.svelte';
export { default as Seo } from './seo.svelte';
22 changes: 0 additions & 22 deletions src/lib/components/seo-homepage-supplement.svelte

This file was deleted.

33 changes: 0 additions & 33 deletions src/lib/components/seo-post-supplement.svelte

This file was deleted.

3 changes: 0 additions & 3 deletions src/lib/components/seo-website-supplement.svelte

This file was deleted.

29 changes: 0 additions & 29 deletions src/lib/components/seo.svelte

This file was deleted.

12 changes: 3 additions & 9 deletions src/lib/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { linkSchema, seoSchema, subscribeFormSchema } from '$lib/schemas';
import { EmbedOptions, Project } from '@stackblitz/sdk';
import { BlogPosting, WebSite, WithContext } from 'schema-dts';
import type { linkSchema, seoSchema, subscribeFormSchema } from '$lib/schemas';
import type { EmbedOptions, Project } from '@stackblitz/sdk';
import type { ComponentType } from 'svelte';
import { z } from 'zod';
import type { z } from 'zod';

// Inferred from local schemas.

export type SeoData = z.infer<typeof seoSchema>;
export type SubscribeForm = z.infer<typeof subscribeFormSchema>;

// Schema.org

export type BlogPosting = WithContext<BlogPosting>;
export type WebSite = WithContext<WebSite>;

// Other types.

export type Color = 'brand' | 'accent';
Expand Down
8 changes: 0 additions & 8 deletions src/lib/utils/decorate.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/lib/utils/serialize.js

This file was deleted.

7 changes: 0 additions & 7 deletions src/routes/(pages)/+layout.svelte

This file was deleted.

4 changes: 1 addition & 3 deletions src/routes/(pages)/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<script>
import { Button, Posts, SeoHomepageSupplement } from '$lib/components';
import { Button, Posts } from '$lib/components';
export let data;
</script>

<SeoHomepageSupplement name={data.seo.title} url={data.canonical_origin} />

<section class="about">
<p>{data.seo.description}</p>
</section>
Expand Down
5 changes: 3 additions & 2 deletions src/routes/(posts)/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script>
import SeoPostSupplement from '$lib/components/seo-post-supplement.svelte';
import { SeoLdPost, SeoFediverseCreator } from '@maiertech/sveltekit-helpers';
import { ContentLayout, PostHeader } from '@maiertech/sveltekit-helpers';
export let data;
</script>

<SeoPostSupplement data={data.resolvedPost} />
<SeoLdPost post={data.resolvedPost} />
<SeoFediverseCreator username="@thilo@maier.social" />

<ContentLayout>
<PostHeader post={data.resolvedPost} slot="header" />
Expand Down
8 changes: 0 additions & 8 deletions src/routes/+layout.js

This file was deleted.

19 changes: 13 additions & 6 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<script>
import { dev } from '$app/environment';
import { page } from '$app/stores';
import { Favicon, Footer, Header, Seo } from '$lib/components';
import { Container, PageLayout } from '@maiertech/sveltekit-helpers';
import { Favicon, Footer, Header } from '$lib/components';
import {
Container,
PageLayout,
SeoBasic,
SeoCanonicalUrl,
SeoOgImage
} from '@maiertech/sveltekit-helpers';
import { inject } from '@vercel/analytics';
import { PUBLIC_CANONICAL_ORIGIN } from '$env/static/public';
import 'open-props/borders';
import 'open-props/fonts';
Expand All @@ -14,13 +21,13 @@
import '$lib/theme.css';
import '@maiertech/sveltekit-helpers/styles.css';
export let data;
inject({ mode: dev ? 'development' : 'production' });
</script>

{#if !$page.error}
<Seo url={$page.url} canonical_origin={data.canonical_origin} data={$page.data.seo} />
<SeoBasic title={$page.data.seo.title} description={$page.data.seo.description} />
<SeoCanonicalUrl origin={PUBLIC_CANONICAL_ORIGIN} canonicalUrl={$page.data.seo.canonical_url} />
{#if $page.data.seo.og_image_url}
<SeoOgImage ogImageUrl={$page.data.seo.og_image_url} />
{/if}

<Favicon />
Expand Down

0 comments on commit 25f9ec3

Please sign in to comment.