From 358c1fcf9cf7905a32f1cf13b1d86effcced054f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Dur=C3=A1n?= Date: Thu, 13 Jul 2023 20:26:51 +0200 Subject: [PATCH] Add url --- web/astro.config.mjs | 2 +- web/src/components/BlogPostMeta.astro | 90 --------------------------- web/src/lib/seo.ts | 70 --------------------- 3 files changed, 1 insertion(+), 161 deletions(-) delete mode 100644 web/src/components/BlogPostMeta.astro diff --git a/web/astro.config.mjs b/web/astro.config.mjs index bac3572..02a1056 100644 --- a/web/astro.config.mjs +++ b/web/astro.config.mjs @@ -17,7 +17,7 @@ const SERVER_PORT = 3000; // the url to access your blog during local development const LOCALHOST_URL = `http://localhost:${SERVER_PORT}`; // the url to access your blog after deploying it somewhere (Eg. Netlify) -const LIVE_URL = "https://yourwebsiteurl.com"; +const LIVE_URL = "https://pruebastecnicas.com"; // this is the astro command your npm script runs const SCRIPT = process.env.npm_lifecycle_script || ""; const isBuild = SCRIPT.includes("astro build"); diff --git a/web/src/components/BlogPostMeta.astro b/web/src/components/BlogPostMeta.astro deleted file mode 100644 index 149a24a..0000000 --- a/web/src/components/BlogPostMeta.astro +++ /dev/null @@ -1,90 +0,0 @@ ---- -import { getBlogPostMeta } from "../lib/seo"; -import { - SITE_TITLE, - SITE_DESCRIPTION, - SITE_URL, - TWITTER_HANDLE, - MY_NAME, -} from "../config"; - -export interface Props { - title?: string; - description?: string; - publishDate: string; - pagePath?: string; - ogImageAbsoluteUrl?: string; - ogImageAltText?: string; - ogImageWidth?: number; - ogImageHeight?: number; -} - -const { - title, - description, - publishDate, - pagePath, - ogImageAbsoluteUrl, - ogImageAltText, - ogImageWidth, - ogImageHeight, -} = Astro.props; - -const { meta, og, twitter } = getBlogPostMeta({ - title: title || SITE_TITLE, - description: description || SITE_DESCRIPTION, - pageUrl: pagePath ? new URL(pagePath, SITE_URL).toString() : undefined, - authorName: MY_NAME, - publishDate, - ogImageAbsoluteUrl, - ogImageAltText, - ogImageWidth, - ogImageHeight, - siteOwnerTwitterHandle: TWITTER_HANDLE, - contentAuthorTwitterHandle: TWITTER_HANDLE, -}); ---- - - -{meta.title} - -{meta.description && } -{meta.canonicalUrl && } - - -{og.title && } -{og.description && } -{og.type && } -{og.url && } -{og.author && } -{ - og.publishDate && ( - - ) -} -{og.image && } -{og.imageAlt && } -{og.imageWidth && } -{og.imageHeight && } - - -{twitter.title && } -{ - twitter.description && ( - - ) -} -{twitter.site && } -{ - twitter.creator && ( - - ) -} - -{twitter.image && } -{ - twitter.imageAlt && ( - - ) -} - diff --git a/web/src/lib/seo.ts b/web/src/lib/seo.ts index b12b3aa..a0005ac 100644 --- a/web/src/lib/seo.ts +++ b/web/src/lib/seo.ts @@ -110,73 +110,3 @@ export function getPageMeta({ twitter, }; } - -export function getBlogPostMeta({ - title: pageTitle, - description, - canonicalUrl, - pageUrl, - authorName, - publishDate, - ogImageAbsoluteUrl, - ogImageAltText, - ogImageWidth, - ogImageHeight, - siteOwnerTwitterHandle, - contentAuthorTwitterHandle, -}: { - title: string; - description: string; - canonicalUrl?: string; - pageUrl?: string; - authorName?: string; - publishDate: string; - ogImageAbsoluteUrl?: string; // should always be absolute - ogImageAltText?: string; - ogImageWidth?: number; - ogImageHeight?: number; - siteOwnerTwitterHandle?: string; - contentAuthorTwitterHandle?: string; -}): { meta: PageMeta; og: BlogPostOgMeta; twitter: BlogPostTwitterMeta } { - if (!pageTitle) { - throw Error("title is required for page SEO"); - } - if (ogImageAbsoluteUrl && !ogImageAltText) { - ogImageAltText = `Preview image for ${pageTitle}`; - } - - const meta: PageMeta = { - title: pageTitle, - description: description, - canonicalUrl, - }; - - const og: BlogPostOgMeta = { - title: pageTitle, - description: description, - type: "article", - url: pageUrl, - author: authorName, - publishDate: publishDate, - image: ogImageAbsoluteUrl, - imageAlt: ogImageAltText, - imageWidth: ogImageWidth ? String(ogImageWidth) : undefined, - imageHeight: ogImageHeight ? String(ogImageHeight) : undefined, - }; - - const twitter: BlogPostTwitterMeta = { - title: pageTitle, - description: description, - card: "summary_large_image", - site: siteOwnerTwitterHandle, - creator: contentAuthorTwitterHandle || siteOwnerTwitterHandle, - image: ogImageAbsoluteUrl, - imageAlt: ogImageAltText, - }; - - return { - meta, - og, - twitter, - }; -}