admin layout redesign
This commit is contained in:
@@ -7,56 +7,32 @@ interface Props {
|
||||
}
|
||||
|
||||
const { title, wide = false } = Astro.props;
|
||||
|
||||
if (Astro.cookies.get('admin_session')?.value !== '1') {
|
||||
return Astro.redirect('/admin/login');
|
||||
}
|
||||
---
|
||||
|
||||
<Layout title={title} wide={wide}>
|
||||
<Fragment slot="head">
|
||||
<script is:inline>
|
||||
(function () {
|
||||
try {
|
||||
var authed = document.cookie.split(';').some(function (c) {
|
||||
return c.trim().indexOf('admin_session=1') === 0;
|
||||
});
|
||||
if (!authed) {
|
||||
window.location.replace('/admin/login');
|
||||
return;
|
||||
}
|
||||
document.documentElement.classList.add('admin-authed');
|
||||
} catch (e) {
|
||||
window.location.replace('/admin/login');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</Fragment>
|
||||
|
||||
<div class="glass p-6 md:p-12 mb-12" id="admin-content">
|
||||
<header class="mb-8 md:mb-12 border-b border-white/5 pb-8 md:pb-12 flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
|
||||
<div>
|
||||
<a id="back-link" href="/admin" class="text-blue hover:text-sky transition-colors mb-4 md:mb-8 inline-flex items-center gap-2 group text-sm md:text-base">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="md:w-5 md:h-5 transition-transform group-hover:-translate-x-1"><path d="m15 18-6-6 6-6"/></svg>
|
||||
Back
|
||||
<div class="space-y-6 md:space-y-10">
|
||||
<header class="flex flex-col md:flex-row md:items-end justify-between gap-4 pb-6 border-b border-surface1/40">
|
||||
<div class="flex-1 min-w-0">
|
||||
<a href="/" class="inline-flex items-center gap-1.5 text-xs text-subtext0 hover:text-text transition-colors mb-2 group">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="transition-transform group-hover:-translate-x-0.5" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>
|
||||
Back to site
|
||||
</a>
|
||||
<h1 class="text-3xl md:text-4xl font-extrabold text-mauve">
|
||||
<h1 class="text-2xl md:text-4xl font-bold text-mauve tracking-tight">
|
||||
{title}
|
||||
</h1>
|
||||
<slot name="header-subtitle" />
|
||||
</div>
|
||||
|
||||
<div class="flex gap-4 w-full md:w-auto">
|
||||
<div class="flex flex-wrap items-center gap-2 shrink-0">
|
||||
<slot name="header-actions" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<slot />
|
||||
<div>
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const backLink = document.getElementById('back-link');
|
||||
if (backLink && document.referrer && document.referrer.includes(window.location.host) && !document.referrer.includes('/admin/login')) {
|
||||
backLink.addEventListener('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
window.history.back();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</Layout>
|
||||
|
||||
Reference in New Issue
Block a user