@micacms/astro 0.6.0-rc.2 → 0.6.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/package.json +3 -3
- package/setup/content-collections.md +102 -45
- package/setup/finish.md +44 -28
- package/setup/new-project.md +18 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micacms/astro",
|
|
3
|
-
"version": "0.6.0
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Reads a Mica content repository as Astro Content Collections via the Content Layer API.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"astro": "^7.0.0",
|
|
46
46
|
"zod": "^4.3.6",
|
|
47
|
-
"@micacms/core": "^0.6.0
|
|
47
|
+
"@micacms/core": "^0.6.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^22.20.1",
|
|
51
51
|
"astro": "^7.2.2",
|
|
52
52
|
"typescript": "^5.7.3",
|
|
53
53
|
"zod": "^4.3.6",
|
|
54
|
-
"@micacms/core": "0.6.0
|
|
54
|
+
"@micacms/core": "0.6.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsc -p tsconfig.json",
|
|
@@ -36,49 +36,104 @@ the integrations in `astro.config.*`. For each collection, find:
|
|
|
36
36
|
- the number of entries, and whether the ids have folders (`2024/hello`);
|
|
37
37
|
- what the bodies contain: plain Markdown, raw HTML, footnotes, MDX imports and
|
|
38
38
|
components, images with relative paths;
|
|
39
|
-
- the pages and URLs that use the collection
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
39
|
+
- the pages, components and URLs that use the collection, and the lines that
|
|
40
|
+
read each field;
|
|
41
|
+
- whether the site uses Tailwind CSS 4: a stylesheet with
|
|
42
|
+
`@import "tailwindcss"`.
|
|
43
|
+
|
|
44
|
+
## 3. Propose, and wait for the approval
|
|
45
|
+
|
|
46
|
+
Before you write the model or change any file, show the user one proposal and
|
|
47
|
+
wait for a short approval or correction. The user must know what will change
|
|
48
|
+
on their website, and why, before anything changes. Write for a reader who is
|
|
49
|
+
new to Mica and may know little about Astro: plain words, short sentences, no
|
|
50
|
+
code. Map the fields with the table in step 4. Use this form:
|
|
51
|
+
|
|
52
|
+
```markdown
|
|
53
|
+
## What editors will manage
|
|
54
|
+
|
|
55
|
+
**Team** (2 entries): the people on the team page.
|
|
56
|
+
- Name — text, required
|
|
57
|
+
- Role — text, required
|
|
58
|
+
- Photo — an image, with its alt text right under it (required)
|
|
59
|
+
- Editors put the people in order by dragging them.
|
|
60
|
+
|
|
61
|
+
**Stays as it is:** <collections that stay in Astro, and why>
|
|
62
|
+
|
|
63
|
+
## What changes in the website's files
|
|
64
|
+
|
|
65
|
+
1. **The team photos' alt text moves into the photo field.** Editors then
|
|
66
|
+
write it right under the photo, and Mica does not save a photo without it.
|
|
67
|
+
In `TeamSection.astro`, two lines read the photo and its alt text in the
|
|
68
|
+
new place. Visitors see no difference.
|
|
69
|
+
Recommended. Other option: keep the alt text as its own field; then this
|
|
70
|
+
file does not change.
|
|
71
|
+
2. …
|
|
72
|
+
|
|
73
|
+
## What cannot move as it is
|
|
74
|
+
|
|
75
|
+
- <each case from the list below, with the options>
|
|
76
|
+
|
|
77
|
+
Shall I go ahead like this? You can change any point.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
List every change to a page, a component, a layout, a style or a config file,
|
|
81
|
+
one per item: what changes, in which file, whether visitors can see it
|
|
82
|
+
(normally not), your recommendation, and the other option. Only what you list
|
|
83
|
+
here may change later. The usual items:
|
|
84
|
+
|
|
85
|
+
- **Manual order.** If a collection has a number field that only sorts it,
|
|
86
|
+
such as `order`: recommend that editors drag the entries into order. It is
|
|
87
|
+
easier, and two entries cannot get the same place. The import turns the
|
|
88
|
+
numbers into `_order.json` (`--order`), the field goes, and each page that
|
|
89
|
+
sorts by it sorts by `entry.data._mica.position`: one changed line per
|
|
90
|
+
page. Other option: keep the number field, with no page change.
|
|
91
|
+
- **Alt text.** If an image has its alt text in a separate field: recommend
|
|
92
|
+
the image field with alt text (`media({ accept: "image", alt: "required" })`,
|
|
93
|
+
`--map <collection>.<image>.alt=<field>`). Editors see it under the image,
|
|
94
|
+
and Mica requires it. The page then reads `entry.data.<image>.src` and
|
|
95
|
+
`.alt`, or `<Image {...entry.data.<image>} />`. Other option: keep the
|
|
96
|
+
separate field, with no page change.
|
|
97
|
+
- **Dates.** A date becomes text such as `2026-01-15`. Each page that formats
|
|
98
|
+
or sorts it changes (step 7). Visitors see the same date.
|
|
99
|
+
- **Bodies.** The Markdown body becomes Markdoc: `<Content />` is replaced
|
|
100
|
+
(step 7).
|
|
101
|
+
- **Tailwind CSS 4.** Tailwind reads every file of the project for class
|
|
102
|
+
names, now also `src/mica.ts` and `content/`. A word in a text, such as
|
|
103
|
+
"hidden", then becomes CSS, and the CSS changes when an editor changes a
|
|
104
|
+
text. Recommend excluding both, in the stylesheet with
|
|
105
|
+
`@import "tailwindcss"`, with paths from that file:
|
|
106
|
+
`@source not "./mica.ts";` and `@source not "../content";`. Visitors see no
|
|
107
|
+
difference.
|
|
108
|
+
|
|
109
|
+
What cannot move as it is, with the options to propose:
|
|
110
|
+
|
|
111
|
+
- MDX components in a body. Markdoc does not run them. Options: a Markdoc tag
|
|
112
|
+
that the website declares and renders, a field, or keep that collection in
|
|
113
|
+
Astro. Remove the `import` lines too, and the text that refers to a
|
|
114
|
+
component you drop.
|
|
115
|
+
- Raw HTML in a body. Markdoc does not render it. Options: Markdown (`<b>`
|
|
116
|
+
becomes `**`), a Unicode character, a Markdoc tag, or remove it. Some tags
|
|
117
|
+
have no Markdown form (`<sub>`, `<sup>`, `<kbd>`, `<mark>`). Do not change
|
|
118
|
+
HTML inside code blocks or inline code: that is text.
|
|
119
|
+
- Footnotes (`[^1]`). Markdoc shows them as text. Options: a normal paragraph
|
|
120
|
+
or a link. Remove the `[^1]` markers from the text too.
|
|
121
|
+
- Images in a body (``). The rich-text editor has no images.
|
|
122
|
+
Options: a `media()` field or a `repeater()` with images, or files in
|
|
123
|
+
`public/` with absolute URLs, which Astro does not optimize.
|
|
124
|
+
- Ids with folders, or ids that are not slugs. They become flat slugs, so the
|
|
125
|
+
URL can change. Options: keep the URL with Astro `redirects`, or accept the
|
|
126
|
+
new URL.
|
|
127
|
+
- A free list of strings, such as tags. See
|
|
128
|
+
[reference.md](./reference.md#the-content-model).
|
|
129
|
+
- Headings lose their `id` and code blocks lose their highlighting, unless the
|
|
130
|
+
website adds them. See
|
|
131
|
+
[reference.md](./reference.md#what-markdoc-renders-differently-from-astros-markdown).
|
|
132
|
+
|
|
133
|
+
Collections that only developers change, such as documentation in the
|
|
134
|
+
repository, can stay Astro collections: propose that where it fits.
|
|
135
|
+
|
|
136
|
+
Wait for the answer. Change the proposal until the user agrees.
|
|
82
137
|
|
|
83
138
|
## 4. Map the schema to the model
|
|
84
139
|
|
|
@@ -158,8 +213,10 @@ from [reference.md](./reference.md#write-entries-with-a-script).
|
|
|
158
213
|
|
|
159
214
|
## 7. Change the pages
|
|
160
215
|
|
|
161
|
-
|
|
162
|
-
|
|
216
|
+
Make the changes that the user agreed to in step 3, and no others. If you find
|
|
217
|
+
a change that the proposal did not list, describe it to the user and wait for
|
|
218
|
+
an answer first. Look at every file from the inventory: pages, layouts,
|
|
219
|
+
components, stylesheets and endpoints such as `rss.xml.js`. See
|
|
163
220
|
[reference.md](./reference.md#render-the-content-in-astro).
|
|
164
221
|
|
|
165
222
|
- `render(entry)` and `<Content />` become
|
package/setup/finish.md
CHANGED
|
@@ -52,33 +52,49 @@ paths if the project uses others.
|
|
|
52
52
|
- Before a commit that changes `content/`, `npm run check` must pass.
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
Change no other documentation, such as `README.md`, unless the user asks.
|
|
56
|
+
|
|
55
57
|
## 4. Tell the user
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
59
|
+
Your last message is the report. Its commands are for this one time: do not
|
|
60
|
+
write them into `README.md` or another file. Use this form, with the real
|
|
61
|
+
files from `git status`:
|
|
62
|
+
|
|
63
|
+
````markdown
|
|
64
|
+
## Done
|
|
65
|
+
|
|
66
|
+
Mica is set up. <one sentence on what editors can now edit>.
|
|
67
|
+
|
|
68
|
+
**What changed:** <file by file, one line each: what and why, in plain words>.
|
|
69
|
+
**Your decisions:** <each decision from the proposal, and the choice>.
|
|
70
|
+
**Not converted:** <anything that was not converted, or "nothing">.
|
|
71
|
+
**Checks:** `npm run check` and `npx astro build` pass. <how the website
|
|
72
|
+
compares with the version before>.
|
|
73
|
+
|
|
74
|
+
## Commit it
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# 1. The setup: packages, model, collections config, agent notes.
|
|
78
|
+
git add package.json package-lock.json src/mica.ts src/content.config.ts \
|
|
79
|
+
content/.mica/schema.json AGENTS.md <other setup files>
|
|
80
|
+
git commit -m "Add Mica"
|
|
81
|
+
# 2. The content and the page changes.
|
|
82
|
+
git add -A
|
|
83
|
+
git commit -m "Move the content to Mica"
|
|
84
|
+
# 3. A branch that is not on the remote yet.
|
|
85
|
+
git push -u origin <branch>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Edit the content
|
|
89
|
+
|
|
90
|
+
`npm run mica` opens the editor on this computer. A save writes files in
|
|
91
|
+
`content/`; Publish commits them, and pushes a new branch the first time.
|
|
92
|
+
`npm run check` checks the content (and the types, if `@astrojs/check` is
|
|
93
|
+
there). On another clone, run `npm install` first. A self-hosted editor for
|
|
94
|
+
other people: https://micacms.com/docs/self-hosting/.
|
|
95
|
+
````
|
|
96
|
+
|
|
97
|
+
- Use the project's lock file (`pnpm-lock.yaml`, `yarn.lock`) and package
|
|
98
|
+
manager.
|
|
99
|
+
- For a new project without converted content, one commit is enough.
|
|
100
|
+
- Run the commands only if the user asks.
|
package/setup/new-project.md
CHANGED
|
@@ -25,8 +25,24 @@ Ask these questions, and wait for the answers:
|
|
|
25
25
|
file.
|
|
26
26
|
6. Do they want example content, so that the pages show something at once?
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
Then show one proposal, and wait for a short approval or correction before
|
|
29
|
+
you write a file. Write for a reader who is new to Mica and may know little
|
|
30
|
+
about Astro: plain words, no code.
|
|
31
|
+
|
|
32
|
+
- **What editors will manage:** each collection and singleton, one line on
|
|
33
|
+
what it is, and its fields in plain words ("Title — text, required",
|
|
34
|
+
"Cover — an image, with its alt text under it").
|
|
35
|
+
- **The pages:** each page you will make, with its URL and what it shows.
|
|
36
|
+
- **Existing files that change:** in an empty Astro project, for example
|
|
37
|
+
`src/pages/index.astro` or a layout: what changes, and why. Nothing else
|
|
38
|
+
changes.
|
|
39
|
+
- Your recommendation where there is a choice, and the other option: manual
|
|
40
|
+
order by dragging, or sorting by a field; alt text required for images that
|
|
41
|
+
carry meaning.
|
|
42
|
+
|
|
43
|
+
End with: "Shall I go ahead like this? You can change any point." Change the
|
|
44
|
+
proposal until the user agrees, and later make no change that it did not
|
|
45
|
+
list without asking first.
|
|
30
46
|
|
|
31
47
|
## 2. Add Mica to the project
|
|
32
48
|
|