Skip to content

Commit

Permalink
chore: try to improve edit this page link
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Mar 25, 2024
1 parent 314c556 commit c3163dd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import netlifyLogo from '@images/footer/netlify.svg';
const sha = import.meta.env.COMMIT_REF?.substring(0, 8) ?? 'dev';
const removeSlash = (path: string) => path.replace(/\/$/, '');
const formatUrl = (path: string) => {
path = path.replace(/\/$/, '');
if (path.includes('/blog/')) {
path = path.replace('/blog/', 'content/blog/');
return `pages${path}.md`;
} else {
return `pages${path}.astro`;
}
};
---

<section>
Expand Down Expand Up @@ -136,7 +144,7 @@ const removeSlash = (path: string) => path.replace(/\/$/, '');
</li>
<li>
<a
href={`https://github.com/agrc/gis.utah.gov/tree/main/src/pages${removeSlash(Astro.url.pathname)}.astro`}
href={`https://github.com/agrc/gis.utah.gov/tree/main/src/${formatUrl(Astro.url.pathname)}`}
class="custom-style rounded hover:underline focus:outline-none focus:ring-1 focus:ring-accent"
>Edit this page</a
>
Expand Down

0 comments on commit c3163dd

Please sign in to comment.