You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/data/blog/adding-new-post.md
+46-9Lines changed: 46 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
author: Sat Naing
3
3
pubDatetime: 2022-09-23T15:22:00Z
4
-
modDatetime: 2025-03-22T06:25:46.734Z
4
+
modDatetime: 2025-06-13T16:52:45.934Z
5
5
title: Adding new posts in AstroPaper theme
6
6
slug: adding-new-posts-in-astropaper-theme
7
7
featured: true
@@ -84,25 +84,23 @@ Title and description (excerpt) are important for search engine optimization (SE
84
84
85
85
For example, if the blog file name is `adding-new-post.md` and you don't specify the slug in your frontmatter, Astro will automatically create a slug for the blog post using the file name. Thus, the slug will be `adding-new-post`. But if you specify the `slug` in the frontmatter, this will override the default slug. You can read more about this in [Astro Docs](https://docs.astro.build/en/guides/content-collections/#defining-custom-slugs).
86
86
87
-
If you omit `tags` in a blog post (in other words, if no tag is specified), the default tag `others` will be used as a tag for that post. You can set the default tag in the `/src/content/config.ts` file.
87
+
If you omit `tags` in a blog post (in other words, if no tag is specified), the default tag `others` will be used as a tag for that post. You can set the default tag in the `content.config.ts` file.
88
88
89
-
```ts
90
-
// src/content/config.ts
89
+
```ts file="src/content.config.ts"
91
90
exportconst blogSchema =z.object({
92
-
//---
91
+
//...
93
92
draft: z.boolean().optional(),
94
93
// [!code highlight:1]
95
94
tags: z.array(z.string()).default(["others"]), // replace "others" with whatever you want
96
-
//---
95
+
//...
97
96
});
98
97
```
99
98
100
99
### Sample Frontmatter
101
100
102
101
Here is the sample frontmatter for a post.
103
102
104
-
```yaml
105
-
# src/content/blog/sample-post.md
103
+
```yaml file="src/data/blog/sample-post.md"
106
104
---
107
105
title: The title of the post
108
106
author: your name
@@ -132,7 +130,7 @@ For instance, if you want to place your table of contents just under the intro p
132
130
<!-- prettier-ignore-start -->
133
131
```md
134
132
---
135
-
# some frontmatter
133
+
# frontmatter
136
134
---
137
135
138
136
Here are some recommendations, tips & ticks for creating new posts in AstroPaper blog theme.
@@ -150,6 +148,45 @@ There's one thing to note about headings. The AstroPaper blog posts use title (t
150
148
151
149
This rule is not mandatory, but highly recommended for visual, accessibility and SEO purposes.
152
150
151
+
## Syntax Highlighting
152
+
153
+
AstroPaper uses [Shiki](https://shiki.style/) as the default syntax highlighting. Starting from AstroPaper v5.4, [@shikijs/transformers](https://shiki.style/packages/transformers) is used to enhance better fenced code blocks. If you don't want to use it, you can simply remove it like this
154
+
155
+
```bash
156
+
pnpm remove @shikijs/transformers
157
+
```
158
+
159
+
```js file="astro.config.ts"
160
+
// ...
161
+
// [!code --:5]
162
+
import {
163
+
transformerNotationDiff,
164
+
transformerNotationHighlight,
165
+
transformerNotationWordHighlight,
166
+
} from"@shikijs/transformers";
167
+
168
+
exportdefaultdefineConfig({
169
+
// ...
170
+
markdown: {
171
+
remarkPlugins: [remarkToc, [remarkCollapse, { test:"Table of contents" }]],
172
+
shikiConfig: {
173
+
// For more themes, visit https://shiki.style/themes
174
+
themes: { light:"min-light", dark:"night-owl" },
175
+
defaultColor:false,
176
+
wrap:false,
177
+
transformers: [
178
+
transformerFileName(),
179
+
// [!code --:3]
180
+
transformerNotationHighlight(),
181
+
transformerNotationWordHighlight(),
182
+
transformerNotationDiff({ matchAlgorithm:"v3" }),
183
+
],
184
+
},
185
+
},
186
+
// ...
187
+
}
188
+
```
189
+
153
190
## Storing Images for Blog Content
154
191
155
192
Here are two methods for storing images and displaying them inside a markdown file.
Copy file name to clipboardExpand all lines: src/data/blog/customizing-astropaper-theme-color-schemes.md
+33-26Lines changed: 33 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
author: Sat Naing
3
3
pubDatetime: 2022-09-25T15:20:35Z
4
-
modDatetime: 2025-06-09T07:42:54.791Z
4
+
modDatetime: 2025-06-13T16:46:34.155Z
5
5
title: Customizing AstroPaper theme color schemes
6
6
featured: false
7
7
draft: false
@@ -19,19 +19,31 @@ This post will explain how you can enable/disable light & dark mode for the webs
19
19
20
20
## Enable/disable light & dark mode
21
21
22
-
AstroPaper theme will include light and dark mode by default. In other words, there will be two color schemes\_ one for light mode and another for dark mode. This default behavior can be disabled in SITE configuration object of the `src/config.ts` file.
22
+
AstroPaper theme will include light and dark mode by default. In other words, there will be two color schemes\_ one for light mode and another for dark mode. This default behavior can be disabled in `SITE` configuration object.
23
23
24
-
```js
25
-
// file: src/config.ts
24
+
```js file="src/config.ts"
26
25
exportconstSITE= {
27
-
website:"https://astro-paper.pages.dev/",
26
+
website:"https://astro-paper.pages.dev/",// replace this with your deployed domain
28
27
author:"Sat Naing",
28
+
profile:"https://satnaing.dev/",
29
29
desc:"A minimal, responsive and SEO-friendly Astro blog theme.",
30
30
title:"AstroPaper",
31
31
ogImage:"astropaper-og.jpg",
32
-
lightAndDarkMode:true, // true by default
33
-
postPerPage:3,
34
-
};
32
+
lightAndDarkMode:true, // [!code highlight]
33
+
postPerIndex:4,
34
+
postPerPage:4,
35
+
scheduledPostMargin:15*60*1000, // 15 minutes
36
+
showArchives:true,
37
+
showBackButton:true, // show back button in post detail
lang:"en", // html lang code. Set this empty and default will be "en"
45
+
timezone:"Asia/Bangkok", // Default global timezone (IANA format) https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
46
+
} as const;
35
47
```
36
48
37
49
To disable `light & dark mode` set `SITE.lightAndDarkMode` to `false`.
@@ -40,16 +52,15 @@ To disable `light & dark mode` set `SITE.lightAndDarkMode` to `false`.
40
52
41
53
By default, if we disable `SITE.lightAndDarkMode`, we will only get system's prefers-color-scheme.
42
54
43
-
Thus, to choose primary color scheme instead of prefers-color-scheme, we have to set color scheme in the primaryColorScheme variable inside `public/toggle-theme.js`.
55
+
Thus, to choose primary color scheme instead of prefers-color-scheme, we have to set color scheme in the `primaryColorScheme` variable inside `toggle-theme.js`.
The **primaryColorScheme** variable can hold two values\_`"light"`, `"dark"`. You can leave the empty string (default) if you don't want to specify the primary color scheme.
@@ -58,20 +69,16 @@ The **primaryColorScheme** variable can hold two values\_ `"light"`, `"dark"`. Y
58
69
-`"light"` - use light mode as primary color scheme.
59
70
-`"dark"` - use dark mode as primary color scheme.
60
71
61
-
<details><summary>Why 'primaryColorScheme' is not inside config.ts?</summary>
62
-
63
-
> To avoid color flickering on page reload, we have to place the toggle-switch JavaScript codes as early as possible when the page loads. It solves the problem of flickering, but as a trade-off, we cannot use ESM imports anymore.
64
-
65
-
[Click here](https://docs.astro.build/en/reference/directives-reference/#isinline) to know more about Astro's `is:inline` script.
66
-
72
+
<details>
73
+
<summary>Why primaryColorScheme' is not inside config.ts?</summary>
74
+
To avoid color flickering on page reload, we have to place the toggle-switch JavaScript codes as early as possible when the page loads. It solves the problem of flickering, but as a trade-off, we cannot use ESM imports anymore.
67
75
</details>
68
76
69
77
## Customize color schemes
70
78
71
-
Both light & dark color schemes of AstroPaper theme can be customized. You can do this in `src/styles/global.css` file.
79
+
Both light & dark color schemes of AstroPaper theme can be customizedin the `global.css` file.
72
80
73
-
```css
74
-
/* file: src/styles/global.css */
81
+
```css file="src/styles/global.css"
75
82
@import"tailwindcss";
76
83
@import"./typography.css";
77
84
@@ -93,7 +100,7 @@ html[data-theme="dark"] {
93
100
--muted: #343f60bf;
94
101
--border: #ab4b08;
95
102
}
96
-
/*other styles*/
103
+
/*...*/
97
104
```
98
105
99
106
In the AstroPaper theme, the `:root` and `html[data-theme="light"]` selectors define the light color scheme, while `html[data-theme="dark"]` defines the dark color scheme.
@@ -112,8 +119,8 @@ Here is the detail explanation of color properties.
112
119
113
120
Here is an example of changing the light color scheme.
114
121
115
-
```css
116
-
/*other styles*/
122
+
```css file="src/styles/global.css"
123
+
/*...*/
117
124
:root,
118
125
html[data-theme="light"] {
119
126
--background: #f6eee1;
@@ -122,7 +129,7 @@ html[data-theme="light"] {
122
129
--muted: #efd8b0;
123
130
--border: #dc9891;
124
131
}
125
-
/*other styles*/
132
+
/*...*/
126
133
```
127
134
128
135
> Check out some [predefined color schemes](https://astro-paper.pages.dev/posts/predefined-color-schemes/) AstroPaper has already crafted for you.
Copy file name to clipboardExpand all lines: src/data/blog/dynamic-og-images.md
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,9 +46,7 @@ Dynamic OG image of AstroPaper includes _the blog post title_, _author name_ and
46
46
47
47
Titles with non-latin characters won't display properly out of the box. To resolve this, we have to replace `fontsConfig` inside `loadGoogleFont.ts` with your preferred font.
Copy file name to clipboardExpand all lines: src/data/blog/how-to-configure-astropaper-theme.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,7 @@ The important configurations resides in `src/config.ts` file. Within that file,
22
22
23
23
During development, it's okay to leave `SITE.website` empty. But in production mode, you should specify your deployed url in `SITE.website` option since this will be used for canonical URL, social card URL etc.. which are important for SEO.
24
24
25
-
```js
26
-
// file: src/config.ts
25
+
```js file=src/config.ts
27
26
exportconstSITE= {
28
27
website:"https://astro-paper.pages.dev/", // replace this with your deployed domain
29
28
author:"Sat Naing",
@@ -73,12 +72,14 @@ Here are SITE configuration options
73
72
74
73
## Update layout width
75
74
76
-
The default `max-width` for the entire blog is `768px` (`max-w-3xl`). If you'd like to change it, you can easily update the `max-w-app` utility in your `src/styles/global.css` file:
75
+
The default `max-width` for the entire blog is `768px` (`max-w-3xl`). If you'd like to change it, you can easily update the `max-w-app` utility in your `global.css`. For instance:
77
76
78
-
```css
77
+
```css file=src/styles/global.css
79
78
@utility max-w-app {
79
+
/* [!code --:1] */
80
+
@apply max-w-3xl;
81
+
/* [!code ++:1] */
80
82
@apply max-w-4xl xl:max-w-5xl;
81
-
/* eg: max-w-4xl xl:max-w-5xl */
82
83
}
83
84
```
84
85
@@ -101,11 +102,11 @@ This is the easiest option. You just have to update `SITE.title` in `src/config.
101
102
You might want to use this option if you want to use an SVG logo.
102
103
103
104
- First add an SVG inside `src/assets` directory. (eg: `src/assets/dummy-logo.svg`)
104
-
- Then import that SVG inside `src/components/Header.astro`
105
+
- Then import that SVG inside `Header.astro`
105
106
106
-
```astro
107
+
```astro file=src/components/Header.astro
107
108
---
108
-
// other imports
109
+
// ...
109
110
import DummyLogo from "@/assets/dummy-logo.svg";
110
111
---
111
112
```
@@ -129,11 +130,11 @@ The best part of this approach is that you can customize your SVG styles as need
129
130
If your logo is an image but not SVG, you can use Astro's Image component.
130
131
131
132
- Add your logo inside `src/assets` directory. (eg: `src/assets/dummy-logo.png`)
132
-
- Import `Image` and your logo in `src/components/Header.astro`
133
+
- Import `Image` and your logo in `Header.astro`
133
134
134
-
```astro
135
+
```astro file=src/components/Header.astro
135
136
---
136
-
// other imports
137
+
// ...
137
138
import { Image } from "astro:assets";
138
139
import dummyLogo from "@/assets/dummy-logo.png";
139
140
---
@@ -155,11 +156,11 @@ With this approach, you can still adjust your image's appearance using CSS class
155
156
156
157
## Configuring social links
157
158
158
-
You can configure social links in `SOCIALS` object inside `src/constants.ts`.
159
-
160
159

161
160
162
-
```ts
161
+
You can configure social links in `SOCIALS` object inside `constants.ts`.
0 commit comments