@studiocms/blog 0.1.0-beta.6 → 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.
Files changed (44) hide show
  1. package/LICENSE +1 -1
  2. package/dist/blog.d.js +0 -0
  3. package/dist/blog.d.ts +8 -0
  4. package/dist/components/BaseHead.astro +73 -0
  5. package/dist/components/Footer.astro +26 -0
  6. package/dist/components/Navigation.astro +83 -0
  7. package/dist/components/PageList.astro +46 -0
  8. package/{src → dist}/components/PostHeader.astro +1 -23
  9. package/dist/components/navigation.css +155 -0
  10. package/dist/components.d.js +0 -0
  11. package/dist/components.d.ts +13 -0
  12. package/dist/index.d.ts +35 -0
  13. package/dist/index.js +81 -0
  14. package/dist/layouts/Layout.astro +60 -0
  15. package/dist/lib.d.js +0 -0
  16. package/dist/lib.d.ts +82 -0
  17. package/dist/renderer.d.js +0 -0
  18. package/dist/renderer.d.ts +9 -0
  19. package/dist/routes/[...slug].astro +36 -0
  20. package/dist/routes/blog/[...slug].astro +44 -0
  21. package/dist/routes/blog/index.astro +32 -0
  22. package/dist/routes/rss.xml.d.ts +2 -0
  23. package/dist/routes/rss.xml.js +34 -0
  24. package/dist/routes/rss.xml.ts +44 -0
  25. package/dist/routes/sitemap-md.xml.d.ts +2 -0
  26. package/dist/routes/sitemap-md.xml.js +22 -0
  27. package/dist/routes/sitemap-md.xml.ts +28 -0
  28. package/dist/routes/sitemap-posts.xml.d.ts +2 -0
  29. package/dist/routes/sitemap-posts.xml.js +30 -0
  30. package/dist/routes/sitemap-posts.xml.ts +38 -0
  31. package/dist/sdk.d.js +0 -0
  32. package/dist/sdk.d.ts +56 -0
  33. package/dist/styles/base.css +245 -0
  34. package/dist/types.d.ts +34 -0
  35. package/dist/types.js +0 -0
  36. package/package.json +23 -20
  37. package/index.ts +0 -65
  38. package/schema.ts +0 -35
  39. package/src/components/PageList.astro +0 -131
  40. package/src/layouts/BlogLayout.astro +0 -39
  41. package/src/pages/blog/[...slug].astro +0 -40
  42. package/src/pages/blog/index.astro +0 -38
  43. package/src/pages/rss.xml.ts +0 -60
  44. /package/{src → dist}/components/RSSIcon.astro +0 -0
@@ -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