This PR adds titleDefault and titleTemplate fields that mostly match the functionality of its inspiration, next-seo. These are two fields that I found myself trying to reach for when using astro-seo but realized they weren't available. I saw the line about "feature-parity with Next SEO" mentioned in the README.md, so I figured I'd open a PR for these two fields.
PR Includes:
[x] titleTemplate
[x] titleDefault
[x] Tests
[x] Updated README.md
An example use-case for these fields would be using the <SEO /> component within a <Layout> while getting the page title via props, like so:
<!-- contact.astro -- titleTemplate example, becomes "Contact - Website Name" -->
<Layout title="Contact">
<!-- [...] page content -->
</Layout>
<!-- about.astro - titleDefault example, forgot to provide a title, fallback to "Website Name - Cool Tagline" -->
<Layout>
<!-- [...] page content -->
</Layout>
<!-- layout.astro -->
<html lang="en">
<head>
<SEO
charset="UTF-8"
title={title}
titleTemplate="%s - Website Name"
titleDefault="Website Name - Cool Tagline"
/>
</head>
<!-- [...] -->
One minor side note: I went with titleDefault instead of defaultTitle to keep it consistent with the other title prop names. Another option could be titleFallback, or defaultTitle would be fine as well.
@reaganchisholm Oh wow, I love this! Thank you for adding this and sorry for the delay in getting this merged. Will build a new version with this in it today. π
Hi there ππ»
This PR adds
titleDefault
andtitleTemplate
fields that mostly match the functionality of its inspiration,next-seo
. These are two fields that I found myself trying to reach for when usingastro-seo
but realized they weren't available. I saw the line about "feature-parity with Next SEO" mentioned in the README.md, so I figured I'd open a PR for these two fields.PR Includes:
An example use-case for these fields would be using the
<SEO />
component within a<Layout>
while getting the page title via props, like so:One minor side note: I went with
titleDefault
instead ofdefaultTitle
to keep it consistent with the other title prop names. Another option could betitleFallback
, ordefaultTitle
would be fine as well.