@xleddyl/nuxt-cms 0.1.49 → 0.1.51

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": "@xleddyl/nuxt-cms",
3
3
  "configKey": "cms",
4
- "version": "0.1.49",
4
+ "version": "0.1.51",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -54,7 +54,7 @@
54
54
  >
55
55
  <CmsIcon name="bars-2" class="size-4" />
56
56
  </button>
57
- <span class="cms-block-bar-name" :title="labelOf(item)">{{ labelOf(item) }}</span>
57
+ <span class="cms-block-bar-name" :title="barTitle(item)">{{ barLabel(item) }}</span>
58
58
  <div class="cms-block-bar-actions">
59
59
  <CmsButton
60
60
  icon="trash"
@@ -143,6 +143,7 @@
143
143
  <script setup>
144
144
  import {
145
145
  isTranslatableMediaField,
146
+ mediaFilename,
146
147
  mediaIconFor,
147
148
  mediaPublicUrl,
148
149
  mediaTypeForKey,
@@ -174,6 +175,13 @@ function blockOf(item) {
174
175
  function labelOf(item) {
175
176
  return blockOf(item)?.label ?? String(item.type);
176
177
  }
178
+ function barLabel(item) {
179
+ const key = mediaKeyOf(item);
180
+ return key ? mediaFilename(key) : labelOf(item);
181
+ }
182
+ function barTitle(item) {
183
+ return mediaKeyOf(item) ?? labelOf(item);
184
+ }
177
185
  function mediaKeyOf(item) {
178
186
  const locale = props.locale ?? i18n.defaultLocale;
179
187
  for (const [key, field] of Object.entries(blockOf(item)?.fields ?? {})) {
@@ -4,7 +4,7 @@
4
4
  <nav v-if="links?.length" class="cms-breadcrumb">
5
5
  <template v-for="link in links" :key="link.to">
6
6
  <NuxtLink :to="link.to" class="cms-breadcrumb-link">{{ link.label }}</NuxtLink>
7
- <CmsIcon name="chevron-right" class="cms-breadcrumb-separator size-3" />
7
+ <CmsIcon name="chevron-right" class="cms-breadcrumb-separator size-2.5" />
8
8
  </template>
9
9
  </nav>
10
10
  <div class="cms-actions">
@@ -228,8 +228,20 @@ function isList(value) {
228
228
  return !!value && Array.isArray(value.items);
229
229
  }
230
230
  const rows = computed(() => isList(data.value) ? data.value.items : []);
231
+ const mounted = ref(false);
232
+ onMounted(() => {
233
+ mounted.value = true;
234
+ });
231
235
  function lastEdit(value) {
232
- return typeof value === "string" && value ? value.slice(0, 10) : "never saved";
236
+ if (typeof value !== "string" || !value) return "Never saved";
237
+ const stamp = value.includes("T") ? value : value.replace(" ", "T") + "Z";
238
+ const date = new Date(stamp);
239
+ if (Number.isNaN(date.getTime())) return `Last edit ${value.slice(0, 10)}`;
240
+ if (!mounted.value) return `Last edit ${value.slice(0, 10)}`;
241
+ return `Last edit ${date.toLocaleDateString()} ${date.toLocaleTimeString([], {
242
+ hour: "2-digit",
243
+ minute: "2-digit"
244
+ })}`;
233
245
  }
234
246
  const pageTree = computed(() => {
235
247
  const byPath = new Set(rows.value.map((row) => String(row.path)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",