@studiocms/blog 0.1.0-beta.8 → 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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -1
  3. package/dist/blog.d.ts +13 -0
  4. package/dist/components/BaseHead.astro +13 -15
  5. package/dist/components/Navigation.astro +5 -6
  6. package/dist/components/PageList.astro +3 -2
  7. package/dist/components/PostHeader.astro +5 -2
  8. package/dist/components/consts.d.ts +1 -0
  9. package/dist/components/consts.js +4 -0
  10. package/dist/components/editor.astro +8 -0
  11. package/dist/components/heroHelper.d.ts +22 -0
  12. package/dist/components/heroHelper.js +17 -0
  13. package/dist/components/render.d.ts +15 -0
  14. package/dist/components/render.js +10 -0
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.js +105 -59
  17. package/dist/layouts/Layout.astro +3 -8
  18. package/dist/routes/[...slug].astro +5 -16
  19. package/dist/routes/blog/[...slug].astro +13 -17
  20. package/dist/routes/blog/index.astro +18 -10
  21. package/dist/routes/rss.xml.d.ts +1 -2
  22. package/dist/routes/rss.xml.js +36 -27
  23. package/dist/routes/sitemap-md.xml.d.ts +1 -2
  24. package/dist/routes/sitemap-md.xml.js +22 -14
  25. package/dist/routes/sitemap-posts.xml.d.ts +1 -2
  26. package/dist/routes/sitemap-posts.xml.js +22 -22
  27. package/dist/styles/base.css +0 -1
  28. package/dist/types.d.ts +85 -8
  29. package/dist/types.js +71 -0
  30. package/dist/utils/remapFilter.d.ts +8 -0
  31. package/dist/utils/remapFilter.js +20 -0
  32. package/package.json +22 -16
  33. package/dist/blog.d.js +0 -0
  34. package/dist/components.d.js +0 -0
  35. package/dist/components.d.ts +0 -13
  36. package/dist/lib.d.js +0 -0
  37. package/dist/lib.d.ts +0 -82
  38. package/dist/renderer.d.js +0 -0
  39. package/dist/renderer.d.ts +0 -9
  40. package/dist/routes/rss.xml.ts +0 -44
  41. package/dist/routes/sitemap-md.xml.ts +0 -28
  42. package/dist/routes/sitemap-posts.xml.ts +0 -38
  43. package/dist/sdk.d.js +0 -0
  44. package/dist/sdk.d.ts +0 -56
@@ -1,34 +1,43 @@
1
1
  import blogConfig from "studiocms:blog/config";
2
2
  import { pathWithBase } from "studiocms:lib";
3
- import studioCMS_SDK from "studiocms:sdk/cache";
3
+ import { SDKCore } from "studiocms:sdk";
4
4
  import rss, {} from "@astrojs/rss";
5
- const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
6
- function getBlogRoute(slug) {
7
- if (blogRouteFullPath) {
8
- return blogRouteFullPath.replace("[...slug]", slug);
5
+ import { createJsonResponse, Effect, withEffectAPI } from "studiocms/effect";
6
+ import { getBlogRoute } from "../utils/remapFilter.js";
7
+ const GET = withEffectAPI(
8
+ Effect.fn(function* ({ site: _site, locals }) {
9
+ const sdk = yield* SDKCore;
10
+ const config = locals?.StudioCMS?.siteConfig?.data;
11
+ const siteTitle = config?.title ?? "StudioCMS";
12
+ const title = `${siteTitle} | ${blogConfig.title}`;
13
+ const description = config?.description ?? "Blog";
14
+ const site = _site ?? "https://example.com";
15
+ const posts = yield* sdk.GET.pages();
16
+ const sortedPosts = posts.filter(({ package: pkg }) => pkg === "@studiocms/blog").sort((a, b) => new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime());
17
+ const items = sortedPosts.map(
18
+ ({ title: title2, description: description2, publishedAt, slug, categories: categoryData }) => {
19
+ const link = pathWithBase(getBlogRoute(slug));
20
+ const categories = (categoryData ?? []).map(({ name }) => name);
21
+ const pubDate = typeof publishedAt === "string" ? new Date(publishedAt) : publishedAt;
22
+ return {
23
+ title: title2,
24
+ description: description2,
25
+ pubDate,
26
+ link,
27
+ categories
28
+ };
29
+ }
30
+ );
31
+ return rss({ title, description, site, items });
32
+ }),
33
+ {
34
+ cors: { methods: ["GET"], origin: "*" },
35
+ onError: async (error) => {
36
+ console.error("Error generating RSS feed:", error);
37
+ return createJsonResponse({ error: "Something went wrong" }, { status: 500 });
38
+ }
9
39
  }
10
- return "#";
11
- }
12
- async function GET(context) {
13
- const config = (await studioCMS_SDK.GET.siteConfig()).data || {
14
- title: "StudioCMS - Database Unavailable",
15
- description: "StudioCMS - Database Unavailable"
16
- };
17
- const title = `${config?.title} | ${blogConfig.title}`;
18
- const description = config?.description ?? "Blog";
19
- const site = context.site ?? "https://example.com";
20
- const orderedPosts = (await studioCMS_SDK.GET.pages()).map(({ data }) => data).filter(({ package: pkg }) => pkg === "@studiocms/blog");
21
- const items = orderedPosts.map((post) => {
22
- return {
23
- title: post.title,
24
- description: post.description,
25
- pubDate: post.publishedAt,
26
- link: pathWithBase(getBlogRoute(post.slug)),
27
- categories: post.categories.map(({ name }) => name)
28
- };
29
- });
30
- return rss({ title, description, site, items });
31
- }
40
+ );
32
41
  export {
33
42
  GET
34
43
  };
@@ -1,2 +1 @@
1
- import type { APIRoute } from 'astro';
2
- export declare const GET: APIRoute;
1
+ export declare const GET: import("astro").APIRoute;
@@ -1,22 +1,30 @@
1
- import { pathWithBase } from "studiocms:lib";
2
- import studioCMS_SDK from "studiocms:sdk/cache";
1
+ import { SDKCore } from "studiocms:sdk";
2
+ import { createJsonResponse, Effect, pipe, withEffectAPI } from "studiocms/effect";
3
+ import { remapFilterSitemap } from "../utils/remapFilter.js";
3
4
  const template = (entries) => `<?xml version="1.0" encoding="UTF-8"?>
4
5
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
5
6
  ${entries.map((entry) => `<url><loc>${entry.location}</loc></url>`).join("")}
6
7
  </urlset>`;
7
- const GET = async (context) => {
8
- const orderedPosts = (await studioCMS_SDK.GET.pages()).map(({ data }) => data).filter(({ package: pkg }) => pkg === "studiocms/markdown");
9
- const sitemapLinks = orderedPosts.map((post) => ({
10
- location: new URL(pathWithBase(post.slug), context.url).toString()
11
- }));
12
- const sitemap = template(sitemapLinks);
13
- return new Response(sitemap, {
14
- status: 200,
15
- headers: {
16
- "Content-Type": "application/xml"
8
+ const GET = withEffectAPI(
9
+ Effect.fn(function* (ctx) {
10
+ const sdk = yield* SDKCore;
11
+ const posts = pipe(yield* sdk.GET.pages(), remapFilterSitemap("studiocms/markdown", ctx));
12
+ const sitemap = template(posts);
13
+ return new Response(sitemap, {
14
+ status: 200,
15
+ headers: {
16
+ "Content-Type": "application/xml"
17
+ }
18
+ });
19
+ }),
20
+ {
21
+ cors: { methods: ["GET"], origin: "*" },
22
+ onError: async (error) => {
23
+ console.error("Sitemap API Error:", error);
24
+ return createJsonResponse({ error: "Something went wrong" }, { status: 500 });
17
25
  }
18
- });
19
- };
26
+ }
27
+ );
20
28
  export {
21
29
  GET
22
30
  };
@@ -1,2 +1 @@
1
- import type { APIRoute } from 'astro';
2
- export declare const GET: APIRoute;
1
+ export declare const GET: import("astro").APIRoute;
@@ -1,30 +1,30 @@
1
- import blogConfig from "studiocms:blog/config";
2
- import { pathWithBase } from "studiocms:lib";
3
- import studioCMS_SDK from "studiocms:sdk/cache";
4
- const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
5
- function getBlogRoute(slug) {
6
- if (blogRouteFullPath) {
7
- return blogRouteFullPath.replace("[...slug]", slug);
8
- }
9
- return "#";
10
- }
1
+ import { SDKCore } from "studiocms:sdk";
2
+ import { createJsonResponse, Effect, pipe, withEffectAPI } from "studiocms/effect";
3
+ import { remapFilterSitemap } from "../utils/remapFilter.js";
11
4
  const template = (entries) => `<?xml version="1.0" encoding="UTF-8"?>
12
5
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
13
6
  ${entries.map((entry) => `<url><loc>${entry.location}</loc></url>`).join("")}
14
7
  </urlset>`;
15
- const GET = async (context) => {
16
- const orderedPosts = (await studioCMS_SDK.GET.pages()).map(({ data }) => data).filter(({ package: pkg }) => pkg === "@studiocms/blog");
17
- const sitemapLinks = orderedPosts.map((post) => ({
18
- location: new URL(pathWithBase(getBlogRoute(post.slug)), context.url).toString()
19
- }));
20
- const sitemap = template(sitemapLinks);
21
- return new Response(sitemap, {
22
- status: 200,
23
- headers: {
24
- "Content-Type": "application/xml"
8
+ const GET = withEffectAPI(
9
+ Effect.fn(function* (ctx) {
10
+ const sdk = yield* SDKCore;
11
+ const posts = pipe(yield* sdk.GET.pages(), remapFilterSitemap("@studiocms/blog", ctx, true));
12
+ const sitemap = template(posts);
13
+ return new Response(sitemap, {
14
+ status: 200,
15
+ headers: {
16
+ "Content-Type": "application/xml"
17
+ }
18
+ });
19
+ }),
20
+ {
21
+ cors: { methods: ["GET"], origin: "*" },
22
+ onError: async (error) => {
23
+ console.error("Sitemap API Error:", error);
24
+ return createJsonResponse({ error: "Something went wrong" }, { status: 500 });
25
25
  }
26
- });
27
- };
26
+ }
27
+ );
28
28
  export {
29
29
  GET
30
30
  };
@@ -156,7 +156,6 @@ footer {
156
156
  width: 1px;
157
157
  overflow: hidden;
158
158
  clip: rect(1px 1px 1px 1px);
159
- clip: rect(1px, 1px, 1px, 1px);
160
159
  clip-path: inset(50%);
161
160
  white-space: nowrap;
162
161
  }
package/dist/types.d.ts CHANGED
@@ -1,34 +1,111 @@
1
+ import { z } from 'astro/zod';
2
+ import { HeadConfigSchema } from 'studiocms/lib/head';
3
+ export type HeadUserConfig = z.input<ReturnType<typeof HeadConfigSchema>>;
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;
1
14
  /**
2
15
  * Options for configuring the StudioCMS Blog.
3
16
  */
4
- export interface StudioCMSBlogOptions {
17
+ export declare const FrontEndConfigSchema: z.ZodDefault<z.ZodOptional<z.ZodObject<{
18
+ /**
19
+ * HTML Default Language - The default language for the HTML tag
20
+ * @default 'en'
21
+ */
22
+ htmlDefaultLanguage: z.ZodDefault<z.ZodOptional<z.ZodString>>;
23
+ /**
24
+ * HTML Default Header - The default head configuration for the Frontend
25
+ */
26
+ htmlDefaultHead: z.ZodDefault<z.ZodArray<z.ZodObject<{
27
+ tag: z.ZodEnum<["title", "base", "link", "style", "meta", "script", "noscript", "template"]>;
28
+ attrs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodUndefined]>>>;
29
+ content: z.ZodDefault<z.ZodString>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ tag: "style" | "title" | "base" | "link" | "meta" | "script" | "noscript" | "template";
32
+ attrs: Record<string, string | boolean | undefined>;
33
+ content: string;
34
+ }, {
35
+ tag: "style" | "title" | "base" | "link" | "meta" | "script" | "noscript" | "template";
36
+ attrs?: Record<string, string | boolean | undefined> | undefined;
37
+ content?: string | undefined;
38
+ }>, "many">>;
39
+ /**
40
+ * Favicon Configuration - The default favicon configuration for the Frontend
41
+ */
42
+ favicon: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>>;
5
43
  /**
6
44
  * Enable sitemap generation
7
45
  * @default true
8
46
  */
9
- sitemap?: boolean;
47
+ sitemap: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
48
  /**
11
49
  * Inject routes
12
50
  * @default true
13
51
  */
14
- injectRoutes?: boolean;
52
+ injectRoutes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
15
53
  /**
16
54
  * The configuration for the blog
17
55
  */
18
- blog?: {
56
+ blog: z.ZodDefault<z.ZodOptional<z.ZodObject<{
19
57
  /**
20
58
  * The title of the blog
21
59
  */
22
- title?: string;
60
+ title: z.ZodDefault<z.ZodOptional<z.ZodString>>;
23
61
  /**
24
62
  * Enable RSS feed
25
63
  */
26
- enableRSS?: boolean;
64
+ enableRSS: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
27
65
  /**
28
66
  * The route for the blog
29
67
  * @default '/blog'
30
68
  * @example '/news'
31
69
  */
32
- route?: string;
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;
33
94
  };
34
- }
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>;
package/dist/types.js CHANGED
@@ -0,0 +1,71 @@
1
+ import { extname } from "node:path";
2
+ import { z } from "astro/zod";
3
+ import { HeadConfigSchema } from "studiocms/lib/head";
4
+ const faviconTypeMap = {
5
+ ".ico": "image/x-icon",
6
+ ".gif": "image/gif",
7
+ ".jpeg": "image/jpeg",
8
+ ".jpg": "image/jpeg",
9
+ ".png": "image/png",
10
+ ".svg": "image/svg+xml"
11
+ };
12
+ function isFaviconExt(ext) {
13
+ return ext in faviconTypeMap;
14
+ }
15
+ const FrontEndConfigSchema = z.object({
16
+ /**
17
+ * HTML Default Language - The default language for the HTML tag
18
+ * @default 'en'
19
+ */
20
+ htmlDefaultLanguage: z.string().optional().default("en"),
21
+ /**
22
+ * HTML Default Header - The default head configuration for the Frontend
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"
35
+ }
36
+ ).optional().default("/favicon.svg"),
37
+ /**
38
+ * Enable sitemap generation
39
+ * @default true
40
+ */
41
+ sitemap: z.boolean().optional().default(true),
42
+ /**
43
+ * Inject routes
44
+ * @default true
45
+ */
46
+ injectRoutes: z.boolean().optional().default(true),
47
+ /**
48
+ * The configuration for the blog
49
+ */
50
+ blog: z.object({
51
+ /**
52
+ * The title of the blog
53
+ */
54
+ title: z.string().optional().default("Blog"),
55
+ /**
56
+ * Enable RSS feed
57
+ */
58
+ enableRSS: z.boolean().optional().default(true),
59
+ /**
60
+ * The route for the blog
61
+ * @default '/blog'
62
+ * @example '/news'
63
+ */
64
+ route: z.string().optional().default("/blog")
65
+ }).optional().default({})
66
+ }).optional().default({});
67
+ export {
68
+ FrontEndConfigSchema,
69
+ faviconTypeMap,
70
+ isFaviconExt
71
+ };
@@ -0,0 +1,8 @@
1
+ import type { CombinedPageData } from 'studiocms:sdk/types';
2
+ import type { APIContext } from 'astro';
3
+ export declare function getBlogRoute(slug: string): string;
4
+ export type SiteMapTemplate = {
5
+ location: string;
6
+ }[];
7
+ export type { APIContext, CombinedPageData };
8
+ export declare const remapFilterSitemap: ((filter: string, context: APIContext, blog?: boolean) => (array: Array<CombinedPageData>) => SiteMapTemplate) & ((array: Array<CombinedPageData>, filter: string, context: APIContext, blog?: boolean) => SiteMapTemplate);
@@ -0,0 +1,20 @@
1
+ import blogConfig from "studiocms:blog/config";
2
+ import { pathWithBase } from "studiocms:lib";
3
+ import { dual } from "studiocms/effect";
4
+ const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
5
+ function getBlogRoute(slug) {
6
+ return blogRouteFullPath.replace("[...slug]", slug);
7
+ }
8
+ const remapFilterSitemap = dual(4, (array, filter, context, blog = false) => {
9
+ function genLocation(slug) {
10
+ const newPath = blog ? getBlogRoute(slug) : slug;
11
+ return new URL(pathWithBase(newPath), context.url);
12
+ }
13
+ return array.filter(({ package: pkg }) => pkg === filter).map(({ slug }) => ({
14
+ location: genLocation(slug).toString()
15
+ }));
16
+ });
17
+ export {
18
+ getBlogRoute,
19
+ remapFilterSitemap
20
+ };
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "@studiocms/blog",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0",
4
4
  "description": "Add a blog to your StudioCMS project with ease!",
5
5
  "author": {
6
- "name": "Adam Matthiesen | Jacob Jenkins | Paul Valladares",
6
+ "name": "withstudiocms",
7
7
  "url": "https://studiocms.dev"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/withstudiocms/studiocms.git",
12
- "directory": "packages/studiocms_blog"
12
+ "directory": "packages/@studiocms/blog"
13
13
  },
14
14
  "contributors": [
15
15
  "Adammatthiesen",
16
16
  "jdtjenkins",
17
- "dreyfus92"
17
+ "dreyfus92",
18
+ "code.spirit"
18
19
  ],
19
20
  "license": "MIT",
20
21
  "keywords": [
@@ -22,12 +23,10 @@
22
23
  "astrocms",
23
24
  "astrodb",
24
25
  "astrostudio",
25
- "astro-integration",
26
26
  "astro-studio",
27
27
  "astro-studiocms",
28
28
  "cms",
29
29
  "studiocms",
30
- "withastro",
31
30
  "blog",
32
31
  "studio-blog",
33
32
  "astro-blog",
@@ -48,24 +47,31 @@
48
47
  "exports": {
49
48
  ".": {
50
49
  "types": "./dist/index.d.ts",
51
- "import": "./dist/index.js"
52
- }
50
+ "default": "./dist/index.js"
51
+ },
52
+ "./routes/*": "./dist/routes/*"
53
53
  },
54
54
  "type": "module",
55
55
  "dependencies": {
56
- "@astrojs/rss": "^4.0.11",
57
- "astro-integration-kit": "^0.18"
56
+ "@astrojs/rss": "^4.0.14",
57
+ "astro-integration-kit": "^0.19.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "^20.14.11"
60
+ "@types/node": "^22.0.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "astro": "^5.4.0",
64
- "vite": "^6.2.0",
65
- "studiocms": "0.1.0-beta.8"
63
+ "astro": "^5.12.9",
64
+ "effect": "^3.19.14",
65
+ "vite": "^6.3.4",
66
+ "@studiocms/md": "0.1.0",
67
+ "studiocms": "0.1.0"
66
68
  },
67
69
  "scripts": {
68
- "build": "build-scripts build 'src/**/*.{ts,css}'",
69
- "dev": "build-scripts dev 'src/**/*.{ts,css}'"
70
+ "build": "buildkit build 'src/**/*.{ts,astro,css,json,png,d.ts}'",
71
+ "dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png,d.ts}'",
72
+ "typecheck": "tspc -p tsconfig.tspc.json",
73
+ "effect-check": "pnpm effect-language-service diagnostics --project tsconfig.tspc.json",
74
+ "ci:effect-check": "pnpm effect-check --format github-actions",
75
+ "test": "vitest"
70
76
  }
71
77
  }
package/dist/blog.d.js DELETED
File without changes
File without changes
@@ -1,13 +0,0 @@
1
- /// <reference types="astro/client" />
2
-
3
- declare module 'studiocms:components' {
4
- export const Avatar: typeof import('studiocms/components/Avatar.astro').default;
5
- export const FormattedDate: typeof import('studiocms/components/FormattedDate.astro').default;
6
- export const GenericHeader: typeof import('studiocms/components/GenericHeader.astro').default;
7
- export const Navigation: typeof import('studiocms/components/Navigation.astro').default;
8
- export const Generator: typeof import('studiocms/components/Generator.astro').default;
9
- }
10
-
11
- declare module 'studiocms:imageHandler/components' {
12
- export const CustomImage: typeof import('studiocms/components/image/CustomImage.astro').default;
13
- }
package/dist/lib.d.js DELETED
File without changes
package/dist/lib.d.ts DELETED
@@ -1,82 +0,0 @@
1
- declare module 'studiocms:lib' {
2
- export const HeadConfigSchema: typeof import('studiocms/lib/head.js').HeadConfigSchema;
3
- export const createHead: typeof import('studiocms/lib/head.js').createHead;
4
- export const headDefaults: typeof import('studiocms/lib/headDefaults.js').headDefaults;
5
- export const stringify: typeof import('studiocms/lib/jsonUtils.js').stringify;
6
- export const stringifyMap: typeof import('studiocms/lib/jsonUtils.js').stringifyMap;
7
- export const pathWithBase: typeof import('studiocms/lib/pathGenerators.js').pathWithBase;
8
- export const fileWithBase: typeof import('studiocms/lib/pathGenerators.js').fileWithBase;
9
- export const ensureLeadingSlash: typeof import(
10
- 'studiocms/lib/pathGenerators.js'
11
- ).ensureLeadingSlash;
12
- export const ensureTrailingSlash: typeof import(
13
- 'studiocms/lib/pathGenerators.js'
14
- ).ensureTrailingSlash;
15
- export const stripLeadingSlash: typeof import(
16
- 'studiocms/lib/pathGenerators.js'
17
- ).stripLeadingSlash;
18
- export const stripTrailingSlash: typeof import(
19
- 'studiocms/lib/pathGenerators.js'
20
- ).stripTrailingSlash;
21
- export const stripHtmlExtension: typeof import(
22
- 'studiocms/lib/pathGenerators.js'
23
- ).stripHtmlExtension;
24
- export const ensureHtmlExtension: typeof import(
25
- 'studiocms/lib/pathGenerators.js'
26
- ).ensureHtmlExtension;
27
- export const removeLeadingTrailingSlashes: typeof import(
28
- 'studiocms/lib/removeLeadingTrailingSlashes.js'
29
- ).removeLeadingTrailingSlashes;
30
- export const getSluggedRoute: typeof import('studiocms/lib/routeMap.js').getSluggedRoute;
31
- export const getEditRoute: typeof import('studiocms/lib/routeMap.js').getEditRoute;
32
- export const getDeleteRoute: typeof import('studiocms/lib/routeMap.js').getDeleteRoute;
33
- export const makeNonDashboardRoute: typeof import(
34
- 'studiocms/lib/routeMap.js'
35
- ).makeNonDashboardRoute;
36
- export const makeDashboardRoute: typeof import('studiocms/lib/routeMap.js').makeDashboardRoute;
37
- export const StudioCMSRoutes: typeof import('studiocms/lib/routeMap.js').StudioCMSRoutes;
38
- export const sideBarLinkMap: typeof import('studiocms/lib/routeMap.js').sideBarLinkMap;
39
- export const urlGenFactory: typeof import('studiocms/lib/urlGen.js').default;
40
-
41
- export type HeadConfig = import('studiocms/lib/head.js').HeadConfig;
42
- export type HeadUserConfig = import('studiocms/lib/head.js').HeadUserConfig;
43
- }
44
-
45
- declare module 'studiocms:config' {
46
- export const config: import('studiocms/schemas').StudioCMSConfig;
47
- export default config;
48
-
49
- export const dashboardConfig: import('studiocms/schemas').StudioCMSConfig['dashboardConfig'];
50
- export const AuthConfig: import(
51
- 'studiocms/schemas'
52
- ).StudioCMSConfig['dashboardConfig']['AuthConfig'];
53
- export const developerConfig: import(
54
- 'studiocms/schemas'
55
- ).StudioCMSConfig['dashboardConfig']['developerConfig'];
56
- export const defaultFrontEndConfig: import(
57
- 'studiocms/schemas'
58
- ).StudioCMSConfig['defaultFrontEndConfig'];
59
- export const sdk: import('studiocms/schemas').StudioCMSConfig['sdk'];
60
- }
61
-
62
- declare module 'studiocms:plugins' {
63
- const mod: import('studiocms/plugins').SafePluginListType;
64
- export default mod;
65
- }
66
-
67
- declare module 'studiocms:plugin-helpers' {
68
- export type SettingsField = import('studiocms/plugins').SettingsField;
69
- export type SafePluginListType = import('studiocms/plugins').SafePluginListType;
70
- export type StudioCMSPlugin = import('studiocms/plugins').StudioCMSPlugin;
71
- export type StudioCMSPluginOptions = import('studiocms/plugins').StudioCMSPluginOptions;
72
- export type AvailableDashboardPages = import('studiocms/plugins').AvailableDashboardPages;
73
- export type FinalDashboardPage = import('studiocms/plugins').FinalDashboardPage;
74
- export type DashboardPage = import('studiocms/plugins').DashboardPage;
75
-
76
- export const getPluginDashboardPages: typeof import(
77
- 'studiocms/lib/plugins/index.js'
78
- ).getPluginDashboardPages;
79
- export const frontendNavigation: typeof import(
80
- 'studiocms/lib/plugins/index.js'
81
- ).frontendNavigation;
82
- }
File without changes
@@ -1,9 +0,0 @@
1
- declare module 'studiocms:renderer' {
2
- export const StudioCMSRenderer: typeof import('studiocms/Renderer.astro').default;
3
- }
4
-
5
- declare module 'studiocms:renderer/current' {
6
- const deModule: typeof import('studiocms/contentRenderer.js').default;
7
- export default deModule;
8
- export const contentRenderer: typeof import('studiocms/contentRenderer.js').contentRenderer;
9
- }
@@ -1,44 +0,0 @@
1
- import blogConfig from 'studiocms:blog/config';
2
- import { pathWithBase } from 'studiocms:lib';
3
- import studioCMS_SDK from 'studiocms:sdk/cache';
4
- import rss, { type RSSFeedItem } from '@astrojs/rss';
5
- import type { APIContext } from 'astro';
6
-
7
- const blogRouteFullPath = `${blogConfig.route}/[...slug]`;
8
-
9
- function getBlogRoute(slug: string) {
10
- if (blogRouteFullPath) {
11
- return blogRouteFullPath.replace('[...slug]', slug);
12
- }
13
- return '#';
14
- }
15
-
16
- export async function GET(context: APIContext) {
17
- // Get Config from Studio Database
18
- const config = (await studioCMS_SDK.GET.siteConfig()).data || {
19
- title: 'StudioCMS - Database Unavailable',
20
- description: 'StudioCMS - Database Unavailable',
21
- };
22
-
23
- // Set Title, Description, and Site
24
- const title = `${config?.title} | ${blogConfig.title}`;
25
- const description = config?.description ?? 'Blog';
26
- const site = context.site ?? 'https://example.com';
27
-
28
- // Get all Posts from Studio Database
29
- const orderedPosts = (await studioCMS_SDK.GET.pages())
30
- .map(({ data }) => data)
31
- .filter(({ package: pkg }) => pkg === '@studiocms/blog');
32
-
33
- const items: RSSFeedItem[] = orderedPosts.map((post) => {
34
- return {
35
- title: post.title,
36
- description: post.description,
37
- pubDate: post.publishedAt,
38
- link: pathWithBase(getBlogRoute(post.slug)),
39
- categories: post.categories.map(({ name }) => name),
40
- };
41
- });
42
-
43
- return rss({ title, description, site, items });
44
- }