@studiocms/blog 0.1.0-beta.26 → 0.1.0-beta.27
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/README.md +2 -0
- package/dist/components/PageList.astro +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +64 -51
- package/dist/routes/rss.xml.js +1 -7
- package/dist/types.d.ts +9 -0
- package/dist/types.js +3 -1
- package/dist/utils/remapFilter.d.ts +2 -1
- package/dist/utils/remapFilter.js +1 -4
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# StudioCMS - Blog Provider
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/github/withstudiocms/studiocms)
|
|
4
|
+
|
|
3
5
|
For information and docs related to this package see [The StudioCMS Docs](https://docs.studiocms.dev/package-catalog/studiocms-plugins/studiocms-blog/)
|
|
4
6
|
|
|
5
7
|
## License
|
|
@@ -3,7 +3,7 @@ import blogConfig from 'studiocms:blog/config';
|
|
|
3
3
|
import { FormattedDate } from 'studiocms:components';
|
|
4
4
|
import { CustomImage } from 'studiocms:imageHandler/components';
|
|
5
5
|
import { pathWithBase } from 'studiocms:lib';
|
|
6
|
-
import type { CombinedPageData } from 'studiocms
|
|
6
|
+
import type { CombinedPageData } from 'studiocms/sdk/types';
|
|
7
7
|
import { getHeroImage } from './heroHelper.js';
|
|
8
8
|
|
|
9
9
|
const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { AstroIntegration } from 'astro';
|
|
1
2
|
import { type StudioCMSPlugin } from 'studiocms/plugins';
|
|
2
3
|
import { type StudioCMSBlogOptions } from './types.js';
|
|
4
|
+
export declare function internalBlogIntegration(options?: StudioCMSBlogOptions): AstroIntegration;
|
|
3
5
|
/**
|
|
4
6
|
* Creates and configures the StudioCMS Blog plugin.
|
|
5
7
|
*
|
package/dist/index.js
CHANGED
|
@@ -3,15 +3,75 @@ import { pathWithBase } from "studiocms/lib/pathGenerators";
|
|
|
3
3
|
import { definePlugin } from "studiocms/plugins";
|
|
4
4
|
import { FrontEndConfigSchema } from "./types.js";
|
|
5
5
|
const packageIdentifier = "@studiocms/blog";
|
|
6
|
-
function
|
|
6
|
+
function internalBlogIntegration(options) {
|
|
7
7
|
const resolvedOptions = FrontEndConfigSchema.parse(options);
|
|
8
8
|
const {
|
|
9
9
|
blog: { title, enableRSS, route: orgRoute },
|
|
10
|
-
sitemap,
|
|
11
10
|
injectRoutes,
|
|
12
11
|
...frontendConfig
|
|
13
12
|
} = resolvedOptions;
|
|
14
13
|
const route = pathWithBase(orgRoute);
|
|
14
|
+
const resEntrypoint = (path) => `@studiocms/blog/routes/${path}`;
|
|
15
|
+
return {
|
|
16
|
+
name: packageIdentifier,
|
|
17
|
+
hooks: {
|
|
18
|
+
/* v8 ignore start */
|
|
19
|
+
/* this is tested indirectly via the plugin tests */
|
|
20
|
+
"astro:config:setup": async (params) => {
|
|
21
|
+
const { injectRoute } = params;
|
|
22
|
+
if (injectRoutes) {
|
|
23
|
+
injectRoute({
|
|
24
|
+
entrypoint: resEntrypoint("[...slug].astro"),
|
|
25
|
+
pattern: pathWithBase("[...slug]"),
|
|
26
|
+
prerender: false
|
|
27
|
+
});
|
|
28
|
+
injectRoute({
|
|
29
|
+
entrypoint: resEntrypoint("blog/index.astro"),
|
|
30
|
+
pattern: `${route}`,
|
|
31
|
+
prerender: false
|
|
32
|
+
});
|
|
33
|
+
injectRoute({
|
|
34
|
+
entrypoint: resEntrypoint("blog/[...slug].astro"),
|
|
35
|
+
pattern: `${route}/[...slug]`,
|
|
36
|
+
prerender: false
|
|
37
|
+
});
|
|
38
|
+
if (enableRSS) {
|
|
39
|
+
injectRoute({
|
|
40
|
+
entrypoint: resEntrypoint("rss.xml.js"),
|
|
41
|
+
pattern: pathWithBase("rss.xml"),
|
|
42
|
+
prerender: false
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
addVirtualImports(params, {
|
|
47
|
+
name: packageIdentifier,
|
|
48
|
+
imports: {
|
|
49
|
+
"studiocms:blog/config": `
|
|
50
|
+
const config = {
|
|
51
|
+
title: ${JSON.stringify(title)},
|
|
52
|
+
enableRSS: ${enableRSS},
|
|
53
|
+
route: ${JSON.stringify(route)}
|
|
54
|
+
}
|
|
55
|
+
export default config;
|
|
56
|
+
`,
|
|
57
|
+
"studiocms:blog/frontend-config": `
|
|
58
|
+
const config = ${JSON.stringify(frontendConfig)};
|
|
59
|
+
export default config;
|
|
60
|
+
`
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/* v8 ignore stop */
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function studioCMSBlogPlugin(options) {
|
|
69
|
+
const resolvedOptions = FrontEndConfigSchema.parse(options);
|
|
70
|
+
const {
|
|
71
|
+
blog: { title, route: orgRoute },
|
|
72
|
+
sitemap
|
|
73
|
+
} = resolvedOptions;
|
|
74
|
+
const route = pathWithBase(orgRoute);
|
|
15
75
|
const { resolve } = createResolver(import.meta.url);
|
|
16
76
|
const editor = resolve("./components/editor.astro");
|
|
17
77
|
const renderer = resolve("./components/renderer.astro");
|
|
@@ -22,55 +82,7 @@ function studioCMSBlogPlugin(options) {
|
|
|
22
82
|
requires: ["@studiocms/md"],
|
|
23
83
|
hooks: {
|
|
24
84
|
"studiocms:astro:config": ({ addIntegrations }) => {
|
|
25
|
-
addIntegrations(
|
|
26
|
-
name: packageIdentifier,
|
|
27
|
-
hooks: {
|
|
28
|
-
"astro:config:setup": async (params) => {
|
|
29
|
-
const { injectRoute } = params;
|
|
30
|
-
if (injectRoutes) {
|
|
31
|
-
injectRoute({
|
|
32
|
-
entrypoint: resolve("./routes/[...slug].astro"),
|
|
33
|
-
pattern: pathWithBase("[...slug]"),
|
|
34
|
-
prerender: false
|
|
35
|
-
});
|
|
36
|
-
injectRoute({
|
|
37
|
-
entrypoint: resolve("./routes/blog/index.astro"),
|
|
38
|
-
pattern: `${route}`,
|
|
39
|
-
prerender: false
|
|
40
|
-
});
|
|
41
|
-
injectRoute({
|
|
42
|
-
entrypoint: resolve("./routes/blog/[...slug].astro"),
|
|
43
|
-
pattern: `${route}/[...slug]`,
|
|
44
|
-
prerender: false
|
|
45
|
-
});
|
|
46
|
-
if (enableRSS) {
|
|
47
|
-
injectRoute({
|
|
48
|
-
entrypoint: resolve("./routes/rss.xml.js"),
|
|
49
|
-
pattern: pathWithBase("rss.xml"),
|
|
50
|
-
prerender: false
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
addVirtualImports(params, {
|
|
55
|
-
name: packageIdentifier,
|
|
56
|
-
imports: {
|
|
57
|
-
"studiocms:blog/config": `
|
|
58
|
-
const config = {
|
|
59
|
-
title: ${JSON.stringify(title)},
|
|
60
|
-
enableRSS: ${enableRSS},
|
|
61
|
-
route: ${JSON.stringify(route)}
|
|
62
|
-
}
|
|
63
|
-
export default config;
|
|
64
|
-
`,
|
|
65
|
-
"studiocms:blog/frontend-config": `
|
|
66
|
-
const config = ${JSON.stringify(frontendConfig)};
|
|
67
|
-
export default config;
|
|
68
|
-
`
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
85
|
+
addIntegrations(internalBlogIntegration(resolvedOptions));
|
|
74
86
|
},
|
|
75
87
|
"studiocms:config:setup": ({ setFrontend, setRendering, setSitemap }) => {
|
|
76
88
|
setFrontend({
|
|
@@ -106,5 +118,6 @@ function studioCMSBlogPlugin(options) {
|
|
|
106
118
|
var index_default = studioCMSBlogPlugin;
|
|
107
119
|
export {
|
|
108
120
|
index_default as default,
|
|
121
|
+
internalBlogIntegration,
|
|
109
122
|
studioCMSBlogPlugin
|
|
110
123
|
};
|
package/dist/routes/rss.xml.js
CHANGED
|
@@ -3,13 +3,7 @@ import { pathWithBase } from "studiocms:lib";
|
|
|
3
3
|
import { SDKCore } from "studiocms:sdk";
|
|
4
4
|
import rss, {} from "@astrojs/rss";
|
|
5
5
|
import { createJsonResponse, Effect, withEffectAPI } from "studiocms/effect";
|
|
6
|
-
|
|
7
|
-
function getBlogRoute(slug) {
|
|
8
|
-
if (blogRouteFullPath) {
|
|
9
|
-
return blogRouteFullPath.replace("[...slug]", slug);
|
|
10
|
-
}
|
|
11
|
-
return "#";
|
|
12
|
-
}
|
|
6
|
+
import { getBlogRoute } from "../utils/remapFilter.js";
|
|
13
7
|
const GET = withEffectAPI(
|
|
14
8
|
Effect.fn(function* ({ site: _site, locals }) {
|
|
15
9
|
const sdk = yield* SDKCore;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import { z } from 'astro/zod';
|
|
|
2
2
|
import { HeadConfigSchema } from 'studiocms/lib/head';
|
|
3
3
|
export type HeadUserConfig = z.input<ReturnType<typeof HeadConfigSchema>>;
|
|
4
4
|
export type HeadConfig = z.output<ReturnType<typeof HeadConfigSchema>>;
|
|
5
|
+
export declare const faviconTypeMap: {
|
|
6
|
+
'.ico': string;
|
|
7
|
+
'.gif': string;
|
|
8
|
+
'.jpeg': string;
|
|
9
|
+
'.jpg': string;
|
|
10
|
+
'.png': string;
|
|
11
|
+
'.svg': string;
|
|
12
|
+
};
|
|
13
|
+
export declare function isFaviconExt(ext: string): ext is keyof typeof faviconTypeMap;
|
|
5
14
|
/**
|
|
6
15
|
* Options for configuring the StudioCMS Blog.
|
|
7
16
|
*/
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { PageDataCacheObject } from 'studiocms:sdk/types';
|
|
2
1
|
import type { APIContext } from 'astro';
|
|
2
|
+
import type { PageDataCacheObject } from 'studiocms/sdk/types';
|
|
3
3
|
export declare function getBlogRoute(slug: string): string;
|
|
4
4
|
export type SiteMapTemplate = {
|
|
5
5
|
location: string;
|
|
6
6
|
}[];
|
|
7
|
+
export type { APIContext, PageDataCacheObject };
|
|
7
8
|
export declare const remapFilterSitemap: ((filter: string, context: APIContext, blog?: boolean) => (array: Array<PageDataCacheObject>) => SiteMapTemplate) & ((array: Array<PageDataCacheObject>, filter: string, context: APIContext, blog?: boolean) => SiteMapTemplate);
|
|
@@ -3,10 +3,7 @@ import { pathWithBase } from "studiocms:lib";
|
|
|
3
3
|
import { dual } from "studiocms/effect";
|
|
4
4
|
const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
|
|
5
5
|
function getBlogRoute(slug) {
|
|
6
|
-
|
|
7
|
-
return blogRouteFullPath.replace("[...slug]", slug);
|
|
8
|
-
}
|
|
9
|
-
return "#";
|
|
6
|
+
return blogRouteFullPath.replace("[...slug]", slug);
|
|
10
7
|
}
|
|
11
8
|
const remapFilterSitemap = dual(4, (array, filter, context, blog = false) => {
|
|
12
9
|
function genLocation(slug) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/blog",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.27",
|
|
4
4
|
"description": "Add a blog to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "withstudiocms",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
".": {
|
|
49
49
|
"types": "./dist/index.d.ts",
|
|
50
50
|
"default": "./dist/index.js"
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"./routes/*": "./dist/routes/*"
|
|
52
53
|
},
|
|
53
54
|
"type": "module",
|
|
54
55
|
"dependencies": {
|
|
@@ -60,14 +61,15 @@
|
|
|
60
61
|
},
|
|
61
62
|
"peerDependencies": {
|
|
62
63
|
"astro": "^5.12.9",
|
|
63
|
-
"effect": "^3.17.
|
|
64
|
+
"effect": "^3.17.14",
|
|
64
65
|
"vite": "^6.3.4",
|
|
65
|
-
"@studiocms/md": "0.1.0-beta.
|
|
66
|
-
"studiocms": "0.1.0-beta.
|
|
66
|
+
"@studiocms/md": "0.1.0-beta.27",
|
|
67
|
+
"studiocms": "0.1.0-beta.27"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
70
71
|
"dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png,d.ts}'",
|
|
71
|
-
"typecheck": "tspc -p tsconfig.tspc.json"
|
|
72
|
+
"typecheck": "tspc -p tsconfig.tspc.json",
|
|
73
|
+
"test": "vitest"
|
|
72
74
|
}
|
|
73
75
|
}
|