diff options
author | 2021-07-01 05:43:02 -0700 | |
---|---|---|
committer | 2021-07-01 08:43:02 -0400 | |
commit | 8f74b3bdbb1cae31e036daf1b7f5fc28686ddd4d (patch) | |
tree | ef46c13328abae62209ad30d49401285f5f72a01 /examples/docs/src/layouts/Main.astro | |
parent | 6a660f1b08430fe6e8f0e0939220511827cb0bc0 (diff) | |
download | astro-8f74b3bdbb1cae31e036daf1b7f5fc28686ddd4d.tar.gz astro-8f74b3bdbb1cae31e036daf1b7f5fc28686ddd4d.tar.zst astro-8f74b3bdbb1cae31e036daf1b7f5fc28686ddd4d.zip |
update example astro inline docs (#592)
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> |