@oneie/plugin-blog 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneie/plugin-blog",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ONE blog — Astro content collection with post grid, search, RSS, and MDX support",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -14,17 +14,12 @@
14
14
  },
15
15
  "peerDependencies": {
16
16
  "astro": ">=6.0.0",
17
- "@oneie/frontend": "*",
17
+ "@oneie/frontend": "^0.1.1",
18
18
  "react": ">=19.0.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "astro": "^6.2.2",
22
22
  "react": "^19.0.0",
23
23
  "typescript": "^5.7.3"
24
- },
25
- "peerDependenciesMeta": {
26
- "@oneie/frontend": {
27
- "optional": true
28
- }
29
24
  }
30
25
  }
@@ -19,7 +19,7 @@ const posts = rawPosts
19
19
  .map((entry) => ({
20
20
  title: entry.data.title,
21
21
  description: entry.data.description,
22
- slug: entry.slug,
22
+ slug: entry.id,
23
23
  date: entry.data.date,
24
24
  category: entry.data.category,
25
25
  image: entry.data.image,
@@ -1,14 +1,29 @@
1
1
  ---
2
2
  import type { CollectionEntry } from 'astro:content'
3
+ import { getCollection, render } from 'astro:content'
3
4
  import type { MarkdownHeading } from 'astro'
4
5
 
5
6
  export interface Props {
6
- entry: CollectionEntry<'blog'>
7
+ /** Omit when this file is used directly as an injected route — it then
8
+ * self-resolves from Astro.params.slug. Pass explicitly when wrapping
9
+ * it in your own page/layout. */
10
+ entry?: CollectionEntry<'blog'>
7
11
  headings?: MarkdownHeading[]
8
12
  }
9
13
 
10
- const { entry, headings = [] } = Astro.props
11
- const { Content } = await entry.render()
14
+ let { entry, headings } = Astro.props
15
+
16
+ if (!entry) {
17
+ const slug = Astro.params.slug as string
18
+ const posts = await getCollection('blog')
19
+ const found = posts.find((p) => p.id === slug)
20
+ if (!found) return Astro.redirect('/blog')
21
+ entry = found
22
+ }
23
+
24
+ const rendered = await render(entry)
25
+ const Content = rendered.Content
26
+ headings ??= rendered.headings
12
27
 
13
28
  const { title, description, date, category, image } = entry.data
14
29
 
package/tsconfig.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
- "extends": "../../tsconfig.base.json",
2
+ "extends": "../tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "jsx": "react-jsx",
5
5
  "jsxImportSource": "react",
6
6
  "paths": {
7
- "@/*": ["../../apps/web/src/*"]
7
+ "@/*": ["../../template/site/src/*"]
8
8
  }
9
9
  },
10
10
  "include": ["src"]