@studiocms/blog 0.1.0-beta.7 → 0.1.0-beta.8
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/dist/blog.d.js +0 -0
- package/dist/blog.d.ts +8 -0
- package/dist/components/BaseHead.astro +73 -0
- package/dist/components/Footer.astro +26 -0
- package/dist/components/Navigation.astro +83 -0
- package/dist/components/PageList.astro +46 -0
- package/{src → dist}/components/PostHeader.astro +1 -23
- package/dist/components/navigation.css +155 -0
- package/dist/components.d.js +0 -0
- package/dist/components.d.ts +13 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +81 -0
- package/dist/layouts/Layout.astro +60 -0
- package/dist/lib.d.js +0 -0
- package/dist/lib.d.ts +82 -0
- package/dist/renderer.d.js +0 -0
- package/dist/renderer.d.ts +9 -0
- package/dist/routes/[...slug].astro +36 -0
- package/dist/routes/blog/[...slug].astro +44 -0
- package/dist/routes/blog/index.astro +32 -0
- package/dist/routes/rss.xml.d.ts +2 -0
- package/dist/routes/rss.xml.js +34 -0
- package/dist/routes/rss.xml.ts +44 -0
- package/dist/routes/sitemap-md.xml.d.ts +2 -0
- package/dist/routes/sitemap-md.xml.js +22 -0
- package/dist/routes/sitemap-md.xml.ts +28 -0
- package/dist/routes/sitemap-posts.xml.d.ts +2 -0
- package/dist/routes/sitemap-posts.xml.js +30 -0
- package/dist/routes/sitemap-posts.xml.ts +38 -0
- package/dist/sdk.d.js +0 -0
- package/dist/sdk.d.ts +56 -0
- package/dist/styles/base.css +245 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.js +0 -0
- package/package.json +23 -20
- package/index.ts +0 -65
- package/schema.ts +0 -35
- package/src/components/PageList.astro +0 -131
- package/src/layouts/BlogLayout.astro +0 -39
- package/src/pages/blog/[...slug].astro +0 -40
- package/src/pages/blog/index.astro +0 -38
- package/src/pages/rss.xml.ts +0 -60
- /package/{src → dist}/components/RSSIcon.astro +0 -0
package/src/pages/rss.xml.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import config from '@studiocms/blog:config';
|
|
2
|
-
import { pages } from '@studiocms/blog:context';
|
|
3
|
-
import { pathWithBase } from 'studiocms:helpers';
|
|
4
|
-
import { contentHelper, getPageList, getSiteConfig } from 'studiocms:helpers/contentHelper';
|
|
5
|
-
import { StudioCMSRenderer } from 'studiocms:renderer';
|
|
6
|
-
import rss from '@astrojs/rss';
|
|
7
|
-
import type { APIContext } from 'astro';
|
|
8
|
-
import { name } from '../../package.json';
|
|
9
|
-
|
|
10
|
-
import { experimental_AstroContainer as AstroContainer } from 'astro/container';
|
|
11
|
-
|
|
12
|
-
const blogRouteFullPath = pages.get('/blog/[...slug]');
|
|
13
|
-
|
|
14
|
-
function getBlogRoute(slug: string) {
|
|
15
|
-
if (blogRouteFullPath) {
|
|
16
|
-
return blogRouteFullPath.replace('[...slug]', slug);
|
|
17
|
-
}
|
|
18
|
-
return '#';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function GET(context: APIContext) {
|
|
22
|
-
// Get Config from Studio Database
|
|
23
|
-
const studioCMSConfig = await getSiteConfig();
|
|
24
|
-
|
|
25
|
-
// Set Title, Description, and Site
|
|
26
|
-
const title = config.title ?? studioCMSConfig.title;
|
|
27
|
-
const description = config.description ?? studioCMSConfig.description;
|
|
28
|
-
const site = context.site ?? 'https://example.com';
|
|
29
|
-
|
|
30
|
-
// Get all Posts from Studio Database
|
|
31
|
-
const unorderedPosts = await getPageList();
|
|
32
|
-
|
|
33
|
-
// Order Posts by Published Date
|
|
34
|
-
const orderedPosts = unorderedPosts
|
|
35
|
-
.filter((page) => page.package === name)
|
|
36
|
-
.sort((a, b) => Date.parse(b.publishedAt.toString()) - Date.parse(a.publishedAt.toString()));
|
|
37
|
-
|
|
38
|
-
// Render Known Posts
|
|
39
|
-
const items = await Promise.all(
|
|
40
|
-
orderedPosts.map(async ({ slug, title, description, publishedAt: pubDate, package: pkg }) => {
|
|
41
|
-
const { content: fetchedContent } = await contentHelper(slug, pkg);
|
|
42
|
-
const container = await AstroContainer.create();
|
|
43
|
-
const renderedContent = await container.renderToString(StudioCMSRenderer, {
|
|
44
|
-
props: { content: fetchedContent },
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const content = renderedContent
|
|
48
|
-
.replace(/<!DOCTYPE html>/, '')
|
|
49
|
-
.replace(/<html.*?>/, '')
|
|
50
|
-
.replace(/<\/html>/, '')
|
|
51
|
-
.trim();
|
|
52
|
-
|
|
53
|
-
const link = pathWithBase(getBlogRoute(slug));
|
|
54
|
-
|
|
55
|
-
return { title, description, pubDate, content, link };
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
return rss({ title, description, site, items });
|
|
60
|
-
}
|
|
File without changes
|