@studiocms/blog 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BaseHead.astro +2 -9
- package/dist/components/render.d.ts +1 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/types.d.ts +58 -102
- package/dist/types.js +70 -52
- package/package.json +4 -4
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '../styles/base.css';
|
|
3
3
|
import config from 'studiocms:blog/frontend-config';
|
|
4
|
-
import {
|
|
5
|
-
createHead,
|
|
6
|
-
type HeadConfig,
|
|
7
|
-
type HeadConfigSchema,
|
|
8
|
-
type HeadUserConfig,
|
|
9
|
-
headDefaults,
|
|
10
|
-
} from 'studiocms:lib';
|
|
11
|
-
import type { z } from 'astro/zod';
|
|
4
|
+
import { createHead, type HeadConfig, type HeadUserConfig, headDefaults } from 'studiocms:lib';
|
|
12
5
|
import { getHeroImage } from './heroHelper.js';
|
|
13
6
|
|
|
14
7
|
let htmlDefaultHead: HeadUserConfig = [];
|
|
@@ -38,7 +31,7 @@ const ogImage = getHeroImage(image, Astro);
|
|
|
38
31
|
|
|
39
32
|
const makeHeader = headDefaults(title, description, lang, Astro, favicon, ogImage, canonicalURL);
|
|
40
33
|
|
|
41
|
-
const StudioCMSFrontEndHeads:
|
|
34
|
+
const StudioCMSFrontEndHeads: HeadUserConfig = [
|
|
42
35
|
// Fonts
|
|
43
36
|
{ tag: 'link', attrs: { rel: 'preconnect', href: 'https://fonts.googleapis.com' } },
|
|
44
37
|
{ tag: 'link', attrs: { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: '' } },
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
declare const renderer: {
|
|
2
2
|
name: string;
|
|
3
3
|
renderer: (content: string) => Promise<string>;
|
|
4
|
-
sanitizeOpts:
|
|
5
|
-
allowElements?: string[] | undefined;
|
|
6
|
-
blockElements?: string[] | undefined;
|
|
7
|
-
dropElements?: string[] | undefined;
|
|
8
|
-
allowAttributes?: Record<string, string[]> | undefined;
|
|
9
|
-
dropAttributes?: Record<string, string[]> | undefined;
|
|
10
|
-
allowComponents?: boolean | undefined;
|
|
11
|
-
allowCustomElements?: boolean | undefined;
|
|
12
|
-
allowComments?: boolean | undefined;
|
|
13
|
-
} | undefined;
|
|
4
|
+
sanitizeOpts: any;
|
|
14
5
|
};
|
|
15
6
|
export default renderer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
|
-
import {
|
|
2
|
+
import type { StudioCMSPluginDef } from 'studiocms/schemas';
|
|
3
3
|
import { type StudioCMSBlogOptions } from './types.js';
|
|
4
4
|
export declare function internalBlogIntegration(options?: StudioCMSBlogOptions): AstroIntegration;
|
|
5
5
|
/**
|
|
6
6
|
* Creates and configures the StudioCMS Blog plugin.
|
|
7
7
|
*
|
|
8
8
|
* @param {StudioCMSBlogOptions} [options] - Optional configuration options for the blog plugin.
|
|
9
|
-
* @returns {
|
|
9
|
+
* @returns {StudioCMSPluginDef} The configured StudioCMS plugin.
|
|
10
10
|
*
|
|
11
11
|
* @remarks
|
|
12
12
|
* This function sets up the StudioCMS Blog plugin with the provided options or default values.
|
|
@@ -33,5 +33,5 @@ export declare function internalBlogIntegration(options?: StudioCMSBlogOptions):
|
|
|
33
33
|
* @param {boolean} [options.sitemap] - Whether to trigger sitemap generation. Defaults to true.
|
|
34
34
|
* @param {boolean} [options.injectRoutes] - Whether to inject routes for the blog. Defaults to true.
|
|
35
35
|
*/
|
|
36
|
-
export declare function studioCMSBlogPlugin(options?: StudioCMSBlogOptions):
|
|
36
|
+
export declare function studioCMSBlogPlugin(options?: StudioCMSBlogOptions): StudioCMSPluginDef;
|
|
37
37
|
export default studioCMSBlogPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { addVirtualImports, createResolver } from "astro-integration-kit";
|
|
2
|
+
import { Schema } from "effect";
|
|
2
3
|
import { pathWithBase } from "studiocms/lib/pathGenerators";
|
|
3
4
|
import { definePlugin } from "studiocms/plugins";
|
|
4
5
|
import { FrontEndConfigSchema } from "./types.js";
|
|
5
6
|
const packageIdentifier = "@studiocms/blog";
|
|
6
|
-
function internalBlogIntegration(options) {
|
|
7
|
-
const resolvedOptions =
|
|
7
|
+
function internalBlogIntegration(options = {}) {
|
|
8
|
+
const resolvedOptions = Schema.decodeSync(FrontEndConfigSchema)(options);
|
|
8
9
|
const {
|
|
9
10
|
blog: { title, enableRSS, route: orgRoute },
|
|
10
11
|
injectRoutes,
|
|
@@ -65,8 +66,8 @@ function internalBlogIntegration(options) {
|
|
|
65
66
|
}
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
|
-
function studioCMSBlogPlugin(options) {
|
|
69
|
-
const resolvedOptions =
|
|
69
|
+
function studioCMSBlogPlugin(options = {}) {
|
|
70
|
+
const resolvedOptions = Schema.decodeSync(FrontEndConfigSchema)(options);
|
|
70
71
|
const {
|
|
71
72
|
blog: { title, route: orgRoute },
|
|
72
73
|
sitemap
|
|
@@ -78,18 +79,17 @@ function studioCMSBlogPlugin(options) {
|
|
|
78
79
|
return definePlugin({
|
|
79
80
|
identifier: packageIdentifier,
|
|
80
81
|
name: "StudioCMS Blog",
|
|
81
|
-
studiocmsMinimumVersion: "0.1.0-beta.21",
|
|
82
82
|
requires: ["@studiocms/md"],
|
|
83
83
|
hooks: {
|
|
84
|
-
"studiocms:astro-config": ({ addIntegrations }) => {
|
|
84
|
+
"studiocms:astro-config": async ({ addIntegrations }) => {
|
|
85
85
|
addIntegrations(internalBlogIntegration(resolvedOptions));
|
|
86
86
|
},
|
|
87
|
-
"studiocms:frontend": ({ setFrontend }) => {
|
|
87
|
+
"studiocms:frontend": async ({ setFrontend }) => {
|
|
88
88
|
setFrontend({
|
|
89
89
|
frontendNavigationLinks: [{ label: title, href: route }]
|
|
90
90
|
});
|
|
91
91
|
},
|
|
92
|
-
"studiocms:rendering": ({ setRendering }) => {
|
|
92
|
+
"studiocms:rendering": async ({ setRendering }) => {
|
|
93
93
|
setRendering({
|
|
94
94
|
pageTypes: [
|
|
95
95
|
{
|
|
@@ -101,7 +101,7 @@ function studioCMSBlogPlugin(options) {
|
|
|
101
101
|
]
|
|
102
102
|
});
|
|
103
103
|
},
|
|
104
|
-
"studiocms:sitemap": ({ setSitemap }) => {
|
|
104
|
+
"studiocms:sitemap": async ({ setSitemap }) => {
|
|
105
105
|
setSitemap({
|
|
106
106
|
triggerSitemap: sitemap,
|
|
107
107
|
sitemaps: [
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type
|
|
4
|
-
export type HeadConfig = z.output<ReturnType<typeof HeadConfigSchema>>;
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { type HeadConfig, type HeadUserConfig } from 'studiocms/lib/head';
|
|
3
|
+
export type { HeadConfig, HeadUserConfig };
|
|
5
4
|
export declare const faviconTypeMap: {
|
|
6
5
|
'.ico': string;
|
|
7
6
|
'.gif': string;
|
|
@@ -11,101 +10,58 @@ export declare const faviconTypeMap: {
|
|
|
11
10
|
'.svg': string;
|
|
12
11
|
};
|
|
13
12
|
export declare function isFaviconExt(ext: string): ext is keyof typeof faviconTypeMap;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
tag: "
|
|
32
|
-
attrs: Record<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
*/
|
|
70
|
-
route: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
71
|
-
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
title: string;
|
|
73
|
-
enableRSS: boolean;
|
|
74
|
-
route: string;
|
|
75
|
-
}, {
|
|
76
|
-
title?: string | undefined;
|
|
77
|
-
enableRSS?: boolean | undefined;
|
|
78
|
-
route?: string | undefined;
|
|
79
|
-
}>>>;
|
|
80
|
-
}, "strip", z.ZodTypeAny, {
|
|
81
|
-
htmlDefaultLanguage: string;
|
|
82
|
-
htmlDefaultHead: {
|
|
83
|
-
tag: "style" | "title" | "base" | "link" | "meta" | "script" | "noscript" | "template";
|
|
84
|
-
attrs: Record<string, string | boolean | undefined>;
|
|
85
|
-
content: string;
|
|
86
|
-
}[];
|
|
87
|
-
favicon: string;
|
|
88
|
-
sitemap: boolean;
|
|
89
|
-
injectRoutes: boolean;
|
|
90
|
-
blog: {
|
|
91
|
-
title: string;
|
|
92
|
-
enableRSS: boolean;
|
|
93
|
-
route: string;
|
|
94
|
-
};
|
|
95
|
-
}, {
|
|
96
|
-
htmlDefaultLanguage?: string | undefined;
|
|
97
|
-
htmlDefaultHead?: {
|
|
98
|
-
tag: "style" | "title" | "base" | "link" | "meta" | "script" | "noscript" | "template";
|
|
99
|
-
attrs?: Record<string, string | boolean | undefined> | undefined;
|
|
100
|
-
content?: string | undefined;
|
|
101
|
-
}[] | undefined;
|
|
102
|
-
favicon?: string | undefined;
|
|
103
|
-
sitemap?: boolean | undefined;
|
|
104
|
-
injectRoutes?: boolean | undefined;
|
|
105
|
-
blog?: {
|
|
106
|
-
title?: string | undefined;
|
|
107
|
-
enableRSS?: boolean | undefined;
|
|
108
|
-
route?: string | undefined;
|
|
109
|
-
} | undefined;
|
|
110
|
-
}>>>;
|
|
111
|
-
export type StudioCMSBlogOptions = z.infer<typeof FrontEndConfigSchema>;
|
|
13
|
+
export declare const FaviconSchema: Schema.transformOrFail<typeof Schema.String, typeof Schema.String, never>;
|
|
14
|
+
export declare const FrontEndBlogSchema: Schema.Struct<{
|
|
15
|
+
title: Schema.optionalWith<typeof Schema.String, {
|
|
16
|
+
default: () => string;
|
|
17
|
+
}>;
|
|
18
|
+
enableRSS: Schema.optionalWith<typeof Schema.Boolean, {
|
|
19
|
+
default: () => true;
|
|
20
|
+
}>;
|
|
21
|
+
route: Schema.optionalWith<typeof Schema.String, {
|
|
22
|
+
default: () => string;
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const FrontEndConfigSchema: Schema.Struct<{
|
|
26
|
+
htmlDefaultLanguage: Schema.optionalWith<typeof Schema.String, {
|
|
27
|
+
default: () => string;
|
|
28
|
+
}>;
|
|
29
|
+
htmlDefaultHead: Schema.optionalWith<Schema.mutable<Schema.Array$<Schema.mutable<Schema.Struct<{
|
|
30
|
+
tag: Schema.Literal<["title", "base", "link", "style", "meta", "script", "noscript", "template"]>;
|
|
31
|
+
attrs: Schema.optionalWith<Schema.Record$<typeof Schema.String, Schema.Union<[typeof Schema.String, typeof Schema.Boolean, typeof Schema.Undefined]>>, {
|
|
32
|
+
default: () => {};
|
|
33
|
+
}>;
|
|
34
|
+
content: Schema.optionalWith<typeof Schema.String, {
|
|
35
|
+
default: () => string;
|
|
36
|
+
}>;
|
|
37
|
+
}>>>>, {
|
|
38
|
+
default: () => never[];
|
|
39
|
+
}>;
|
|
40
|
+
favicon: Schema.optionalWith<Schema.transformOrFail<typeof Schema.String, typeof Schema.String, never>, {
|
|
41
|
+
default: () => string;
|
|
42
|
+
}>;
|
|
43
|
+
sitemap: Schema.optionalWith<typeof Schema.Boolean, {
|
|
44
|
+
default: () => true;
|
|
45
|
+
}>;
|
|
46
|
+
injectRoutes: Schema.optionalWith<typeof Schema.Boolean, {
|
|
47
|
+
default: () => true;
|
|
48
|
+
}>;
|
|
49
|
+
blog: Schema.optionalWith<Schema.Struct<{
|
|
50
|
+
title: Schema.optionalWith<typeof Schema.String, {
|
|
51
|
+
default: () => string;
|
|
52
|
+
}>;
|
|
53
|
+
enableRSS: Schema.optionalWith<typeof Schema.Boolean, {
|
|
54
|
+
default: () => true;
|
|
55
|
+
}>;
|
|
56
|
+
route: Schema.optionalWith<typeof Schema.String, {
|
|
57
|
+
default: () => string;
|
|
58
|
+
}>;
|
|
59
|
+
}>, {
|
|
60
|
+
default: () => {
|
|
61
|
+
readonly title: string;
|
|
62
|
+
readonly enableRSS: boolean;
|
|
63
|
+
readonly route: string;
|
|
64
|
+
};
|
|
65
|
+
}>;
|
|
66
|
+
}>;
|
|
67
|
+
export type StudioCMSBlogOptions = typeof FrontEndConfigSchema.Encoded;
|
package/dist/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extname } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { ParseResult, Schema } from "effect";
|
|
3
3
|
import { HeadConfigSchema } from "studiocms/lib/head";
|
|
4
4
|
const faviconTypeMap = {
|
|
5
5
|
".ico": "image/x-icon",
|
|
@@ -12,59 +12,77 @@ const faviconTypeMap = {
|
|
|
12
12
|
function isFaviconExt(ext) {
|
|
13
13
|
return ext in faviconTypeMap;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
htmlDefaultHead: HeadConfigSchema(),
|
|
25
|
-
/**
|
|
26
|
-
* Favicon Configuration - The default favicon configuration for the Frontend
|
|
27
|
-
*/
|
|
28
|
-
favicon: z.string().refine(
|
|
29
|
-
(fav) => {
|
|
30
|
-
const ext = extname(fav);
|
|
31
|
-
return isFaviconExt(ext);
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
message: "favicon must be a .ico, .gif, .jpg, .png, or .svg file"
|
|
15
|
+
const FaviconSchema = Schema.transformOrFail(Schema.String, Schema.String, {
|
|
16
|
+
strict: true,
|
|
17
|
+
decode: (input, _options, ast) => {
|
|
18
|
+
const ext = extname(input).toLocaleLowerCase();
|
|
19
|
+
if (!isFaviconExt(ext)) {
|
|
20
|
+
return ParseResult.fail(
|
|
21
|
+
new ParseResult.Type(ast, input, "favicon must be a .ico, .gif, .jpg, .png, or .svg file")
|
|
22
|
+
);
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
24
|
+
return ParseResult.succeed(input);
|
|
25
|
+
},
|
|
26
|
+
encode: (input) => ParseResult.succeed(input)
|
|
27
|
+
}).annotations({
|
|
28
|
+
title: "Favicon",
|
|
29
|
+
identifier: "FaviconSchema",
|
|
30
|
+
description: "The path to the favicon file. Must be a .ico, .gif, .jpg, .png, or .svg file.",
|
|
31
|
+
examples: ["/favicon.ico", "/favicon.png", "/favicon.svg"]
|
|
32
|
+
});
|
|
33
|
+
const FrontEndBlogSchema = Schema.Struct({
|
|
34
|
+
title: Schema.optionalWith(Schema.String, {
|
|
35
|
+
default: () => "Blog"
|
|
36
|
+
}).annotations({
|
|
37
|
+
description: "The title of the blog"
|
|
38
|
+
}),
|
|
39
|
+
enableRSS: Schema.optionalWith(Schema.Boolean, {
|
|
40
|
+
default: () => true
|
|
41
|
+
}).annotations({
|
|
42
|
+
description: "Enable RSS feed"
|
|
43
|
+
}),
|
|
44
|
+
route: Schema.optionalWith(Schema.String, {
|
|
45
|
+
default: () => "/blog"
|
|
46
|
+
}).annotations({
|
|
47
|
+
description: "The route for the blog",
|
|
48
|
+
examples: ["/blog", "/news", "/articles"]
|
|
49
|
+
})
|
|
50
|
+
}).annotations({
|
|
51
|
+
description: "The configuration for the blog"
|
|
52
|
+
});
|
|
53
|
+
const FrontEndConfigSchema = Schema.Struct({
|
|
54
|
+
htmlDefaultLanguage: Schema.optionalWith(Schema.String, {
|
|
55
|
+
default: () => "en"
|
|
56
|
+
}).annotations({
|
|
57
|
+
description: "The default language for the HTML tag"
|
|
58
|
+
}),
|
|
59
|
+
htmlDefaultHead: HeadConfigSchema.fields.head.annotations({
|
|
60
|
+
description: "The default head configuration for the Frontend"
|
|
61
|
+
}),
|
|
62
|
+
favicon: Schema.optionalWith(FaviconSchema, {
|
|
63
|
+
default: () => "/favicon.svg"
|
|
64
|
+
}).annotations({
|
|
65
|
+
description: "The default favicon configuration for the Frontend"
|
|
66
|
+
}),
|
|
67
|
+
sitemap: Schema.optionalWith(Schema.Boolean, {
|
|
68
|
+
default: () => true
|
|
69
|
+
}).annotations({
|
|
70
|
+
description: "Enable sitemap generation"
|
|
71
|
+
}),
|
|
72
|
+
injectRoutes: Schema.optionalWith(Schema.Boolean, {
|
|
73
|
+
default: () => true
|
|
74
|
+
}).annotations({
|
|
75
|
+
description: "Inject routes"
|
|
76
|
+
}),
|
|
77
|
+
blog: Schema.optionalWith(FrontEndBlogSchema, {
|
|
78
|
+
default: () => FrontEndBlogSchema.make({})
|
|
79
|
+
}).annotations({
|
|
80
|
+
description: "The configuration for the blog"
|
|
81
|
+
})
|
|
82
|
+
});
|
|
67
83
|
export {
|
|
84
|
+
FaviconSchema,
|
|
85
|
+
FrontEndBlogSchema,
|
|
68
86
|
FrontEndConfigSchema,
|
|
69
87
|
faviconTypeMap,
|
|
70
88
|
isFaviconExt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/blog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Add a blog to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "withstudiocms",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"@types/node": "^22.0.0",
|
|
61
61
|
"astro": "^5.12.9",
|
|
62
62
|
"vite": "^6.3.4",
|
|
63
|
-
"@studiocms/md": "^0.
|
|
64
|
-
"studiocms": "^0.
|
|
63
|
+
"@studiocms/md": "^0.3.0",
|
|
64
|
+
"studiocms": "^0.4.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"effect": "^3.19.
|
|
67
|
+
"effect": "^3.19.19"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|