From 8f74b3bdbb1cae31e036daf1b7f5fc28686ddd4d Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Thu, 1 Jul 2021 05:43:02 -0700 Subject: update example astro inline docs (#592) --- examples/docs/src/layouts/Main.astro | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'examples/docs/src') 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 +--- {content.title} -- cgit v1.2.3