Skip to content

Commit

Permalink
fix: do not use toReversed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Jan 25, 2024
1 parent 6ca1fae commit 2fde6ce
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
100 changes: 50 additions & 50 deletions components/pages/home/PageHistory.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
<script lang="ts" setup>
import { formatTimeAgo } from '@vueuse/core'
import { toast } from 'vue-sonner'
import { XMarkIcon } from '@heroicons/vue/20/solid'
import {formatTimeAgo} from '@vueuse/core'
import {toast} from 'vue-sonner'
import {XMarkIcon} from '@heroicons/vue/20/solid'
const { isPremium } = useUserData()
const { pageHistory } = usePageHistory()
const {isPremium} = useUserData()
const {pageHistory} = usePageHistory()
function historyPathToTitle(path: string) {
path = decodeURIComponent(path)
function historyPathToTitle(path: string) {
path = decodeURIComponent(path)
return (
path
//
.replace('/posts/', 'domain: ')
.replace('?', '&')
.split('&')
.map(
(_query) =>
_query
// Capitalize first character
.charAt(0)
.toUpperCase() +
_query
.slice(1)
return (
path
//
.replace('/posts/', 'domain: ')
.replace('?', '&')
.split('&')
.map(
(_query) =>
_query
// Capitalize first character
.charAt(0)
.toUpperCase() +
_query
.slice(1)
// Replace first '=' with ': '
.replace(/=/, ': ')
)
// Query separator
.join('\n')
// Separate tags
.replace(/\|/g, ', ')
)
}
function onHistoryItemClick(path: string) {
if (!isPremium.value) {
toast.info('Premium feature', {
description: 'Page history is only available for Premium users',
action: {
label: 'Subscribe',
onClick: () => navigateTo('/premium')
}
})
return
}
// Replace first '=' with ': '
.replace(/=/, ': ')
)
// Query separator
.join('\n')
// Separate tags
.replace(/\|/g, ', ')
)
}
navigateTo(path)
function onHistoryItemClick(path: string) {
if (!isPremium.value) {
toast.info('Premium feature', {
description: 'Page history is only available for Premium users',
action: {
label: 'Subscribe',
onClick: () => navigateTo('/premium')
}
})
return
}
function removeHistoryItem(path: string) {
pageHistory.value = pageHistory.value.filter((historyItem) => historyItem.path !== path)
}
navigateTo(path)
}
function removeHistoryItem(path: string) {
pageHistory.value = pageHistory.value.filter((historyItem) => historyItem.path !== path)
}
</script>

<template>
Expand All @@ -60,7 +60,7 @@
role="list"
>
<li
v-for="(historyItem, index) in pageHistory.toReversed()"
v-for="(historyItem, index) in pageHistory.slice().reverse()"
:key="index"
class="relative flex gap-x-4"
>
Expand All @@ -71,12 +71,12 @@
'absolute left-0 top-0 flex w-6 justify-center'
]"
>
<div class="w-px bg-base-0/20" />
<div class="w-px bg-base-0/20"/>
</div>

<!-- Icon (dot) -->
<div class="relative flex h-6 w-6 flex-none items-center justify-center bg-base-1000">
<div class="h-1.5 w-1.5 rounded-full bg-base-0/10 ring-1 ring-base-0/20" />
<div class="h-1.5 w-1.5 rounded-full bg-base-0/10 ring-1 ring-base-0/20"/>
</div>

<!-- Text -->
Expand All @@ -100,7 +100,7 @@
type="button"
@click="removeHistoryItem(historyItem.path)"
>
<XMarkIcon class="h-5 w-5" />
<XMarkIcon class="h-5 w-5"/>
</button>
</li>
</ol>
Expand Down
12 changes: 6 additions & 6 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sentryVitePlugin } from '@sentry/vite-plugin'
import {sentryVitePlugin} from '@sentry/vite-plugin'

export default defineNuxtConfig({
// TODO: Enable SSR and pre-rendering when Nuxt-Auth supports it
Expand Down Expand Up @@ -48,7 +48,7 @@ export default defineNuxtConfig({
target: 'esnext'
}
},

prerender: {
// crawlLinks: true
// routes: ['/sitemap.xml', '/robots.txt']
Expand Down Expand Up @@ -98,7 +98,7 @@ export default defineNuxtConfig({

css: ['~/assets/css/main.css'],

components: [{ path: '~/components', pathPrefix: false }],
components: [{path: '~/components', pathPrefix: false}],

site: {
url: `https://${process.env.APP_DOMAIN}`
Expand Down Expand Up @@ -157,9 +157,9 @@ export default defineNuxtConfig({
property: false
},
endpoints: {
login: { url: process.env.API_URL + '/auth/log-in', method: 'post' },
refresh: { url: process.env.API_URL + '/auth/refresh', method: 'post' },
user: { url: process.env.API_URL + '/auth/profile', method: 'get' },
login: {url: process.env.API_URL + '/auth/log-in', method: 'post'},
refresh: {url: process.env.API_URL + '/auth/refresh', method: 'post'},
user: {url: process.env.API_URL + '/auth/profile', method: 'get'},
logout: false
}
}
Expand Down

0 comments on commit 2fde6ce

Please sign in to comment.