mktcms 0.2.12 → 0.2.13

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mktcms",
3
3
  "configKey": "mktcms",
4
- "version": "0.2.12",
4
+ "version": "0.2.13",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -6,6 +6,7 @@ const { path } = usePathParam();
6
6
  const { data: content } = await useFetch(`/api/admin/txt?path=${path}`);
7
7
  const isSaving = ref(false);
8
8
  const savingSuccessful = ref(false);
9
+ const commitMessage = ref("Inhaltliche \xC4nderungen");
9
10
  async function saveContent() {
10
11
  if (content.value === void 0) return;
11
12
  isSaving.value = true;
@@ -13,7 +14,8 @@ async function saveContent() {
13
14
  await useFetch(`/api/admin/txt?path=${path}`, {
14
15
  method: "POST",
15
16
  body: {
16
- text: content.value
17
+ text: content.value,
18
+ commitMessage: commitMessage.value
17
19
  }
18
20
  });
19
21
  isSaving.value = false;
@@ -28,9 +30,27 @@ async function saveContent() {
28
30
  class="w-full h-24 resize-y border border-gray-300 p-2 box-border font-mono"
29
31
  />
30
32
 
33
+ <div class="mt-3">
34
+ <label
35
+ for="commit-message"
36
+ class="block mb-1"
37
+ >
38
+ Kommentar / Änderungsgrund
39
+ </label>
40
+ <input
41
+ id="commit-message"
42
+ v-model="commitMessage"
43
+ type="text"
44
+ required
45
+ class="w-full border border-gray-200 rounded-sm px-3 py-2"
46
+ placeholder="Inhaltliche Änderungen"
47
+ >
48
+ </div>
49
+
31
50
  <button
32
51
  type="button"
33
52
  class="button w-full justify-center mt-3"
53
+ :disabled="!commitMessage.trim() || isSaving"
34
54
  @click="saveContent"
35
55
  >
36
56
  <span v-if="isSaving">Speichern...</span>
@@ -1,17 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { defineEventHandler, getValidatedQuery, readValidatedBody } from "h3";
3
3
  import { useStorage } from "nitropack/runtime";
4
+ import syncGitContent from "../../utils/syncGitContent.js";
4
5
  const querySchema = z.object({
5
6
  path: z.string().min(1)
6
7
  });
7
8
  const bodySchema = z.object({
8
- text: z.string()
9
+ text: z.string(),
10
+ commitMessage: z.string().trim().min(1)
9
11
  });
10
12
  export default defineEventHandler(async (event) => {
11
13
  const { path } = await getValidatedQuery(event, (query) => querySchema.parse(query));
12
- const { text } = await readValidatedBody(event, (body) => bodySchema.parse(body));
14
+ const { text, commitMessage } = await readValidatedBody(event, (body) => bodySchema.parse(body));
13
15
  const decodedPath = decodeURIComponent(path);
14
16
  const storage = useStorage("content");
15
17
  await storage.setItem(decodedPath, text);
18
+ try {
19
+ await syncGitContent(commitMessage, [decodedPath]);
20
+ } catch (error) {
21
+ console.error("Git-Fehler:", error);
22
+ }
16
23
  return { success: true };
17
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mktcms",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Simple CMS module for Nuxt",
5
5
  "repository": "mktcode/mktcms",
6
6
  "license": "MIT",