diff options
Diffstat (limited to 'examples/docs/src/layouts/Main.astro')
-rw-r--r-- | examples/docs/src/layouts/Main.astro | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/examples/docs/src/layouts/Main.astro b/examples/docs/src/layouts/Main.astro index 0f1e6efe4..a92ffaff4 100644 --- a/examples/docs/src/layouts/Main.astro +++ b/examples/docs/src/layouts/Main.astro @@ -1,16 +1,23 @@ --- +// Component Imports import ArticleFooter from '../components/ArticleFooter.astro'; import SiteSidebar from '../components/SiteSidebar.astro'; import ThemeToggle from '../components/ThemeToggle.tsx'; import DocSidebar from '../components/DocSidebar.tsx'; +// Component Script: +// You can write any JavaScript/TypeScript that you'd like here. +// It will run during the build, but never in the browser. +// All variables are available to use in the HTML template below. const { content } = Astro.props; const headers = content?.astro?.headers; -let editHref = Astro?.request?.url?.pathname?.slice(1) ?? ''; -if (editHref === '') editHref = `index`; -editHref = `https://github.com/snowpackjs/astro/tree/main/examples/doc/src/pages/${editHref}.md` ---- +const currentPage = Astro.request.url.pathname; +const currentFile = currentPage === '/' ? 'src/pages/index.md' : `src/pages${currentPage.replace(/\/$/, "")}.md`; +const githubEditUrl = `https://github.com/USER/REPO/blob/main/${currentFile}` +// Full Astro Component Syntax: +// https://github.com/snowpackjs/astro/blob/main/docs/core-concepts/astro-components.md +--- <html> <head> <title>{content.title}</title> |