diff options
author | 2021-06-28 15:29:16 -0700 | |
---|---|---|
committer | 2021-06-28 15:29:16 -0700 | |
commit | 5591d4eb9fc70e781804f940fabd334b53ce7056 (patch) | |
tree | 9c4c4ebaf708e959a96b1fc9cede9c1fc9cc40b5 /examples/blog/src/components/BlogPost.astro | |
parent | 7063c04dec48fcabcda104c42d61642a554f6044 (diff) | |
download | astro-5591d4eb9fc70e781804f940fabd334b53ce7056.tar.gz astro-5591d4eb9fc70e781804f940fabd334b53ce7056.tar.zst astro-5591d4eb9fc70e781804f940fabd334b53ce7056.zip |
update the blog example (#565)
Diffstat (limited to 'examples/blog/src/components/BlogPost.astro')
-rw-r--r-- | examples/blog/src/components/BlogPost.astro | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/examples/blog/src/components/BlogPost.astro b/examples/blog/src/components/BlogPost.astro new file mode 100644 index 000000000..95116b2e7 --- /dev/null +++ b/examples/blog/src/components/BlogPost.astro @@ -0,0 +1,86 @@ +--- +import Author from './Author.astro'; + +export interface Props { + title: string; + author: string; + publishDate: string; + heroImage: string; +} + +const { title, author, publishDate, heroImage } = Astro.props; +--- + +<div class="layout"> + <article class="content"> + <div> + <header> + {heroImage && <img width="720" height="420" class="hero-image" loading="lazy" src={heroImage} />} + <p class="publish-date">{publishDate}</p> + <h1 class="title">{title}</h1> + <Author name="@FredKSchott" url="https://twitter.com/FredKSchott" /> + </header> + <main> + <slot /> + </main> + </article> +</div> + +<style> +.hero-image { + width: 100vw; + object-fit: cover; + object-position: center; + margin-top: 2rem; + margin-bottom: 4rem; + max-width: 1280px; +} + +@media (max-width: 50em) { + .hero-image { + height: 260px; + margin-top: 0; + margin-bottom: 2rem; + } +} + +.content { + margin-bottom: 8rem; +} + +.content :global(main > * + *) { + margin-top: 1rem; +} + +.content :global(h2) { + margin-top: 4rem; +} + +header { + display: flex; + flex-direction: column; + text-align: center; + align-items: center; + justify-content: center; + + padding-bottom: 2rem; + margin-bottom: 2rem; + border-bottom: 4px solid var(--theme-divider); +} + +.title, +.author, +.publish-date { + margin: 0; +} + +.publish-date, +.author { + color: var(--theme-text-lighter); +} + +.title { + font-size: 2.25rem; + font-weight: 700; +} +</style> |