Make my blog printable
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Kaan Barmore-Genç 2024-06-29 06:09:30 +00:00
parent 5b05df846f
commit cc876072c5
6 changed files with 114 additions and 33 deletions

View file

@ -6,7 +6,10 @@ import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url)); const __dirname = path.dirname(fileURLToPath(import.meta.url));
const title = process.argv[2] ?? 'New Blog Post'; const title = process.argv[2] ?? 'New Blog Post';
const slug = title.toLowerCase().replaceAll(' ', '-').slice(0, 60); let slug = title.toLowerCase().replaceAll(' ', '-');
while (slug.length > 60 && slug.includes('-')) {
slug = slug.substring(0, slug.lastIndexOf('-'));
}
const filename = `${format(new Date(), 'yyyy.MM.dd')}.${slug}.md`; const filename = `${format(new Date(), 'yyyy.MM.dd')}.${slug}.md`;

View file

@ -81,6 +81,14 @@ body {
flex-direction: column; flex-direction: column;
} }
@media print {
main code[class*='language-'],
main pre[class*='language-'] {
white-space: pre-wrap;
word-wrap: break-word;
}
}
/* Pagefind UI */ /* Pagefind UI */
.pagefind-ui { .pagefind-ui {
--pagefind-ui-border-radius: 0; --pagefind-ui-border-radius: 0;

View file

@ -13,6 +13,7 @@
import BlogPostList from './posts/[[page=integer]]/BlogPostList.svelte'; import BlogPostList from './posts/[[page=integer]]/BlogPostList.svelte';
import Button from '$lib/Button.svelte'; import Button from '$lib/Button.svelte';
import BlogPost from './posts/[[page=integer]]/BlogPost.svelte'; import BlogPost from './posts/[[page=integer]]/BlogPost.svelte';
import SocialButton from './SocialButton.svelte';
export let data; export let data;
</script> </script>
@ -70,34 +71,34 @@
<ul class="socials"> <ul class="socials">
<li> <li>
<a target="_blank" rel="noreferrer me" href="mailto:kaan@bgenc.net"> <SocialButton href="mailto:kaan@bgenc.net">
<EnvelopeSimple aria-hidden /> <EnvelopeSimple slot="logo" />
<span>Email</span> Email
</a> </SocialButton>
</li> </li>
<li> <li>
<a target="_blank" rel="noreferrer me" href="https://github.com/SeriousBug"> <SocialButton href="https://github.com/SeriousBug">
<GithubLogo aria-hidden /> <GithubLogo slot="logo" />
<span>Github</span> Github
</a> </SocialButton>
</li> </li>
<li> <li>
<a target="_blank" rel="noreferrer me" href="https://fosstodon.org/@kaan"> <SocialButton href="https://fosstodon.org/@kaan">
<MastodonLogo aria-hidden /> <MastodonLogo slot="logo" />
<span>Mastodon</span> Mastodon
</a> </SocialButton>
</li> </li>
<li> <li>
<a target="_blank" rel="noreferrer me" href="https://www.linkedin.com/in/kaan-barmore-genc"> <SocialButton href={'https://www.linkedin.com/in/kaan-barmore-genc'}>
<LinkedinLogo aria-hidden /> <LinkedinLogo slot="logo" />
<span>LinkedIn</span> LinkedIn
</a> </SocialButton>
</li> </li>
<li> <li>
<a target="_blank" href={cv}> <SocialButton href={cv} rel="" showPrint={false}>
<FilePlus /> <FilePlus slot="logo" />
<span>CV</span> CV
</a> </SocialButton>
</li> </li>
</ul> </ul>
</section> </section>
@ -115,6 +116,7 @@
<BlogPostList showYear showReadingTime={false} posts={data.highlightedPosts} /> <BlogPostList showYear showReadingTime={false} posts={data.highlightedPosts} />
<div class="all-posts-button"> <div class="all-posts-button">
<Button href="/posts/">All Posts</Button> <Button href="/posts/">All Posts</Button>
<div class="print-link">https://bgenc.net/posts/</div>
</div> </div>
</section> </section>
{/if} {/if}
@ -142,20 +144,30 @@
align-items: center; align-items: center;
} }
.print-link {
display: none;
}
@media print {
.socials {
gap: 0;
}
picture {
margin-top: -200px;
margin-left: 300px;
margin-bottom: -80px;
}
.print-link {
display: block;
}
}
.socials li { .socials li {
list-style-type: none; list-style-type: none;
} }
.socials a {
@include button($color-secondary, $color-secondary-text);
min-width: 8rem;
}
h1 {
width: 100%;
text-align: center;
}
.all-posts-button { .all-posts-button {
max-width: 12rem; max-width: 12rem;
margin: 2rem auto 0 auto; margin: 2rem auto 0 auto;

View file

@ -51,7 +51,7 @@
<Spacer /> <Spacer />
<div class="collapse-container"> <div class="collapse-container">
<div class="collapse" class:expanded> <div class="collapse" class:expanded>
<div id="search"></div> <div class="" id="search"></div>
<Button href="/posts/">Blog</Button> <Button href="/posts/">Blog</Button>
<Button href="/portfolio/">Portfolio</Button> <Button href="/portfolio/">Portfolio</Button>
</div> </div>
@ -128,6 +128,16 @@
} }
} }
@media print {
#search {
display: none;
}
.collapse-container {
display: none;
}
}
.logo { .logo {
width: 12rem; width: 12rem;
height: 12rem; height: 12rem;

View file

@ -0,0 +1,35 @@
<script lang="ts">
export let href = '';
export let rel = 'noreferrer me';
export let showPrint = true;
</script>
<a data-show-print={showPrint} target="_blank" {rel} {href}>
<div aria-hidden><slot name="logo"></slot></div>
<span><slot></slot></span>
<div class="print-link">{href.replace(/^mailto:/, '')}</div>
</a>
<style lang="scss">
@import '../vars';
@import '../button';
a {
@include button($color-secondary, $color-secondary-text);
min-width: 8rem;
}
.print-link {
display: none;
}
@media print {
.print-link {
display: block;
}
[data-show-print='false'] {
display: none;
}
}
</style>

View file

@ -5,9 +5,11 @@
export let showYear: boolean = false; export let showYear: boolean = false;
export let showReadingTime: boolean = true; export let showReadingTime: boolean = true;
export let post: Post; export let post: Post;
const href = `/${post.path}`;
</script> </script>
<a href={`/${post.path}`}> <a {href}>
<li> <li>
<div> <div>
<h5 class="post-title"> <h5 class="post-title">
@ -26,6 +28,7 @@
{/if} {/if}
</div> </div>
</li> </li>
<div class="print-link">{`https://bgenc.net${href}`}</div>
</a> </a>
<style lang="scss"> <style lang="scss">
@ -71,4 +74,14 @@
font-size: 0.9rem; font-size: 0.9rem;
opacity: 0.8; opacity: 0.8;
} }
.print-link {
display: none;
}
@media print {
.print-link {
display: block;
}
}
</style> </style>