Skip to content

Commit 4ac408e

Browse files
committed
chore: added variable font support
1 parent dd8c0f5 commit 4ac408e

21 files changed

+86
-23
lines changed

astro.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default defineConfig({
3030
rehypePlugins: [
3131
rehypeHeadingIds,
3232
sectionize,
33-
[rehypeAutolinkHeadings, { behavior: "wrap" }],
33+
rehypeAutolinkHeadings,
34+
// [rehypeAutolinkHeadings, { behavior: "wrap" }],
3435
],
3536
},
3637
});

public/fonts/Inter_18pt-Black.ttf

337 KB
Binary file not shown.
341 KB
Binary file not shown.

public/fonts/Inter_18pt-Bold.ttf

336 KB
Binary file not shown.
340 KB
Binary file not shown.

public/fonts/Inter_18pt-ExtraBold.ttf

337 KB
Binary file not shown.
341 KB
Binary file not shown.
335 KB
Binary file not shown.
339 KB
Binary file not shown.

public/fonts/Inter_18pt-Italic.ttf

338 KB
Binary file not shown.

public/fonts/Inter_18pt-Light.ttf

336 KB
Binary file not shown.
339 KB
Binary file not shown.

public/fonts/Inter_18pt-Medium.ttf

335 KB
Binary file not shown.
339 KB
Binary file not shown.

public/fonts/Inter_18pt-Regular.ttf

335 KB
Binary file not shown.

public/fonts/Inter_18pt-SemiBold.ttf

336 KB
Binary file not shown.
340 KB
Binary file not shown.

public/fonts/Inter_18pt-Thin.ttf

335 KB
Binary file not shown.
339 KB
Binary file not shown.

src/pages/blog/[id].astro

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,25 @@ const { Content, headings } = await render(post);
1515
1616
---
1717

18-
<!-- https://kld.dev/building-table-of-contents/ -->
19-
<!-- headings -->
18+
<!-- https://medium.com/@rezahedi/how-to-build-table-of-contents-in-astro-and-sectionize-the-markdown-content-78bee84e6a7f -->
2019

2120
<BaseLayout title={post.data.title}>
2221
<div class="px-4 py-8">
2322
<div class=" text-center ">
24-
<h1 class="text-5xl text-center font-bold text-gray-800 mb-4">{post.data.title}</h1>
23+
<h1 class="text-5xl text-center font-bold text-gray-800 mb-4 font-display">{post.data.title}</h1>
2524

2625
{post.data?.pubDate && (
2726
<p class="text-gray-500 text-sm mb-8">{post.data.pubDate.toDateString()}</p>
2827
)}
2928
</div>
3029

3130

32-
<article class="prose dark:prose-invert prose-a:font-normal prose-headings:font-bold prose-headings:prose-a:font-bold prose-headings:prose-a:no-underline prose-img:rounded-xl ">
31+
<article class="prose prose-base prose-headings:font-display prose-headings:font-semibold dark:prose-headings:text-white dark:prose-blockquote:border-base-500 prose-blockquote:font-normal prose-blockquote:tracking-normal prose-img:border prose-img:border-base-200 dark:prose-img:border-base-700 dark:prose-code:text-white prose-a:text-accent-400 hover:prose-a:text-accent-500 dark:prose-hr:border-base-800 prose-hr:border-base-300 prose-pre:border-none prose-pre:rounded-none prose-strong:font-medium prose-a:duration-200 dark:prose-strong:text-white">
3332

34-
<p class="font-semibold mb-8">
33+
<p class="mb-8">
3534
{post.data.description}
3635
</p>
3736

38-
<h2>Table of contents</h2>
39-
<ul class="mb-12">
40-
{headings.map((heading) => (
41-
<li>
42-
<a href={`#${heading.slug}`} class={heading.depth === 1 ? 'font-bold' : ''}>
43-
{heading.text}
44-
</a>
45-
</li>
46-
))}
47-
</ul>
4837
<Content />
4938
</article>
5039
</div>

src/styles/global.css

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
font-style: normal;
1010
}
1111

12+
@font-face {
13+
font-family: "Raleway";
14+
src: url("/fonts/Raleway-SemiBold.ttf") format("truetype");
15+
font-weight: 500;
16+
font-style: normal;
17+
}
18+
1219
@font-face {
1320
font-family: "Raleway";
1421
src: url("/fonts/Raleway-Bold.ttf") format("truetype");
@@ -23,19 +30,85 @@
2330
font-style: italic;
2431
}
2532

33+
@font-face {
34+
font-family: "Raleway";
35+
src: url("/fonts/Raleway-SemiBoldItalic.ttf") format("truetype");
36+
font-weight: 500;
37+
font-style: italic;
38+
}
39+
2640
@font-face {
2741
font-family: "Raleway";
2842
src: url("/fonts/Raleway-BoldItalic.ttf") format("truetype");
2943
font-weight: bold;
3044
font-style: italic;
3145
}
3246

47+
@font-face {
48+
font-family: "Inter";
49+
src: url("/fonts/Inter_18pt-Light.ttf") format("truetype");
50+
font-weight: 300;
51+
font-style: normal;
52+
}
53+
54+
@font-face {
55+
font-family: "Inter";
56+
src: url("/fonts/Inter_18pt-Regular.ttf") format("truetype");
57+
font-weight: normal;
58+
font-style: normal;
59+
}
60+
61+
@font-face {
62+
font-family: "Inter";
63+
src: url("/fonts/Inter_18pt-SemiBold.ttf") format("truetype");
64+
font-weight: 500;
65+
font-style: normal;
66+
}
67+
68+
@font-face {
69+
font-family: "Inter";
70+
src: url("/fonts/Inter_18pt-Bold.ttf") format("truetype");
71+
font-weight: bold;
72+
font-style: normal;
73+
}
74+
75+
@font-face {
76+
font-family: "Inter";
77+
src: url("/fonts/Inter_18pt-LightItalic.ttf") format("truetype");
78+
font-weight: 300;
79+
font-style: italic;
80+
}
81+
82+
@font-face {
83+
font-family: "Inter";
84+
src: url("/fonts/Inter_18pt-Italic.ttf") format("truetype");
85+
font-weight: normal;
86+
font-style: italic;
87+
}
88+
89+
@font-face {
90+
font-family: "Inter";
91+
src: url("/fonts/Inter_18pt-SemiBoldItalic.ttf") format("truetype");
92+
font-weight: 500;
93+
font-style: italic;
94+
}
95+
96+
@font-face {
97+
font-family: "Inter";
98+
src: url("/fonts/Inter_18pt-BoldItalic.ttf") format("truetype");
99+
font-weight: bold;
100+
font-style: italic;
101+
}
102+
33103
/* Set Raleway as the default heading font */
34-
h1,
35-
h2,
36-
h3,
37-
h4,
38-
h5,
39-
h6 {
40-
font-family: "Raleway", sans-serif;
104+
@theme {
105+
--font-sans: "Inter", "sans-serif";
106+
--font-display: "Raleway", "sans-serif";
107+
}
108+
109+
/* Override Tailwind Typography defaults to make prose text less bold */
110+
.prose {
111+
--tw-prose-headings-font-weight: 500; /* Adjust heading font weight */
112+
--tw-prose-bold-font-weight: 600; /* Adjust bold text font weight */
113+
--tw-prose-strong-font-weight: 600; /* Adjust strong text font weight */
41114
}

0 commit comments

Comments
 (0)