summaryrefslogtreecommitdiff
path: root/docs/src/layouts/MainLayout.astro
diff options
context:
space:
mode:
authorGravatar Caleb Jasik <calebjasik@jasik.xyz> 2021-08-23 15:08:20 -0500
committerGravatar GitHub <noreply@github.com> 2021-08-23 15:08:20 -0500
commit2fd004dcd99c09fc8eae423c24b31313568f039f (patch)
treeeb41923e718e63eea6ec3d40084e377a88b534e7 /docs/src/layouts/MainLayout.astro
parent3963cef96378cdb464499dd5d878077544849e22 (diff)
downloadastro-2fd004dcd99c09fc8eae423c24b31313568f039f.tar.gz
astro-2fd004dcd99c09fc8eae423c24b31313568f039f.tar.zst
astro-2fd004dcd99c09fc8eae423c24b31313568f039f.zip
Add a `titleClosure` to the `HeadSEO.astro` component (#1140)
* Testing out adding a `titleClosure` to the `HeadSEO.astro` component I think the api needs a bit of improvement, but the basic idea is you can pass this in to a published astro component for specifying how you want it to format your title! * Refactor to make it pretty * Rename the `titleClosure()` prop to `formatTitle()` to be more clear * Use title, with site title as the fallback (#1143) See og:title guidance (https://developers.facebook.com/docs/sharing/webmasters/) Co-authored-by: Jonathan Neal <jonathantneal@hotmail.com>
Diffstat (limited to 'docs/src/layouts/MainLayout.astro')
-rw-r--r--docs/src/layouts/MainLayout.astro3
1 files changed, 2 insertions, 1 deletions
diff --git a/docs/src/layouts/MainLayout.astro b/docs/src/layouts/MainLayout.astro
index bfee61cd9..45eab6d0f 100644
--- a/docs/src/layouts/MainLayout.astro
+++ b/docs/src/layouts/MainLayout.astro
@@ -12,13 +12,14 @@ const { content = {} } = Astro.props;
const currentPage = Astro.request.url.pathname;
const currentFile = `src/pages${currentPage.replace(/\/$/, "")}.md`;
const githubEditUrl = `https://github.com/snowpackjs/astro/blob/main/docs/${currentFile}`;
+const formatTitle = (content, SITE) => content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title;
---
<html dir="{content.dir ?? 'ltr'}" lang="{content.lang ?? 'en-us'}" class="initial">
<head>
<HeadCommon />
<HeadSEO {content} canonicalURL={Astro.request.canonicalURL} />
- <title>{content.title ? `${content.title} 🚀 ${SITE.title}` : SITE.title}</title>
+ <title>{formatTitle(content, SITE)}</title>
<style>
body {
width: 100%;