Skip to content

Commit 75c46d7

Browse files
committed
fix: ci
1 parent d39eb76 commit 75c46d7

File tree

6 files changed

+69
-63
lines changed

6 files changed

+69
-63
lines changed

eslint.config.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ export default [
2020
"vue/multi-word-component-names": "off",
2121
"vue/require-default-prop": "off",
2222
"vue/require-prop-types": "error",
23-
"no-unused-vars": ["error", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^props$" }],
23+
"no-unused-vars": [
24+
"error",
25+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^props$" },
26+
],
2427
},
2528
languageOptions: {
2629
ecmaVersion: 2022,
2730
globals: {
2831
window: "readonly",
2932
document: "readonly",
3033
console: "readonly",
31-
panel: "readonly"
32-
}
34+
panel: "readonly",
35+
},
3336
},
3437
},
3538
];

src/components/field-header.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup>
22
import Editable from "@/components/editable.vue"
3-
import { useSyncedSlug } from "@/utils/useSyncedSlug"
3+
import { useSyncedSlug } from "@/utils/use-synced-slug"
44
55
const props = defineProps({
66
content: Object,
@@ -15,7 +15,7 @@ const update = (value) => emit("update", { ...props.content, ...value })
1515
// use the composable for key syncing
1616
const { handleManualInput } = useSyncedSlug({
1717
initialValue: props.content?.key,
18-
syncField: 'label',
18+
syncField: "label",
1919
syncSource: props.content,
2020
onUpdate: (value) => update({ key: value })
2121
})

src/fields/field-slug-field.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
name,
1313
required
1414
} from "kirbyuse/props"
15-
import { useSyncedSlug } from "@/utils/useSyncedSlug"
15+
import { useSyncedSlug } from "@/utils/use-synced-slug"
1616
1717
const props = defineProps({
1818
formData: {
@@ -71,9 +71,12 @@ const fieldProps = computed(() => {
7171
})
7272
7373
// sync external value changes
74-
watch(() => props.value, (newValue) => {
75-
slug.value = newValue || ""
76-
})
74+
watch(
75+
() => props.value,
76+
(newValue) => {
77+
slug.value = newValue || ""
78+
}
79+
)
7780
7881
const input = ref(null)
7982

src/utils/block.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { disabled, id, section } from "kirbyuse/props";
1+
import { disabled, id, section } from "kirbyuse/props"
22

33
export const props = {
44
fieldset: section.fieldset,
55
...disabled,
66
...id,
77
endpoints: {
88
default: () => ({}),
9-
type: [Array, Object],
9+
type: [Array, Object]
1010
},
11-
content: Object,
12-
};
11+
content: Object
12+
}

src/utils/date.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
export function formatDate(timestamp) {
2-
const locale = window.panel.user.language;
3-
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
2+
const locale = window.panel.user.language
3+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" })
44

5-
const diff = (Date.now() - timestamp * 1000) / 1000;
5+
const diff = (Date.now() - timestamp * 1000) / 1000
66
const units = [
77
{ unit: "year", seconds: 365 * 24 * 60 * 60 },
88
{ unit: "month", seconds: 30 * 24 * 60 * 60 },
99
{ unit: "day", seconds: 24 * 60 * 60 },
1010
{ unit: "hour", seconds: 60 * 60 },
11-
{ unit: "minute", seconds: 60 },
12-
];
11+
{ unit: "minute", seconds: 60 }
12+
]
1313

1414
for (const { unit, seconds } of units) {
15-
const value = Math.floor(diff / seconds);
15+
const value = Math.floor(diff / seconds)
1616
if (value > 0) {
17-
return rtf.format(0 - value, unit);
17+
return rtf.format(0 - value, unit)
1818
}
1919
}
2020

21-
return window.panel.$t("dreamform.justNow");
21+
return window.panel.$t("dreamform.justNow")
2222
}

src/utils/useSyncedSlug.js renamed to src/utils/use-synced-slug.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
useApp,
66
useContent,
77
usePanel,
8-
watch,
9-
} from "kirbyuse";
8+
watch
9+
} from "kirbyuse"
1010

1111
/**
1212
* Composable for syncing slug values with auto-generation and uniqueness
@@ -22,34 +22,34 @@ export function useSyncedSlug({
2222
initialValue,
2323
syncField,
2424
syncSource,
25-
onUpdate,
25+
onUpdate
2626
}) {
27-
const app = useApp();
28-
const panel = usePanel();
29-
const { currentContent } = useContent();
27+
const app = useApp()
28+
const panel = usePanel()
29+
const { currentContent } = useContent()
3030

31-
const slug = ref(initialValue || "");
32-
const shouldAutoGenerate = ref(!initialValue);
31+
const slug = ref(initialValue || "")
32+
const shouldAutoGenerate = ref(!initialValue)
3333

3434
// stop auto-generation on publish
3535
const handlePublish = () => {
3636
if (slug.value) {
37-
shouldAutoGenerate.value = false;
37+
shouldAutoGenerate.value = false
3838
}
39-
};
39+
}
4040

4141
onMounted(() => {
42-
panel.events.on("content.publish", handlePublish);
43-
});
42+
panel.events.on("content.publish", handlePublish)
43+
})
4444

4545
onUnmounted(() => {
46-
panel.events.off("content.publish", handlePublish);
47-
});
46+
panel.events.off("content.publish", handlePublish)
47+
})
4848

4949
// get all existing keys from the current content
5050
const getExistingKeys = () => {
51-
const keys = [];
52-
const content = currentContent.value;
51+
const keys = []
52+
const content = currentContent.value
5353

5454
if (content?.fields && Array.isArray(content.fields)) {
5555
// iterate through all field layouts
@@ -59,61 +59,61 @@ export function useSyncedSlug({
5959
if (column.blocks && Array.isArray(column.blocks)) {
6060
column.blocks.forEach((block) => {
6161
// check if this block has a key field
62-
const key = block.content?.key;
62+
const key = block.content?.key
6363
if (key && key !== slug.value) {
64-
keys.push(key);
64+
keys.push(key)
6565
}
66-
});
66+
})
6767
}
68-
});
68+
})
6969
}
70-
});
70+
})
7171
}
7272

73-
return keys;
74-
};
73+
return keys
74+
}
7575

7676
// ensure slug is unique by adding suffix if needed
7777
const ensureUniqueSlug = (baseSlug) => {
78-
const existingKeys = getExistingKeys();
79-
let uniqueSlug = baseSlug;
80-
let counter = 2;
78+
const existingKeys = getExistingKeys()
79+
let uniqueSlug = baseSlug
80+
let counter = 2
8181

8282
while (existingKeys.includes(uniqueSlug)) {
83-
uniqueSlug = `${baseSlug}_${counter}`;
84-
counter++;
83+
uniqueSlug = `${baseSlug}_${counter}`
84+
counter++
8585
}
8686

87-
return uniqueSlug;
88-
};
87+
return uniqueSlug
88+
}
8989

9090
// watch for sync field changes
9191
if (syncField && syncSource) {
9292
watch(
9393
() => syncSource[syncField],
9494
(newValue) => {
9595
if (shouldAutoGenerate.value && newValue) {
96-
const baseSlug = app.$helper.slug(newValue);
97-
const uniqueSlug = ensureUniqueSlug(baseSlug);
98-
slug.value = uniqueSlug;
99-
onUpdate?.(uniqueSlug);
96+
const baseSlug = app.$helper.slug(newValue)
97+
const uniqueSlug = ensureUniqueSlug(baseSlug)
98+
slug.value = uniqueSlug
99+
onUpdate?.(uniqueSlug)
100100
}
101101
},
102-
{ immediate: true },
103-
);
102+
{ immediate: true }
103+
)
104104
}
105105

106106
// handle manual input
107107
const handleManualInput = (value) => {
108108
// disable auto-generation when user manually edits
109-
shouldAutoGenerate.value = false;
110-
slug.value = value;
111-
onUpdate?.(value);
112-
};
109+
shouldAutoGenerate.value = false
110+
slug.value = value
111+
onUpdate?.(value)
112+
}
113113

114114
return {
115115
slug,
116116
shouldAutoGenerate,
117-
handleManualInput,
118-
};
117+
handleManualInput
118+
}
119119
}

0 commit comments

Comments
 (0)