From ec46f08a795beda82e1289d22e13433a946179ae Mon Sep 17 00:00:00 2001 From: spences10 Date: Sat, 6 Jan 2024 07:43:31 +0000 Subject: [PATCH] refactor: :recycle: add svead as workspace package export package from svead, config prettier --- README.md | 8 ++ apps/web/package.json | 5 +- apps/web/src/lib/components/head.svelte | 107 ------------------ apps/web/src/lib/components/head.test.ts | 76 ------------- .../src/lib/components/schema-org-props.ts | 22 ---- apps/web/src/lib/components/schema-org.svelte | 39 ------- .../web/src/lib/components/schema-org.test.ts | 76 ------------- apps/web/src/lib/icons/git-hub.svelte | 12 +- apps/web/src/lib/icons/twitter.svelte | 2 +- apps/web/src/lib/icons/you-tube.svelte | 2 +- apps/web/src/lib/index.ts | 3 +- apps/web/src/lib/main-entity-types.ts | 34 ------ apps/web/src/lib/types.ts | 31 ----- apps/web/src/routes/+layout.svelte | 8 +- apps/web/src/routes/+page.svelte | 2 +- apps/web/src/routes/article/+page.svelte | 2 +- apps/web/src/routes/blog-posting/+page.svelte | 2 +- apps/web/src/routes/news-article/+page.svelte | 2 +- apps/web/src/routes/web-page/+page.svelte | 2 +- apps/web/tailwind.config.cjs | 2 +- packages/svead/.eslintrc.cjs | 14 +-- packages/svead/.prettierrc | 10 +- packages/svead/README.md | 26 +++-- packages/svead/package.json | 36 +++++- packages/svead/playwright.config.ts | 4 +- packages/svead/src/app.html | 5 +- packages/svead/src/lib/index.ts | 2 +- packages/svead/src/routes/+page.svelte | 10 +- packages/svead/svelte.config.js | 4 +- packages/svead/tests/test.ts | 4 +- packages/svead/vite.config.ts | 4 +- pnpm-lock.yaml | 5 +- 32 files changed, 125 insertions(+), 436 deletions(-) delete mode 100644 apps/web/src/lib/components/head.svelte delete mode 100644 apps/web/src/lib/components/head.test.ts delete mode 100644 apps/web/src/lib/components/schema-org-props.ts delete mode 100644 apps/web/src/lib/components/schema-org.svelte delete mode 100644 apps/web/src/lib/components/schema-org.test.ts delete mode 100644 apps/web/src/lib/main-entity-types.ts delete mode 100644 apps/web/src/lib/types.ts diff --git a/README.md b/README.md index 3d8813f..e2fd8c9 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,14 @@ npm login npm dist-tag add sveltekit-embed@0.0.13 latest ``` +## pnpm workspaces + +To add a package to the web workspace: + +```bash +pnpm add -D svead --filter web +``` + ## Contributors ✨ Thanks goes to these wonderful people diff --git a/apps/web/package.json b/apps/web/package.json index 6639d36..a7bad50 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -1,5 +1,5 @@ { - "name": "@svead/web", + "name": "web", "version": "0.0.0", "private": true, "scripts": { @@ -37,7 +37,8 @@ "prettier": "^3.1.1", "prettier-plugin-svelte": "^3.1.2", "prettier-plugin-tailwindcss": "^0.5.9", - "svelte": "^5.0.0-next.1", + "svead": "workspace:^", + "svelte": "5.0.0-next.29", "svelte-check": "^3.6.0", "tailwindcss": "^3.3.6", "tslib": "^2.4.1", diff --git a/apps/web/src/lib/components/head.svelte b/apps/web/src/lib/components/head.svelte deleted file mode 100644 index 8ca157d..0000000 --- a/apps/web/src/lib/components/head.svelte +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - {title} - - - {#if authorName} - - {/if} - - - {#if image} - - - - {/if} - - - {#if image} - - - - - - {/if} - - - {#if image} - - {#if website} - - {/if} - - - - - {/if} - - - {#if paymentPointer} - - {/if} - - - diff --git a/apps/web/src/lib/components/head.test.ts b/apps/web/src/lib/components/head.test.ts deleted file mode 100644 index 6ca2f8b..0000000 --- a/apps/web/src/lib/components/head.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { render } from '@testing-library/svelte'; -import { afterEach, describe, expect, it } from 'vitest'; -import Head from './head.svelte'; - -describe('Head', () => { - afterEach(() => { - document.head.innerHTML = ''; - }); - - it.skip('renders the correct title, description, and author', async () => { - render(Head, { - url: 'https://example.com', - title: 'Test Title', - description: 'Test Description', - authorName: 'Test Author', - }); - - const titleElement = document.head.querySelector( - 'meta[name="title"]', - ); - const descriptionElement = document.head.querySelector( - 'meta[name="description"]', - ); - const authorElement = document.head.querySelector( - 'meta[name="author"]', - ); - - expect(titleElement?.getAttribute('content')).toBe('Test Title'); - expect(descriptionElement?.getAttribute('content')).toBe( - 'Test Description', - ); - expect(authorElement?.getAttribute('content')).toBe( - 'Test Author', - ); - }); - - it.skip('renders the correct Open Graph and Twitter tags when an image is provided', async () => { - render(Head, { - url: 'https://example.com', - title: 'Test Title', - description: 'Test Description', - image: 'https://example.com/test-image.jpg', - }); - - const ogImageElement = document.head.querySelector( - 'meta[property="og:image"]', - ); - const twitterImageElement = document.head.querySelector( - 'meta[name="twitter:image"]', - ); - - expect(ogImageElement?.getAttribute('content')).toBe( - 'https://example.com/test-image.jpg', - ); - expect(twitterImageElement?.getAttribute('content')).toBe( - 'https://example.com/test-image.jpg', - ); - }); - - it.skip('renders the monetization tag when a payment pointer is provided', async () => { - render(Head, { - url: 'https://example.com', - title: 'Test Title', - description: 'Test Description', - paymentPointer: '$example.wallet/test', - }); - - const monetizationElement = document.head.querySelector( - 'meta[name="monetization"]', - ); - - expect(monetizationElement?.getAttribute('content')).toBe( - '$example.wallet/test', - ); - }); -}); diff --git a/apps/web/src/lib/components/schema-org-props.ts b/apps/web/src/lib/components/schema-org-props.ts deleted file mode 100644 index 8bc1580..0000000 --- a/apps/web/src/lib/components/schema-org-props.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { AuthorType, MainEntity } from '$lib/types'; - -export interface BreadcrumbItem { - name: string; - url: string; -} - -export interface SchemaOrgProps { - url: string; - title: string; - description: string; - website?: string; - authorName?: string; - authorType?: AuthorType; - authorUrl?: string; - image?: string; - datePublished?: string; - dateModified?: string; - language?: string; - mainEntity: MainEntity; - breadcrumbs?: BreadcrumbItem[]; -} diff --git a/apps/web/src/lib/components/schema-org.svelte b/apps/web/src/lib/components/schema-org.svelte deleted file mode 100644 index 58694a5..0000000 --- a/apps/web/src/lib/components/schema-org.svelte +++ /dev/null @@ -1,39 +0,0 @@ - - - - {@html jsonLdScript} - diff --git a/apps/web/src/lib/components/schema-org.test.ts b/apps/web/src/lib/components/schema-org.test.ts deleted file mode 100644 index 29373c2..0000000 --- a/apps/web/src/lib/components/schema-org.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { render } from '@testing-library/svelte'; -import { afterEach, describe, expect, it } from 'vitest'; -import SchemaOrg from './schema-org.svelte'; - -describe('SchemaOrg', () => { - afterEach(() => { - document.head.innerHTML = ''; - }); - - it.skip('renders the correct JSON-LD script with the provided properties', async () => { - render(SchemaOrg, { - schemaOrgProps: { - url: 'https://example.com', - title: 'Test Title', - description: 'Test Description', - authorName: 'Test Author', - authorType: 'Person', - authorUrl: 'https://example.com/authors/test-author', - image: 'https://example.com/test-image.jpg', - datePublished: '2023-04-05T10:00:00Z', - dateModified: '2023-04-05T12:00:00Z', - language: 'en', - mainEntity: { - type: 'Article', - name: 'Test Title', - url: 'https://example.com', - headline: 'Test Title', - description: 'Test Description', - image: 'https://example.com/test-image.jpg', - datePublished: '2023-04-05T10:00:00Z', - dateModified: '2023-04-05T12:00:00Z', - author: { - type: 'Person', - name: 'Test Author', - url: 'https://example.com/authors/test-author', - }, - publisher: { - type: 'Organization', - name: 'https://example.com', - logo: '', - }, - }, - breadcrumbs: [], - }, - }); - - const jsonLdScriptElement = document.head.querySelector( - 'script[type="application/ld+json"]', - ); - - if (!jsonLdScriptElement) { - throw new Error('JSON-LD script element not found'); - } - - const jsonLdContent = JSON.parse(jsonLdScriptElement.innerHTML); - - expect(jsonLdContent['@type']).toBe('Article'); - expect(jsonLdContent.name).toBe('Test Title'); - expect(jsonLdContent.url).toBe('https://example.com'); - expect(jsonLdContent.headline).toBe('Test Title'); - expect(jsonLdContent.description).toBe('Test Description'); - expect(jsonLdContent.image).toBe( - 'https://example.com/test-image.jpg', - ); - expect(jsonLdContent.datePublished).toBe('2023-04-05T10:00:00Z'); - expect(jsonLdContent.dateModified).toBe('2023-04-05T12:00:00Z'); - expect(jsonLdContent.author['@type']).toBe('Person'); - expect(jsonLdContent.author.name).toBe('Test Author'); - expect(jsonLdContent.author.url).toBe( - 'https://example.com/authors/test-author', - ); - expect(jsonLdContent.publisher['@type']).toBe('Organization'); - expect(jsonLdContent.publisher.name).toBe('https://example.com'); - expect(jsonLdContent.publisher.logo).toBe(''); - }); -}); diff --git a/apps/web/src/lib/icons/git-hub.svelte b/apps/web/src/lib/icons/git-hub.svelte index c9fded2..fa0e51a 100644 --- a/apps/web/src/lib/icons/git-hub.svelte +++ b/apps/web/src/lib/icons/git-hub.svelte @@ -1,7 +1,13 @@ diff --git a/apps/web/src/lib/icons/twitter.svelte b/apps/web/src/lib/icons/twitter.svelte index 529bac8..73780b3 100644 --- a/apps/web/src/lib/icons/twitter.svelte +++ b/apps/web/src/lib/icons/twitter.svelte @@ -4,7 +4,7 @@ viewBox="0 0 24 24" height="25" width="25" - class="fill-current text-primary-content transition hover:text-secondary-focus" + class="hover:text-secondary-focus fill-current text-primary-content transition" >