-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.astro
88 lines (82 loc) · 1.91 KB
/
index.astro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
import ThemedCode from "../../../components/ThemedCode.astro";
import BaseLayout from "../../../layouts/BaseLayout.astro";
---
<style is:global>
.sub-page {
max-width: 600px;
margin: 0 auto;
}
.sub-page nav {
display: flex;
justify-content: space-between;
}
.home-page-hero {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.nav-img {
width: 100px;
}
img {
width: 300px;
}
.empty {
height: 50vh;
}
body:has(.home-page-hero) nav .logo {
display: none;
}
body:has(.home-page-hero) .sub-page nav {
justify-content: flex-end;
}
</style>
<BaseLayout title="Anywhere - Home">
<div class="description">
<p>Select elements anywhere on the page if a specific selector exists.</p>
<p>
In this example if the hero section is present, hide the logo in the
navbar and change the flex box alignment.
</p>
</div>
<ThemedCode lang="css" code=`body:has(.home-page-hero) nav .logo {
display: none;
}
body:has(.home-page-hero) .sub-page nav {
justify-content: flex-end;
}` />
<hr>
<section class="sub-page" id="page">
<nav>
<div class="logo">
<img class="nav-img" src="/syntax.png" />
</div>
<ul class="nav-list">
<li>
<a href="/anywhere/2/#page">Home</a>
</li>
<li>
<a href="/anywhere/2/about#page">About</a>
</li>
</ul>
</nav>
<div class="home-page-hero">
<img src="/syntax.png" />
<h2>A Tasty Treats Podcast for Web Developers</h2>
</div>
<div class="empty"></div>
</section>
</BaseLayout>
<script is:inline>
function scrollToPage() {
if (window.location.hash) {
const element = document.querySelector(window.location.hash);
if (element) {
element.scrollIntoView();
}
}
}
document.addEventListener("astro:after-swap", scrollToPage);
</script>