@explorer-1/vue 0.2.81 → 0.2.83

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": "@explorer-1/vue",
3
- "version": "0.2.81",
3
+ "version": "0.2.83",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -163,12 +163,19 @@ export default defineComponent({
163
163
  return undefined
164
164
  },
165
165
  computedTo() {
166
- let toValue = this.to
166
+ let toValue = this.to ? this.addTrailingSlash(this.to as string) : undefined
167
167
  // filter out unnecessary `/home/` prefix from wagtail default site urlPaths
168
168
  if (toValue && typeof toValue === 'string' && toValue.startsWith('/home/')) {
169
169
  toValue = toValue.replace('/home/', '/')
170
170
  }
171
171
  return toValue
172
+ },
173
+ computedHref() {
174
+ let hrefValue =
175
+ this.href && (this.href.includes('jpl.nasa.gov') || this.href.includes('localhost'))
176
+ ? this.addTrailingSlash(this.href as string)
177
+ : this.href
178
+ return hrefValue
172
179
  }
173
180
  },
174
181
  methods: {
@@ -176,6 +183,46 @@ export default defineComponent({
176
183
  this.$root?.$emit('linkClicked')
177
184
  this.$emit('specificLinkClicked')
178
185
  eventBus.emit('linkClicked')
186
+ },
187
+ addTrailingSlash(path: string) {
188
+ let filteredPath = path
189
+ const isFilePath = () => {
190
+ const afterLastSlash = path.split('/').pop()
191
+ if (afterLastSlash && afterLastSlash.includes('.')) {
192
+ return true
193
+ }
194
+ return false
195
+ }
196
+ const isQueryPath = path.includes('?')
197
+ const isAnchorPath = path.includes('#')
198
+ if (
199
+ !isQueryPath &&
200
+ !isAnchorPath &&
201
+ !isFilePath() &&
202
+ path !== '/' &&
203
+ !path.endsWith('/') &&
204
+ !path.startsWith('/preview')
205
+ ) {
206
+ // add a trailing slash if there isn't one
207
+ filteredPath += '/'
208
+ } else if (isQueryPath) {
209
+ if (!path.includes('/?')) {
210
+ // also add a trailing slash to paths with query params
211
+ const urlParts = filteredPath.split('?')
212
+ const pathWithSlash = `${urlParts[0]}/`
213
+ const queryParams = urlParts[1]
214
+ filteredPath = pathWithSlash + '?' + queryParams
215
+ }
216
+ } else if (isAnchorPath) {
217
+ if (!path.includes('/#')) {
218
+ // also add a trailing slash to paths with anchors
219
+ const urlParts = filteredPath.split('#')
220
+ const pathWithSlash = `${urlParts[0]}/`
221
+ const anchor = urlParts[1]
222
+ filteredPath = pathWithSlash + '#' + anchor
223
+ }
224
+ }
225
+ return filteredPath
179
226
  }
180
227
  }
181
228
  })
@@ -220,8 +267,8 @@ export default defineComponent({
220
267
  </template>
221
268
  </nuxt-link>
222
269
  <a
223
- v-else-if="href"
224
- :href="href"
270
+ v-else-if="computedHref"
271
+ :href="computedHref"
225
272
  class="group"
226
273
  :class="computedClass"
227
274
  :target="theTarget"
@@ -293,20 +293,33 @@ export const mixinFormatSplitEventDates = (
293
293
  endDatetime?: string,
294
294
  compact?: boolean
295
295
  ): EventDateObject => {
296
- const startDateDayjs = dayjs(startDatetime)
296
+ const endDateDayjs = endDatetime ? dayjs(endDatetime) : undefined
297
297
 
298
- const monthFormat = compact ? 'MM' : 'MMM'
299
- let day = startDateDayjs.format('D')
300
- const month = startDateDayjs.format(monthFormat).replace('.', '')
301
- const year = startDateDayjs.format('YYYY')
302
- const monthAndYear = startDateDayjs.format(`${monthFormat} YYYY`)
298
+ const startDateDayjs = () => {
299
+ // use the end date if the event has started but hasn't ended
300
+ let date = startDatetime
301
+ const startDate = startDatetime ? dayjs(startDatetime) : undefined
302
+ if (startDatetime && endDatetime && endDateDayjs && startDate) {
303
+ let now = dayjs(new Date())
304
+ if (endDateDayjs > now && startDate < now) {
305
+ date = endDatetime
306
+ } else {
307
+ date = startDatetime
308
+ }
309
+ }
310
+ return dayjs(date)
311
+ }
303
312
 
304
- if (endDatetime) {
305
- const endDateDayjs = dayjs(endDatetime)
313
+ const monthFormat = compact ? 'MM' : 'MMM'
314
+ let day = startDateDayjs().format('D')
315
+ const month = startDateDayjs().format(monthFormat).replace('.', '')
316
+ const year = startDateDayjs().format('YYYY')
317
+ const monthAndYear = startDateDayjs().format(`${monthFormat} YYYY`)
306
318
 
319
+ if (endDateDayjs) {
307
320
  if (
308
- startDateDayjs.format('MM') === endDateDayjs.format('MM') &&
309
- startDateDayjs.format('ll') !== endDateDayjs.format('ll')
321
+ startDateDayjs().format('MM') === endDateDayjs.format('MM') &&
322
+ startDateDayjs().format('ll') !== endDateDayjs.format('ll')
310
323
  ) {
311
324
  // If event spans multiple days within the same month, show both days
312
325
  day = `${day}-${endDateDayjs.format('D')}`