-
Notifications
You must be signed in to change notification settings - Fork 0
Add overlay hero layout for blog posts #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -194,6 +194,64 @@ | |
| object-fit: cover; | ||
| } | ||
|
|
||
| /* ─────────────────────────────────────────── | ||
| Overlay Hero | ||
| ─────────────────────────────────────────── */ | ||
|
|
||
| .overlayHero { | ||
| position: relative; | ||
| width: 100vw; | ||
| margin-left: calc(50% - 50vw); | ||
| margin-top: -80px; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mobile hero offset overshoots viewport topMedium Severity
|
||
| aspect-ratio: 16 / 9; | ||
| max-height: 480px; | ||
| overflow: hidden; | ||
| margin-bottom: 64px; | ||
| } | ||
|
|
||
| .overlayImage { | ||
| width: 100%; | ||
| height: 100%; | ||
| object-fit: cover; | ||
| } | ||
|
|
||
| .overlayGradient { | ||
| position: absolute; | ||
| inset: 0; | ||
| background: linear-gradient( | ||
| to bottom, | ||
| transparent 20%, | ||
| rgba(11, 11, 11, 0.5) 50%, | ||
| rgba(11, 11, 11, 0.85) 75%, | ||
| rgb(11, 11, 11) 100% | ||
| ); | ||
| } | ||
|
|
||
| .overlayHeader { | ||
| position: absolute; | ||
| bottom: 0; | ||
| left: 50%; | ||
| transform: translateX(-50%); | ||
| width: 100%; | ||
| max-width: var(--col-max); | ||
| padding: 0 24px 32px; | ||
| z-index: 1; | ||
| } | ||
|
|
||
| .overlayHeader .postMeta { | ||
| margin-bottom: 16px; | ||
| color: rgba(240, 237, 232, 0.7); | ||
| } | ||
|
|
||
| .overlayHeader .postTitle { | ||
| color: #fff; | ||
| text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5); | ||
| } | ||
|
|
||
| .overlayHeader .postSubtitle { | ||
| color: rgba(240, 237, 232, 0.8); | ||
| } | ||
|
|
||
| /* ─────────────────────────────────────────── | ||
| Prose (MDX content) | ||
| ─────────────────────────────────────────── */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,8 @@ export function getAllPosts(): BlogMeta[] { | |
| const files = fs.readdirSync(blogDirectory).filter((f) => f.endsWith('.md')) | ||
|
|
||
| const posts: BlogMeta[] = files.map((fileName) => { | ||
| const slug = fileName.replace(/\.md$/, '') | ||
| const overlay = fileName.endsWith('.overlay.md') | ||
| const slug = fileName.replace(/\.overlay\.md$/, '').replace(/\.md$/, '') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overlay and regular files can collideLow Severity
Additional Locations (1) |
||
| const filePath = path.join(blogDirectory, fileName) | ||
| const fileContent = fs.readFileSync(filePath, 'utf-8') | ||
| const { data } = matter(fileContent) | ||
|
|
@@ -35,6 +36,7 @@ export function getAllPosts(): BlogMeta[] { | |
| date: data.date ? String(data.date) : '', | ||
| image: findImage(slug), | ||
| readingTime: data.readingTime, | ||
| overlay, | ||
| slug, | ||
| } | ||
| }) | ||
|
|
@@ -43,7 +45,10 @@ export function getAllPosts(): BlogMeta[] { | |
| } | ||
|
|
||
| export function getPostBySlug(slug: string): BlogPost | null { | ||
| const filePath = path.join(blogDirectory, `${slug}.md`) | ||
| const overlayPath = path.join(blogDirectory, `${slug}.overlay.md`) | ||
| const regularPath = path.join(blogDirectory, `${slug}.md`) | ||
| const overlay = fs.existsSync(overlayPath) | ||
| const filePath = overlay ? overlayPath : regularPath | ||
| if (!fs.existsSync(filePath)) return null | ||
|
|
||
| const fileContent = fs.readFileSync(filePath, 'utf-8') | ||
|
|
@@ -56,6 +61,7 @@ export function getPostBySlug(slug: string): BlogPost | null { | |
| date: data.date ? String(data.date) : '', | ||
| image: findImage(slug), | ||
| readingTime: data.readingTime, | ||
| overlay, | ||
| slug, | ||
| }, | ||
| content, | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Full-bleed hero can trigger horizontal scrolling
Low Severity
The new full-bleed hero uses
width: 100vwwithmargin-left: calc(50% - 50vw), which can exceed the layout width when a vertical scrollbar is present. Overlay posts may show an unwanted horizontal scrollbar and slight sideways page shift on some browsers.