@studiocms/blog 0.1.0-beta.9 → 0.1.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/LICENSE +1 -1
- package/README.md +9 -1
- package/dist/blog.d.ts +13 -0
- package/dist/components/BaseHead.astro +13 -15
- package/dist/components/Navigation.astro +5 -6
- package/dist/components/PageList.astro +3 -2
- package/dist/components/PostHeader.astro +5 -2
- package/dist/components/consts.d.ts +1 -0
- package/dist/components/consts.js +4 -0
- package/dist/components/editor.astro +8 -0
- package/dist/components/heroHelper.d.ts +22 -0
- package/dist/components/heroHelper.js +17 -0
- package/dist/components/render.d.ts +15 -0
- package/dist/components/render.js +10 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +105 -59
- package/dist/layouts/Layout.astro +3 -8
- package/dist/routes/[...slug].astro +5 -16
- package/dist/routes/blog/[...slug].astro +13 -17
- package/dist/routes/blog/index.astro +18 -10
- package/dist/routes/rss.xml.d.ts +1 -2
- package/dist/routes/rss.xml.js +36 -27
- package/dist/routes/sitemap-md.xml.d.ts +1 -2
- package/dist/routes/sitemap-md.xml.js +22 -14
- package/dist/routes/sitemap-posts.xml.d.ts +1 -2
- package/dist/routes/sitemap-posts.xml.js +22 -22
- package/dist/styles/base.css +0 -1
- package/dist/types.d.ts +85 -8
- package/dist/types.js +71 -0
- package/dist/utils/remapFilter.d.ts +8 -0
- package/dist/utils/remapFilter.js +20 -0
- package/package.json +22 -16
- package/dist/blog.d.js +0 -0
- package/dist/components.d.js +0 -0
- package/dist/components.d.ts +0 -13
- package/dist/lib.d.js +0 -0
- package/dist/lib.d.ts +0 -82
- package/dist/renderer.d.js +0 -0
- package/dist/renderer.d.ts +0 -9
- package/dist/routes/rss.xml.ts +0 -44
- package/dist/routes/sitemap-md.xml.ts +0 -28
- package/dist/routes/sitemap-posts.xml.ts +0 -38
- package/dist/sdk.d.js +0 -0
- package/dist/sdk.d.ts +0 -56
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025-present StudioCMS - withstudiocms (https://github.com/withstudiocms)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
# StudioCMS - Blog Provider
|
|
1
|
+
# StudioCMS - Blog Provider
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/github/withstudiocms/studiocms)
|
|
4
|
+
|
|
5
|
+
For information and docs related to this package see [The StudioCMS Docs](https://docs.studiocms.dev/package-catalog/studiocms-plugins/studiocms-blog/)
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
[MIT Licensed](./LICENSE).
|
package/dist/blog.d.ts
CHANGED
|
@@ -6,3 +6,16 @@ declare module 'studiocms:blog/config' {
|
|
|
6
6
|
};
|
|
7
7
|
export default config;
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
declare module 'studiocms:blog/frontend-config' {
|
|
11
|
+
const config: {
|
|
12
|
+
htmlDefaultLanguage: string;
|
|
13
|
+
htmlDefaultHead: {
|
|
14
|
+
tag: 'title' | 'base' | 'link' | 'style' | 'meta' | 'script' | 'noscript' | 'template';
|
|
15
|
+
attrs: Record<string, string | boolean | undefined>;
|
|
16
|
+
content: string;
|
|
17
|
+
}[];
|
|
18
|
+
favicon: string;
|
|
19
|
+
};
|
|
20
|
+
export default config;
|
|
21
|
+
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '../styles/base.css';
|
|
3
|
-
import config from 'studiocms:config';
|
|
3
|
+
import config from 'studiocms:blog/frontend-config';
|
|
4
4
|
import {
|
|
5
|
+
createHead,
|
|
5
6
|
type HeadConfig,
|
|
6
7
|
type HeadConfigSchema,
|
|
7
8
|
type HeadUserConfig,
|
|
8
|
-
createHead,
|
|
9
9
|
headDefaults,
|
|
10
10
|
} from 'studiocms:lib';
|
|
11
11
|
import type { z } from 'astro/zod';
|
|
12
|
+
import { getHeroImage } from './heroHelper.js';
|
|
12
13
|
|
|
13
14
|
let htmlDefaultHead: HeadUserConfig = [];
|
|
14
15
|
let favicon = '';
|
|
15
16
|
|
|
16
|
-
if (config
|
|
17
|
-
if (config.
|
|
18
|
-
htmlDefaultHead.push(...config.
|
|
17
|
+
if (config && typeof config === 'object') {
|
|
18
|
+
if (config.htmlDefaultHead) {
|
|
19
|
+
htmlDefaultHead.push(...config.htmlDefaultHead);
|
|
19
20
|
}
|
|
20
|
-
if (config.
|
|
21
|
-
favicon = config.
|
|
21
|
+
if (config.favicon) {
|
|
22
|
+
favicon = config.favicon;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -26,19 +27,16 @@ interface Props {
|
|
|
26
27
|
title: string;
|
|
27
28
|
description: string;
|
|
28
29
|
lang?: string | undefined;
|
|
29
|
-
image?: string | undefined;
|
|
30
|
+
image?: string | null | undefined;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
const canonicalURL = Astro.url;
|
|
33
34
|
|
|
34
|
-
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
lang = 'en',
|
|
38
|
-
image = 'https://images.unsplash.com/photo-1707343843982-f8275f3994c5?q=80&w=1032&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
|
|
39
|
-
} = Astro.props;
|
|
35
|
+
const { title, description, lang = 'en', image } = Astro.props;
|
|
36
|
+
|
|
37
|
+
const ogImage = getHeroImage(image, Astro);
|
|
40
38
|
|
|
41
|
-
const makeHeader = headDefaults(title, description, lang, Astro, favicon,
|
|
39
|
+
const makeHeader = headDefaults(title, description, lang, Astro, favicon, ogImage, canonicalURL);
|
|
42
40
|
|
|
43
41
|
const StudioCMSFrontEndHeads: z.input<ReturnType<typeof HeadConfigSchema>> = [
|
|
44
42
|
// Fonts
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { StudioCMSRoutes } from 'studiocms:lib';
|
|
3
2
|
import './navigation.css';
|
|
4
3
|
import { frontendNavigation } from 'studiocms:plugin-helpers';
|
|
5
|
-
import studioCMS_SDK from 'studiocms:sdk/cache';
|
|
6
4
|
|
|
7
5
|
type Props = {
|
|
8
6
|
topLevelLinkCount?: number;
|
|
@@ -10,12 +8,13 @@ type Props = {
|
|
|
10
8
|
|
|
11
9
|
const { topLevelLinkCount = 3 } = Astro.props;
|
|
12
10
|
|
|
13
|
-
const config =
|
|
11
|
+
const config = Astro.locals.StudioCMS.siteConfig.data;
|
|
14
12
|
|
|
15
13
|
const { title } = config || { title: 'StudioCMS' };
|
|
16
14
|
const {
|
|
17
15
|
mainLinks: { baseSiteURL },
|
|
18
|
-
|
|
16
|
+
authLinks: { loginURL },
|
|
17
|
+
} = Astro.locals.StudioCMS.routeMap;
|
|
19
18
|
|
|
20
19
|
type LinkProps = {
|
|
21
20
|
text: string;
|
|
@@ -45,7 +44,7 @@ const links: LinkProps[] = await frontendNavigation();
|
|
|
45
44
|
))
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
<a class="avatar" href={
|
|
47
|
+
<a class="avatar" href={loginURL}>Dashboard</a>
|
|
49
48
|
</div>
|
|
50
49
|
) }
|
|
51
50
|
|
|
@@ -78,6 +77,6 @@ const links: LinkProps[] = await frontendNavigation();
|
|
|
78
77
|
</div>
|
|
79
78
|
</div>
|
|
80
79
|
|
|
81
|
-
<a class="avatar" href={
|
|
80
|
+
<a class="avatar" href={loginURL}>Dashboard</a>
|
|
82
81
|
</div>
|
|
83
82
|
) }
|
|
@@ -3,7 +3,8 @@ 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
|
+
import { getHeroImage } from './heroHelper.js';
|
|
7
8
|
|
|
8
9
|
const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
|
|
9
10
|
|
|
@@ -26,7 +27,7 @@ const { blogPageList } = Astro.props;
|
|
|
26
27
|
blogPageList.length > 0 && blogPageList.map(({slug, heroImage, title, description, publishedAt}) => (
|
|
27
28
|
<li>
|
|
28
29
|
<a href={pathWithBase(getBlogRoute(slug))}>
|
|
29
|
-
<CustomImage src={heroImage} alt={title} width={720} height={360}/>
|
|
30
|
+
<CustomImage src={getHeroImage(heroImage, Astro)} alt={title} width={720} height={360}/>
|
|
30
31
|
<div>
|
|
31
32
|
<span class="title">{title}</span>
|
|
32
33
|
<span class="date"> <FormattedDate date={publishedAt} /> </span>
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { FormattedDate } from 'studiocms:components';
|
|
3
3
|
import { CustomImage } from 'studiocms:imageHandler/components';
|
|
4
|
+
import { getHeroImage } from './heroHelper.js';
|
|
4
5
|
|
|
5
6
|
interface Props {
|
|
6
7
|
title: string;
|
|
7
8
|
publishedAt: Date;
|
|
8
9
|
updatedAt?: Date | null;
|
|
9
|
-
heroImage
|
|
10
|
+
heroImage?: string | null | undefined;
|
|
10
11
|
description: string;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
const { title, description, heroImage, publishedAt, updatedAt } = Astro.props;
|
|
15
|
+
|
|
16
|
+
const heroImageToUse = getHeroImage(heroImage, Astro);
|
|
14
17
|
---
|
|
15
18
|
<h1 class="title">{title}</h1>
|
|
16
19
|
|
|
17
20
|
<div style="text-align: center;">
|
|
18
|
-
<CustomImage src={
|
|
21
|
+
<CustomImage src={heroImageToUse} alt={title} width={720} height={360}/>
|
|
19
22
|
<div>
|
|
20
23
|
<p class="date">Published: <FormattedDate date={publishedAt}/></p>
|
|
21
24
|
{updatedAt && <p class="date"> | Last Updated: <FormattedDate date={updatedAt}/></p>}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FALLBACK_OG_IMAGE = "https://images.unsplash.com/photo-1707343843982-f8275f3994c5?q=80&w=1032&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AstroGlobal } from 'astro';
|
|
2
|
+
/**
|
|
3
|
+
* Trims leading and trailing whitespace from the given input string.
|
|
4
|
+
*
|
|
5
|
+
* @param input - The string to trim. Can be `string`, `null`, or `undefined`.
|
|
6
|
+
* @returns The trimmed string, or `undefined` if the input is `null` or `undefined`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function trimInput(input: string | null | undefined): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the appropriate hero image URL based on the provided `hero` string,
|
|
11
|
+
* the site's default OG image, or a fallback image.
|
|
12
|
+
*
|
|
13
|
+
* The function checks the following, in order:
|
|
14
|
+
* 1. If a valid `hero` image URL is provided, it returns that.
|
|
15
|
+
* 2. If not, it attempts to use the site's default OG image from the Astro global context.
|
|
16
|
+
* 3. If neither is available, it returns a constant fallback image URL.
|
|
17
|
+
*
|
|
18
|
+
* @param hero - The primary hero image URL, or `undefined` if not provided.
|
|
19
|
+
* @param Astro - The Astro global context, used to access site configuration.
|
|
20
|
+
* @returns The resolved hero image URL as a string.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getHeroImage(hero: string | null | undefined, Astro: AstroGlobal): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FALLBACK_OG_IMAGE } from "./consts.js";
|
|
2
|
+
function trimInput(input) {
|
|
3
|
+
if (input == null) return void 0;
|
|
4
|
+
const trimmed = input.trim();
|
|
5
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
6
|
+
}
|
|
7
|
+
function getHeroImage(hero, Astro) {
|
|
8
|
+
const primary = trimInput(hero);
|
|
9
|
+
const siteFallback = trimInput(Astro.locals?.StudioCMS?.siteConfig?.data?.defaultOgImage);
|
|
10
|
+
if (primary) return primary;
|
|
11
|
+
if (siteFallback) return siteFallback;
|
|
12
|
+
return FALLBACK_OG_IMAGE;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
getHeroImage,
|
|
16
|
+
trimInput
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const renderer: {
|
|
2
|
+
name: string;
|
|
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;
|
|
14
|
+
};
|
|
15
|
+
export default renderer;
|
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
|
-
import type
|
|
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
|
@@ -1,75 +1,120 @@
|
|
|
1
1
|
import { addVirtualImports, createResolver } from "astro-integration-kit";
|
|
2
|
-
import { pathWithBase } from "studiocms/lib/pathGenerators
|
|
2
|
+
import { pathWithBase } from "studiocms/lib/pathGenerators";
|
|
3
3
|
import { definePlugin } from "studiocms/plugins";
|
|
4
|
+
import { FrontEndConfigSchema } from "./types.js";
|
|
4
5
|
const packageIdentifier = "@studiocms/blog";
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
pattern: pathWithBase("[...slug]"),
|
|
39
|
-
prerender: false
|
|
40
|
-
});
|
|
41
|
-
injectRoute({
|
|
42
|
-
entrypoint: resolve("./routes/blog/index.astro"),
|
|
43
|
-
pattern: `${route}`,
|
|
44
|
-
prerender: false
|
|
45
|
-
});
|
|
6
|
+
function internalBlogIntegration(options) {
|
|
7
|
+
const resolvedOptions = FrontEndConfigSchema.parse(options);
|
|
8
|
+
const {
|
|
9
|
+
blog: { title, enableRSS, route: orgRoute },
|
|
10
|
+
injectRoutes,
|
|
11
|
+
...frontendConfig
|
|
12
|
+
} = resolvedOptions;
|
|
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) {
|
|
46
39
|
injectRoute({
|
|
47
|
-
entrypoint:
|
|
48
|
-
pattern:
|
|
40
|
+
entrypoint: resEntrypoint("rss.xml.js"),
|
|
41
|
+
pattern: pathWithBase("rss.xml"),
|
|
49
42
|
prerender: false
|
|
50
43
|
});
|
|
51
|
-
if (enableRSS) {
|
|
52
|
-
injectRoute({
|
|
53
|
-
entrypoint: resolve("./routes/rss.xml.js"),
|
|
54
|
-
pattern: pathWithBase("rss.xml"),
|
|
55
|
-
prerender: false
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
44
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
}
|
|
46
|
+
addVirtualImports(params, {
|
|
47
|
+
name: packageIdentifier,
|
|
48
|
+
imports: {
|
|
49
|
+
"studiocms:blog/config": `
|
|
63
50
|
const config = {
|
|
64
|
-
title:
|
|
51
|
+
title: ${JSON.stringify(title)},
|
|
65
52
|
enableRSS: ${enableRSS},
|
|
66
|
-
route:
|
|
53
|
+
route: ${JSON.stringify(route)}
|
|
67
54
|
}
|
|
68
55
|
export default config;
|
|
56
|
+
`,
|
|
57
|
+
"studiocms:blog/frontend-config": `
|
|
58
|
+
const config = ${JSON.stringify(frontendConfig)};
|
|
59
|
+
export default config;
|
|
69
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);
|
|
75
|
+
const { resolve } = createResolver(import.meta.url);
|
|
76
|
+
const editor = resolve("./components/editor.astro");
|
|
77
|
+
const renderer = resolve("./components/render.js");
|
|
78
|
+
return definePlugin({
|
|
79
|
+
identifier: packageIdentifier,
|
|
80
|
+
name: "StudioCMS Blog",
|
|
81
|
+
studiocmsMinimumVersion: "0.1.0-beta.21",
|
|
82
|
+
requires: ["@studiocms/md"],
|
|
83
|
+
hooks: {
|
|
84
|
+
"studiocms:astro-config": ({ addIntegrations }) => {
|
|
85
|
+
addIntegrations(internalBlogIntegration(resolvedOptions));
|
|
86
|
+
},
|
|
87
|
+
"studiocms:frontend": ({ setFrontend }) => {
|
|
88
|
+
setFrontend({
|
|
89
|
+
frontendNavigationLinks: [{ label: title, href: route }]
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
"studiocms:rendering": ({ setRendering }) => {
|
|
93
|
+
setRendering({
|
|
94
|
+
pageTypes: [
|
|
95
|
+
{
|
|
96
|
+
identifier: packageIdentifier,
|
|
97
|
+
label: "Blog Post (StudioCMS Blog)",
|
|
98
|
+
pageContentComponent: editor,
|
|
99
|
+
rendererComponent: renderer
|
|
70
100
|
}
|
|
71
|
-
|
|
72
|
-
}
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
"studiocms:sitemap": ({ setSitemap }) => {
|
|
105
|
+
setSitemap({
|
|
106
|
+
triggerSitemap: sitemap,
|
|
107
|
+
sitemaps: [
|
|
108
|
+
{
|
|
109
|
+
pluginName: packageIdentifier,
|
|
110
|
+
sitemapXMLEndpointPath: resolve("./routes/sitemap-posts.xml.js")
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
pluginName: "pages",
|
|
114
|
+
sitemapXMLEndpointPath: resolve("./routes/sitemap-md.xml.js")
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
});
|
|
73
118
|
}
|
|
74
119
|
}
|
|
75
120
|
});
|
|
@@ -77,5 +122,6 @@ function studioCMSBlogPlugin(options) {
|
|
|
77
122
|
var index_default = studioCMSBlogPlugin;
|
|
78
123
|
export {
|
|
79
124
|
index_default as default,
|
|
125
|
+
internalBlogIntegration,
|
|
80
126
|
studioCMSBlogPlugin
|
|
81
127
|
};
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
3
|
-
import studioCMS_SDK from 'studiocms:sdk/cache';
|
|
2
|
+
import defaultFrontEndConfig from 'studiocms:blog/frontend-config';
|
|
4
3
|
import BaseHead from '../components/BaseHead.astro';
|
|
5
4
|
import Footer from '../components/Footer.astro';
|
|
6
5
|
import Navigation from '../components/Navigation.astro';
|
|
7
6
|
|
|
8
|
-
const { title: SiteTitle, description: SiteDescription } =
|
|
9
|
-
.data || {
|
|
10
|
-
title: 'StudioCMS - Database Unavailable',
|
|
11
|
-
description: 'StudioCMS - Database Unavailable',
|
|
12
|
-
};
|
|
7
|
+
const { title: SiteTitle, description: SiteDescription } = Astro.locals.StudioCMS.siteConfig.data;
|
|
13
8
|
|
|
14
9
|
let htmlDefaultLanguage = 'en';
|
|
15
10
|
|
|
@@ -23,7 +18,7 @@ type Props = {
|
|
|
23
18
|
title: string;
|
|
24
19
|
description: string;
|
|
25
20
|
lang?: string | undefined;
|
|
26
|
-
heroImage?: string | undefined;
|
|
21
|
+
heroImage?: string | null | undefined;
|
|
27
22
|
siteTitle?: string | undefined;
|
|
28
23
|
siteDescription?: string | undefined;
|
|
29
24
|
pageTitleDelimiter?: string | undefined;
|
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
---
|
|
2
|
-
import config from 'studiocms:config';
|
|
3
2
|
import { StudioCMSRenderer } from 'studiocms:renderer';
|
|
4
|
-
import
|
|
5
|
-
import studioCMS_SDK_Cache from 'studiocms:sdk/cache';
|
|
3
|
+
import { runSDK, SDKCoreJs } from 'studiocms:sdk';
|
|
6
4
|
import Layout from '../layouts/Layout.astro';
|
|
7
5
|
|
|
8
|
-
// This is here to refresh the cache when needed
|
|
9
|
-
const allPages = await studioCMS_SDK_Cache.GET.pages();
|
|
10
|
-
|
|
11
|
-
if (config.dbStartPage) {
|
|
12
|
-
return Astro.redirect('/start');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
6
|
let { slug } = Astro.params;
|
|
16
7
|
|
|
17
8
|
if (!slug) {
|
|
18
9
|
slug = 'index';
|
|
19
10
|
}
|
|
20
11
|
|
|
21
|
-
const page = await
|
|
12
|
+
const page = await runSDK(SDKCoreJs.GET.page.bySlug(slug));
|
|
22
13
|
|
|
23
14
|
if (!page) {
|
|
24
15
|
return new Response(null, { status: 404 });
|
|
25
16
|
}
|
|
26
17
|
|
|
27
|
-
const { title, description, heroImage
|
|
28
|
-
|
|
29
|
-
const content = defaultContent?.content || '';
|
|
18
|
+
const { title, description, heroImage } = page;
|
|
30
19
|
---
|
|
31
20
|
|
|
32
21
|
<Layout title={title} description={description} heroImage={heroImage}>
|
|
33
22
|
<main>
|
|
34
|
-
<StudioCMSRenderer
|
|
23
|
+
<StudioCMSRenderer data={page} />
|
|
35
24
|
</main>
|
|
36
|
-
</Layout>
|
|
25
|
+
</Layout>
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { StudioCMSRenderer } from 'studiocms:renderer';
|
|
3
|
-
import
|
|
4
|
-
import studioCMS_SDK_Cache from 'studiocms:sdk/cache';
|
|
3
|
+
import { runSDK, SDKCoreJs } from 'studiocms:sdk';
|
|
5
4
|
import PostHeader from '../../components/PostHeader.astro';
|
|
6
5
|
import Layout from '../../layouts/Layout.astro';
|
|
7
6
|
|
|
8
|
-
// This is here to refresh the cache when needed
|
|
9
|
-
const allPages = await studioCMS_SDK_Cache.GET.pages();
|
|
10
|
-
|
|
11
7
|
// Get the slug from the URL
|
|
12
8
|
const { slug } = Astro.params;
|
|
13
9
|
|
|
@@ -18,27 +14,27 @@ if (!slug) {
|
|
|
18
14
|
|
|
19
15
|
// Fetch the blog post content
|
|
20
16
|
|
|
21
|
-
const post = await
|
|
17
|
+
const post = await runSDK(SDKCoreJs.GET.page.bySlug(slug));
|
|
22
18
|
|
|
23
19
|
// If no content is found, redirect to 404
|
|
24
20
|
if (!post) {
|
|
25
21
|
return new Response(null, { status: 404 });
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
const { title, description, heroImage, publishedAt, updatedAt
|
|
29
|
-
|
|
30
|
-
// If no content is found, redirect to 404
|
|
31
|
-
if (!defaultContent) {
|
|
32
|
-
return new Response(null, { status: 404 });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const content = defaultContent.content || '';
|
|
24
|
+
const { title, description, heroImage, publishedAt, updatedAt } = post;
|
|
36
25
|
---
|
|
26
|
+
|
|
37
27
|
<Layout {title} {description} {heroImage}>
|
|
38
28
|
<main>
|
|
39
29
|
<article>
|
|
40
|
-
<PostHeader
|
|
41
|
-
|
|
30
|
+
<PostHeader
|
|
31
|
+
{title}
|
|
32
|
+
{description}
|
|
33
|
+
{heroImage}
|
|
34
|
+
{publishedAt}
|
|
35
|
+
{updatedAt}
|
|
36
|
+
/>
|
|
37
|
+
<StudioCMSRenderer data={post} />
|
|
42
38
|
</article>
|
|
43
39
|
</main>
|
|
44
|
-
</Layout>
|
|
40
|
+
</Layout>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
import blogConfig from 'studiocms:blog/config';
|
|
3
|
-
import
|
|
3
|
+
import { runSDK, SDKCoreJs } from 'studiocms:sdk';
|
|
4
4
|
import PageList from '../../components/PageList.astro';
|
|
5
5
|
import RSSIcon from '../../components/RSSIcon.astro';
|
|
6
6
|
import Layout from '../../layouts/Layout.astro';
|
|
7
7
|
|
|
8
|
-
const config =
|
|
9
|
-
description: 'StudioCMS - Database Unavailable',
|
|
10
|
-
};
|
|
8
|
+
const config = Astro.locals.StudioCMS.siteConfig.data;
|
|
11
9
|
|
|
12
10
|
// Set the title and description
|
|
13
11
|
const { description: configDescription } = config;
|
|
@@ -17,16 +15,26 @@ const description: string = configDescription || 'Blog Index';
|
|
|
17
15
|
const showRSSFeed: boolean = blogConfig.enableRSS;
|
|
18
16
|
|
|
19
17
|
// Get all pages
|
|
20
|
-
const blogPageList = (await
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
const blogPageList = (await runSDK(SDKCoreJs.GET.pages())).filter(
|
|
19
|
+
({ package: pkg }) => pkg === '@studiocms/blog'
|
|
20
|
+
);
|
|
23
21
|
|
|
24
22
|
// Get the RSS feed URL
|
|
25
23
|
const rssPath = '/rss.xml';
|
|
26
24
|
---
|
|
27
|
-
|
|
25
|
+
|
|
26
|
+
<Layout {title} description={description}>
|
|
28
27
|
<main>
|
|
29
|
-
<h1>
|
|
28
|
+
<h1>
|
|
29
|
+
{title}
|
|
30
|
+
{
|
|
31
|
+
showRSSFeed && rssPath && (
|
|
32
|
+
<a href={rssPath}>
|
|
33
|
+
<RSSIcon />
|
|
34
|
+
</a>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
</h1>
|
|
30
38
|
<PageList {blogPageList} />
|
|
31
39
|
</main>
|
|
32
|
-
</Layout>
|
|
40
|
+
</Layout>
|
package/dist/routes/rss.xml.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function GET(context: APIContext): Promise<Response>;
|
|
1
|
+
export declare const GET: import("astro").APIRoute;
|