Skip to content

Commit dcd8133

Browse files
committed
Add Print components - Cover and Header
1 parent 237c452 commit dcd8133

5 files changed

Lines changed: 72 additions & 14 deletions

File tree

src/components/Layout/Copyright/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ const publishYear = publishDate.getFullYear()
1414

1515

1616
{variant === 'default' && <DefaultCopyright publishYear={publishYear} />}
17-
{variant === 'print' && <PrintCopyright publishYear={publishYear} link={link} />}
17+
{variant === 'print' && <PrintCopyright publishYear={publishYear} {...(link ? { link } : {})} />}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
import { type CollectionEntry } from 'astro:content'
3+
import Image from '@components/Image/index.astro'
4+
5+
export interface Props {
6+
article: CollectionEntry<'deepDives'>
7+
authorName: string
8+
}
9+
10+
const { article, authorName } = Astro.props
11+
const publishDateIso = article.data.publishDate.toISOString()
12+
const publishDateLabel = article.data.publishDate.toLocaleDateString(undefined, {
13+
year: 'numeric',
14+
month: 'long',
15+
day: 'numeric',
16+
})
17+
---
18+
19+
<section class="flex min-h-screen break-after-page flex-col items-center justify-center text-center print:break-after-page">
20+
<h1 class="mb-4 text-4xl font-bold text-content-active">{article.data.title}</h1>
21+
<div class="mb-6 w-full max-w-4xl">
22+
<Image
23+
src={article.data.cover}
24+
alt={article.data.coverAlt}
25+
loading="eager"
26+
variant="full"
27+
/>
28+
</div>
29+
<p class="mb-2 text-lg text-content">By {authorName}</p>
30+
<p class="text-sm text-content-offset">
31+
Published on <time datetime={publishDateIso}>{publishDateLabel}</time>
32+
</p>
33+
</section>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
import Brand from '@components/Brand/index.astro'
3+
4+
export interface Props {
5+
/** The URL path component e.g. 'articles/my-article' */
6+
path: string
7+
}
8+
---
9+
10+
<header
11+
id="header"
12+
data-header-search-open="false"
13+
class="site-header group/header flex flex-row items-center justify-between relative"
14+
role="banner"
15+
>
16+
{/* Logo and wordmark */}
17+
<span
18+
id="header__brand"
19+
class="header-brand flex items-center justify-between relative z-(--z-content-overlay)"
20+
>
21+
<Brand />
22+
</span>
23+
</header>

src/pages/pdf/[...slug].astro

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type CollectionEntry, getCollection, getEntry } from 'astro:content'
55
import { isDev } from '@lib/config/environmentServer'
66
import { getReadingTimeLabel } from '@lib/markdown/utils/readingTime'
77
import ContentLayout from '@components/Content/Layout/index.astro'
8+
import Cover from '@components/Layout/Print/Cover/index.astro'
89
910
export interface Props {
1011
article: CollectionEntry<'deepDives'>
@@ -33,6 +34,7 @@ const readingTime = article.data.readingTime ?? getReadingTimeLabel(articleBody)
3334
const section = 'Deep Dive Article PDF Files'
3435
---
3536

37+
<Cover article={article} authorName={author.data.name} />
3638
<ContentLayout
3739
author={author.data.name}
3840
article={article}
@@ -44,30 +46,30 @@ const section = 'Deep Dive Article PDF Files'
4446
<style is:global is:inline>
4547
@media print and (color) {
4648
@page {
47-
size: A4 landscape; /* Set paper size and orientation */
48-
margin: 2cm; /* Set all margins to 2 centimeters */
49+
margin: 2cm 2cm 3.5cm; /* Reserve extra bottom margin for fixed print footer */
50+
size: a4 landscape; /* Set paper size and orientation */
4951
}
5052

5153
@page :first {
54+
margin-bottom: 3.5cm;
5255
margin-top: 10cm; /* Add extra top margin for a title page */
5356
}
5457

5558
.footer {
56-
display: block;
57-
position: fixed;
58-
bottom: 0;
59-
left: 0;
60-
right: 0;
61-
height: 50px;
59+
align-items: center;
6260
background: #f8f9fa;
6361
border-top: 2px solid #dee2e6;
64-
padding: 15px 20px;
65-
font-size: 10pt;
62+
bottom: 0;
6663
color: #666;
67-
64+
display: block;
6865
display: flex;
66+
font-size: 0.875rem;
67+
height: 50px;
6968
justify-content: space-between;
70-
align-items: center;
69+
left: 0;
70+
padding: 15px 20px;
71+
position: fixed;
72+
right: 0;
7173
}
7274

7375
body {

src/styles/print.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
-------------------------------------------------------------------------- */
99

1010
@page {
11-
margin: 2cm;
11+
margin: 2cm 2cm 3.5cm;
1212
}
1313

1414
/* --------------------------------------------------------------------------

0 commit comments

Comments
 (0)