|
| 1 | +--- |
| 2 | +import BaseLayout from "../layouts/layout.astro"; |
| 3 | +import PageHeader from "../components/pageHeader/pageHeader.jsx"; |
| 4 | +import Card from "../components/card/card.jsx"; |
| 5 | +
|
| 6 | +const data = Astro.fetchContent("../content/resources/*.md"); |
| 7 | +let tagBlaster = []; |
| 8 | +data.map((resource) => { |
| 9 | + tagBlaster.push(resource.tags); |
| 10 | +}); |
| 11 | +const flatTags = tagBlaster.flat(); |
| 12 | +const tags = [...new Set(flatTags.map(JSON.stringify))].map(JSON.parse); |
| 13 | +
|
| 14 | +console.log(tags); |
| 15 | +
|
| 16 | +const tagsOpen = false; |
| 17 | +--- |
| 18 | + |
| 19 | +<BaseLayout title="Serverless - Ideas"> |
| 20 | + <PageHeader title="Resources" class="pageHeader"> |
| 21 | + <p> |
| 22 | + Articles about things related to Serverless, JAMstack, and the whole ball |
| 23 | + of yarn. |
| 24 | + </p> |
| 25 | + |
| 26 | + <nav class="nav" data-open={tagsOpen}> |
| 27 | + Topics:{" "} |
| 28 | + {tags.map((tag, i) => { |
| 29 | + return ( |
| 30 | + <button key={tag} onClick={() => onTagClick(tag)} class="tag"> |
| 31 | + {tag} |
| 32 | + </button> |
| 33 | + ); |
| 34 | + })} |
| 35 | + <button |
| 36 | + class="more" |
| 37 | + data-open={tagsOpen} |
| 38 | + id="more-resources-button" |
| 39 | + onClick={() => { |
| 40 | + console.log("clicked"); |
| 41 | + }} |
| 42 | + > |
| 43 | + More |
| 44 | + </button> |
| 45 | + </nav> |
| 46 | + </PageHeader> |
| 47 | + |
| 48 | + <div class="grid ideasCardGrid"> |
| 49 | + {data.map((resource) => ( |
| 50 | + <Card |
| 51 | + key={resource.title} |
| 52 | + title={resource.title} |
| 53 | + author={resource.author} |
| 54 | + tags={resource.tags} |
| 55 | + html={resource.content.html} |
| 56 | + url={resource.url} |
| 57 | + extraClasses="resource" |
| 58 | + /> |
| 59 | + ))} |
| 60 | + </div> |
| 61 | +</BaseLayout> |
| 62 | + |
| 63 | +<script> |
| 64 | + let tagsOpen = false; |
| 65 | + function onTagClick() { |
| 66 | + console.log("clicked"); |
| 67 | + } |
| 68 | +</script> |
| 69 | + |
| 70 | +<style lang="scss"> |
| 71 | + .pageHeader { |
| 72 | + background-image: url("https://res.cloudinary.com/css-tricks/image/upload/f_auto,q_auto,w_600/v1558187394/rocket_akopq6.png"), |
| 73 | + url("https://res.cloudinary.com/css-tricks/image/upload/f_auto,q_auto,w_1200/v1558187112/cloud4_gi3gqj.png"), |
| 74 | + url("/img/stars.svg"); |
| 75 | + background-size: 13%, 55%, 90%; |
| 76 | + background-repeat: no-repeat; |
| 77 | + background-position: top 10% right 22%, top right, top center; |
| 78 | + @media (max-width: 420px) { |
| 79 | + background-position: top 30% right 10%, top 5% right, top center; |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + .nav { |
| 84 | + font-family: var(--ff-gothic); |
| 85 | + text-transform: uppercase; |
| 86 | + font-size: 2rem; |
| 87 | + overflow: hidden; |
| 88 | + line-height: 1; |
| 89 | + max-height: 500px; |
| 90 | + transition: max-height 0.2s; |
| 91 | + position: relative; |
| 92 | + padding: 0 70px 40px 0; |
| 93 | + margin-bottom: 1rem; |
| 94 | + |
| 95 | + &[data-open="false"] { |
| 96 | + max-height: 80px; |
| 97 | + &::after { |
| 98 | + content: ""; |
| 99 | + position: absolute; |
| 100 | + bottom: 0; |
| 101 | + left: 0; |
| 102 | + width: 100%; |
| 103 | + height: 50px; |
| 104 | + background: linear-gradient(to top, #110b2e, rgba(#110b2e, 0)); |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + .tag { |
| 110 | + background: none; |
| 111 | + border: 0; |
| 112 | + font-family: var(--ff-gothic); |
| 113 | + color: #c4b3ec; |
| 114 | + font-size: 2rem; |
| 115 | + text-transform: uppercase; |
| 116 | + padding: 0; |
| 117 | + margin-right: 1rem; |
| 118 | + |
| 119 | + &:hover, |
| 120 | + &:focus { |
| 121 | + outline: 0; |
| 122 | + color: white; |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + .more { |
| 127 | + position: absolute; |
| 128 | + top: 0; |
| 129 | + right: 0; |
| 130 | + background: transparent url(/img/arrow-down.svg) right center no-repeat; |
| 131 | + color: white; |
| 132 | + border: 0; |
| 133 | + font-family: var(--ff-gothic); |
| 134 | + font-size: 2rem; |
| 135 | + text-transform: uppercase; |
| 136 | + padding-right: 20px; |
| 137 | + transition: 0.5s; |
| 138 | + cursor: pointer; |
| 139 | + &:hover, |
| 140 | + &:focus { |
| 141 | + outline: 0; |
| 142 | + } |
| 143 | + |
| 144 | + &[data-open="true"] { |
| 145 | + transform: rotate(180deg); |
| 146 | + } |
| 147 | + } |
| 148 | +</style> |
0 commit comments