Skip to content

Commit 97f90d4

Browse files
committed
Added Keystatic for editing blog content
1 parent 590b0f8 commit 97f90d4

File tree

8 files changed

+3064
-204
lines changed

8 files changed

+3064
-204
lines changed

astro.config.mjs

+35-68
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,62 @@
11
import path from 'path';
22
import { fileURLToPath } from 'url';
3-
43
import { defineConfig, squooshImageService } from 'astro/config';
5-
64
import sitemap from '@astrojs/sitemap';
75
import tailwind from '@astrojs/tailwind';
86
import mdx from '@astrojs/mdx';
97
import partytown from '@astrojs/partytown';
108
import icon from 'astro-icon';
119
import compress from 'astro-compress';
1210
import tasks from './src/utils/tasks';
13-
1411
import { readingTimeRemarkPlugin, responsiveTablesRehypePlugin } from './src/utils/frontmatter.mjs';
15-
1612
import { ANALYTICS, SITE } from './src/utils/config.ts';
17-
13+
import react from "@astrojs/react";
14+
import markdoc from "@astrojs/markdoc";
15+
import keystatic from '@keystatic/astro';
1816
const __dirname = path.dirname(fileURLToPath(import.meta.url));
17+
const whenExternalScripts = (items = []) => ANALYTICS.vendors.googleAnalytics.id && ANALYTICS.vendors.googleAnalytics.partytown ? Array.isArray(items) ? items.map(item => item()) : [items()] : [];
1918

20-
const whenExternalScripts = (items = []) =>
21-
ANALYTICS.vendors.googleAnalytics.id && ANALYTICS.vendors.googleAnalytics.partytown
22-
? Array.isArray(items)
23-
? items.map((item) => item())
24-
: [items()]
25-
: [];
26-
19+
// https://astro.build/config
2720
export default defineConfig({
2821
site: SITE.site,
2922
base: SITE.base,
3023
trailingSlash: SITE.trailingSlash ? 'always' : 'never',
31-
3224
output: 'hybrid',
33-
34-
integrations: [
35-
tailwind({
36-
applyBaseStyles: false,
37-
}),
38-
sitemap(),
39-
mdx(),
40-
icon({
41-
include: {
42-
tabler: ['*'],
43-
'flat-color-icons': [
44-
'template',
45-
'gallery',
46-
'approval',
47-
'document',
48-
'advertising',
49-
'currency-exchange',
50-
'voice-presentation',
51-
'business-contact',
52-
'database',
53-
],
54-
},
55-
}),
56-
57-
...whenExternalScripts(() =>
58-
partytown({
59-
config: { forward: ['dataLayer.push'] },
60-
})
61-
),
62-
63-
compress({
64-
CSS: true,
65-
HTML: {
66-
'html-minifier-terser': {
67-
removeAttributeQuotes: false,
68-
},
69-
},
70-
Image: false,
71-
JavaScript: true,
72-
SVG: false,
73-
Logger: 1,
74-
}),
75-
76-
tasks(),
77-
],
78-
25+
integrations: [tailwind({
26+
applyBaseStyles: false
27+
}), sitemap(), mdx(), icon({
28+
include: {
29+
tabler: ['*'],
30+
'flat-color-icons': ['template', 'gallery', 'approval', 'document', 'advertising', 'currency-exchange', 'voice-presentation', 'business-contact', 'database']
31+
}
32+
}), ...whenExternalScripts(() => partytown({
33+
config: {
34+
forward: ['dataLayer.push']
35+
}
36+
})), compress({
37+
CSS: true,
38+
HTML: {
39+
'html-minifier-terser': {
40+
removeAttributeQuotes: false
41+
}
42+
},
43+
Image: false,
44+
JavaScript: true,
45+
SVG: false,
46+
Logger: 1
47+
}), tasks(), react(), markdoc(), keystatic()],
7948
image: {
80-
service: squooshImageService(),
49+
service: squooshImageService()
8150
},
82-
8351
markdown: {
8452
remarkPlugins: [readingTimeRemarkPlugin],
85-
rehypePlugins: [responsiveTablesRehypePlugin],
53+
rehypePlugins: [responsiveTablesRehypePlugin]
8654
},
87-
8855
vite: {
8956
resolve: {
9057
alias: {
91-
'~': path.resolve(__dirname, './src'),
92-
},
93-
},
94-
},
95-
});
58+
'~': path.resolve(__dirname, './src')
59+
}
60+
}
61+
}
62+
});

keystatic.config.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { config, fields, collection } from '@keystatic/core';
2+
3+
export default config({
4+
storage: {
5+
kind: 'local',
6+
},
7+
collections: {
8+
posts: collection({
9+
label: 'Posts',
10+
slugField: 'title',
11+
path: 'src/content/posts/*',
12+
format: { contentField: 'content' },
13+
schema: {
14+
title: fields.slug({ name: { label: 'Title' } }),
15+
content: fields.document({
16+
label: 'Content',
17+
formatting: true,
18+
dividers: true,
19+
links: true,
20+
images: {
21+
directory: 'src/assets/images/posts',
22+
publicPath: '../../assets/images/posts/',
23+
},
24+
}),
25+
},
26+
}),
27+
},
28+
});

0 commit comments

Comments
 (0)