diff options
author | 2022-07-21 10:45:59 -0700 | |
---|---|---|
committer | 2022-07-21 13:45:59 -0400 | |
commit | ddefb172f66bcd646dd0b75a7ea8360157dd2ba0 (patch) | |
tree | a43eb2a6a7cadf867e3f333e09ebac51974b1438 /examples/docs/src/layouts/MainLayout.astro | |
parent | d503c5bf3db39afeecb28522861ac5d78c919408 (diff) | |
download | astro-ddefb172f66bcd646dd0b75a7ea8360157dd2ba0.tar.gz astro-ddefb172f66bcd646dd0b75a7ea8360157dd2ba0.tar.zst astro-ddefb172f66bcd646dd0b75a7ea8360157dd2ba0.zip |
Replace/Rename Astro.canonicalURL with new Astro.url helper (#3959)
* add Astro.url
* Add examples of how to create the canonicalURL
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Diffstat (limited to 'examples/docs/src/layouts/MainLayout.astro')
-rw-r--r-- | examples/docs/src/layouts/MainLayout.astro | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/docs/src/layouts/MainLayout.astro b/examples/docs/src/layouts/MainLayout.astro index e9812acdd..93ba323e4 100644 --- a/examples/docs/src/layouts/MainLayout.astro +++ b/examples/docs/src/layouts/MainLayout.astro @@ -9,7 +9,8 @@ import RightSidebar from "../components/RightSidebar/RightSidebar.astro"; import * as CONFIG from "../config"; const { content = {} } = Astro.props; -const currentPage = new URL(Astro.request.url).pathname; +const canonicalURL = new URL(Astro.url.pathname, Astro.site); +const currentPage = Astro.url.pathname; const currentFile = `src/pages${currentPage.replace(/\/$/, "")}.md`; const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + currentFile; --- @@ -17,7 +18,7 @@ const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + current <html dir={content.dir ?? "ltr"} lang={content.lang ?? "en-us"} class="initial"> <head> <HeadCommon /> - <HeadSEO {content} canonicalURL={Astro.canonicalURL} /> + <HeadSEO {content} canonicalURL={canonicalURL} /> <title>{content.title ? `${content.title} 🚀 ${CONFIG.SITE.title}` : CONFIG.SITE.title}</title> <style> body { |