fix: Move generateSlug to admin page to prevent client-side bundling of server utils
This commit is contained in:
@@ -72,8 +72,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { generateSlug } from '~/server/utils/auth'
|
||||
|
||||
const form = reactive({
|
||||
title: '',
|
||||
date: '',
|
||||
@@ -85,6 +83,24 @@ const form = reactive({
|
||||
const loading = ref(false)
|
||||
const successMessage = ref('')
|
||||
|
||||
const generateSlug = (title: string, date: string) => {
|
||||
if (!title || !date) return ''
|
||||
|
||||
const formattedTitle = title
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9\s-]/g, '')
|
||||
.replace(/\s+/g, '-')
|
||||
.replace(/-+/g, '-')
|
||||
.trim()
|
||||
|
||||
const dateObj = new Date(date)
|
||||
const month = String(dateObj.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(dateObj.getDate()).padStart(2, '0')
|
||||
const year = dateObj.getFullYear()
|
||||
|
||||
return `sermon-${month}${day}${year}`
|
||||
}
|
||||
|
||||
const addBibleReference = () => {
|
||||
form.bibleReferences.push('')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user