Working on page pre-rendering

This commit is contained in:
Julien Nahum 2024-01-02 16:35:16 +01:00
parent 3638ef8cfb
commit d1d8e62abb
25 changed files with 1677 additions and 119 deletions

View File

@ -3,8 +3,6 @@ export default defineNuxtRouteMiddleware((to, from) => {
if (!authStore.check) {
useCookie('intended_url').value = to.path
console.log('redirecting to login')
return navigateTo({ name: 'login' })
}
})

View File

@ -1,27 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
import opnformConfig from "./opnform.config";
const modules = [
'@pinia/nuxt',
'@vueuse/nuxt',
'@vueuse/motion/nuxt'
]
if (opnformConfig.sentry_dsn) {
modules.push('@nuxtjs/sentry')
}
const preRenderedRoutes = [
'/',
'/ai-form-builder',
'/login',
'/register',
// '/privacy-policy',
// '/terms-conditions',
'/templates',
'/templates/*',
].reduce((acc, curr) => (acc[curr] = {prerender: true}, acc), {});
import sitemap from "./sitemap";
export default defineNuxtConfig({
devtools: {enabled: true},
@ -30,7 +9,9 @@ export default defineNuxtConfig({
'@pinia/nuxt',
'@vueuse/nuxt',
'@vueuse/motion/nuxt',
'nuxt3-notifications'
'nuxt3-notifications',
'nuxt-simple-sitemap',
// ... opnformConfig.sentry_dsn ? ['@nuxtjs/sentry'] : [],
],
postcss: {
plugins: {
@ -40,6 +21,9 @@ export default defineNuxtConfig({
autoprefixer: {},
},
},
experimental: {
inlineRouteRules: true
},
sentry: {
dsn: opnformConfig.sentry_dsn,
},
@ -59,5 +43,5 @@ export default defineNuxtConfig({
},
'~/components',
],
routeRules: { ... preRenderedRoutes}
sitemap
})

1606
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@
"@nuxt/devtools": "latest",
"autoprefixer": "^10.4.16",
"nuxt": "^3.8.2",
"nuxt-simple-sitemap": "^4.2.3",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6",
"vue": "^3.3.10",
@ -35,6 +36,7 @@
"fuse.js": "^6.4.6",
"js-sha256": "^0.9.0",
"libphonenumber-js": "^1.10.44",
"nuxt3-notifications": "^1.1.9",
"object-to-formdata": "^4.5.1",
"pinia": "^2.1.7",
"prismjs": "^1.24.1",
@ -49,7 +51,6 @@
"vue-notion": "^3.0.0-beta.1",
"vue-signature-pad": "^3.0.2",
"vue3-editor": "^0.1.1",
"nuxt3-notifications": "^1.1.9",
"vuedraggable": "next"
}
}

View File

@ -496,16 +496,18 @@
<script>
import { computed } from 'vue'
import { useAuthStore } from '../stores/auth'
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
import SeoMeta from '../mixins/seo-meta.js'
export default {
components: {OpenFormFooter},
layout: 'default',
mixins: [SeoMeta],
setup () {
const authStore = useAuthStore()
defineRouteRules({
prerender: true
})
return {
authenticated : computed(() => authStore.check),
}

View File

@ -23,15 +23,7 @@
</template>
<script>
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
import SeoMeta from '../../../mixins/seo-meta.js'
export default {
components: {
OpenFormFooter
},
mixins: [SeoMeta],
middleware: 'guest',
data: () => ({

View File

@ -33,15 +33,7 @@
</template>
<script>
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
import SeoMeta from '../../../mixins/seo-meta.js'
export default {
components: {
OpenFormFooter
},
mixins: [SeoMeta],
middleware: 'guest',
data: () => ({

View File

@ -1,35 +0,0 @@
<template>
<div>
<div class="mt-6 flex flex-col">
<div class="w-full md:max-w-3xl md:mx-auto px-4 md:pt-16 pb-10">
<h1 class="sm:text-5xl mb-4">
OpnForm Discount for Students, Academics and NGOs
</h1>
<notion-page page-id="c65a499d39834e0b8978556a8d7af867" />
</div>
</div>
<open-form-footer />
</div>
</template>
<script>
import OpenFormFooter from '../../components/pages/OpenFormFooter.vue'
export default {
components: { OpenFormFooter },
layout: 'default',
props: {
metaTitle: { type: String, default: 'OpnForm Discount for Students, Academics and NGOs' },
metaDescription: { type: String, default: 'If you are a student, an academic of if you work for a NGO we are happy to offer you a 40% discount on your OpnForm Pro subscription.' }
},
data: () => ({
}),
computed: {},
mounted () {
}
}
</script>

View File

@ -31,7 +31,9 @@ import {initForm} from "~/composables/forms/initForm.js"
import {loadAllTemplates} from "~/stores/templates.js";
import {fetchAllWorkspaces} from "~/stores/workspaces.js";
// middleware: 'guest',
definePageMeta({
middleware: "auth"
})
const templatesStore = useTemplatesStore()
const workingFormStore = useWorkingFormStore()

View File

@ -26,6 +26,10 @@ import {initForm} from "~/composables/forms/initForm.js"
import FormEditor from "~/components/open/forms/components/FormEditor.vue"
import CreateFormBaseModal from '../../../components/pages/forms/create/CreateFormBaseModal.vue'
definePageMeta({
middleware: "auth"
})
// metaTitle: 'Create a new Form',
// beforeRouteLeave (to, from, next) {

View File

@ -118,7 +118,6 @@ import {useFormsStore} from '../stores/forms'
import {useWorkspacesStore} from '../stores/workspaces'
import Fuse from 'fuse.js'
import TextInput from '../components/forms/TextInput.vue'
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
import ExtraMenu from '../components/pages/forms/show/ExtraMenu.vue'
import {refDebounced} from "@vueuse/core"

View File

@ -189,18 +189,21 @@ import Features from '~/components/pages/welcome/Features.vue'
import MoreFeatures from '~/components/pages/welcome/MoreFeatures.vue'
import PricingTable from '../components/pages/pricing/PricingTable.vue'
import AiFeature from '~/components/pages/welcome/AiFeature.vue'
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
import Testimonials from '../components/pages/welcome/Testimonials.vue'
import TemplatesSlider from '../components/pages/welcome/TemplatesSlider.vue'
import SeoMeta from '../mixins/seo-meta.js'
export default {
components: {Testimonials, OpenFormFooter, Features, MoreFeatures, PricingTable, AiFeature, TemplatesSlider},
components: {Testimonials, Features, MoreFeatures, PricingTable, AiFeature, TemplatesSlider},
mixins: [SeoMeta],
layout: 'default',
setup() {
const authStore = useAuthStore()
defineRouteRules({
prerender: true
})
return {
authenticated: computed(() => authStore.check),
config: useAppConfig()

View File

@ -13,10 +13,7 @@
</template>
<script>
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
export default {
components: { OpenFormFooter },
layout: 'default',
props: {

View File

@ -53,12 +53,10 @@
</template>
<script>
import OpenFormFooter from '~/components/pages/OpenFormFooter.vue'
import LoginForm from "~/components/pages/auth/components/LoginForm.vue"
export default {
components: {
OpenFormFooter,
LoginForm
},
@ -66,6 +64,9 @@ export default {
definePageMeta({
middleware: "guest"
})
defineRouteRules({
prerender: true
})
},
data: () => ({

View File

@ -238,27 +238,26 @@
<script>
import { computed } from 'vue'
import { useAuthStore } from '../stores/auth';
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
import PricingTable from '../components/pages/pricing/PricingTable.vue'
import SeoMeta from '../mixins/seo-meta.js'
export default {
components: {OpenFormFooter, PricingTable},
mixins: [SeoMeta],
components: {PricingTable},
layout: 'default',
props: {},
beforeRouteEnter(to, from, next) {
if (!this.$config.paid_plans_enabled) { // If no paid plan so no need this page
next({name: 'home'})
return
}
next()
},
setup () {
definePageMeta({
middleware: [
function (to, from) {
// Custom inline middleware
if (!useAppConfig().paid_plans_enabled) { // If no paid plan so no need this page
return navigateTo('/', { redirectCode: 301 })
}
},
],
});
const authStore = useAuthStore()
return {
user : computed(() => authStore.user),
authenticated : computed(() => authStore.check)

View File

@ -13,13 +13,9 @@
</template>
<script>
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
import SeoMeta from '../mixins/seo-meta.js'
export default {
components: { OpenFormFooter},
layout: 'default',
mixins: [SeoMeta],
data: () => ({
metaTitle: 'Privacy Policy',

View File

@ -54,17 +54,23 @@
</template>
<script>
import OpenFormFooter from '~/components/pages/OpenFormFooter.vue'
import RegisterForm from "~/components/pages/auth/components/RegisterForm.vue"
import AppSumoRegister from "~/components/vendor/appsumo/AppSumoRegister.vue"
export default {
components: {
AppSumoRegister,
OpenFormFooter,
RegisterForm
},
setup() {
definePageMeta({
middleware: "guest"
})
defineRouteRules({
prerender: true
})
},
middleware: 'guest',

View File

@ -18,12 +18,9 @@
<script>
import { computed } from 'vue'
import { useAuthStore } from '../../stores/auth'
import OpenFormFooter from '../../components/pages/OpenFormFooter.vue'
import SeoMeta from '../../mixins/seo-meta.js'
export default {
components: { OpenFormFooter },
mixins: [SeoMeta],
layout: 'default',
middleware: 'auth',

View File

@ -201,6 +201,10 @@ import Breadcrumb from '~/components/global/Breadcrumb.vue'
import SingleTemplate from '../../components/pages/templates/SingleTemplate.vue'
import {fetchTemplate} from "~/stores/templates.js";
defineRouteRules({
prerender: true
})
const authStore = useAuthStore()
const templatesStore = useTemplatesStore()

View File

@ -22,6 +22,10 @@
<script setup>
import {loadAllTemplates} from "~/stores/templates.js";
defineRouteRules({
prerender: true
})
// props: {
// metaTitle: { type: String, default: 'Templates' },
// metaDescription: { type: String, default: 'Our collection of beautiful templates to create your own forms!' }

View File

@ -42,10 +42,13 @@
<script setup>
import {computed} from 'vue'
import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
import Breadcrumb from '~/components/global/Breadcrumb.vue'
import {loadAllTemplates} from "~/stores/templates.js";
defineRouteRules({
prerender: true
})
const route = useRoute()
const authStore = useAuthStore()
const templatesStore = useTemplatesStore()

View File

@ -13,17 +13,15 @@
</div>
</section>
<templates-list :only-my="true" />
<!-- <templates-list :only-my="true" />-->
</div>
</template>
<script>
import TemplatesList from '../../components/pages/templates/TemplatesList.vue'
import SeoMeta from '../../mixins/seo-meta.js'
export default {
components: { TemplatesList },
mixins: [SeoMeta],
middleware: 'auth',
props: {

View File

@ -46,6 +46,10 @@ import OpenFormFooter from '../../../components/pages/OpenFormFooter.vue'
import Breadcrumb from '~/components/global/Breadcrumb.vue'
import {loadAllTemplates} from "~/stores/templates.js";
defineRouteRules({
prerender: true
})
const route = useRoute()
const authStore = useAuthStore()
const templatesStore = useTemplatesStore()

View File

@ -13,10 +13,7 @@
</template>
<script>
import OpenFormFooter from '../components/pages/OpenFormFooter.vue'
export default {
components: { OpenFormFooter },
layout: 'default',
data: () => ({

4
client/sitemap.js vendored Normal file
View File

@ -0,0 +1,4 @@
export default {
// exclude all URLs that start with /secret
exclude: ['/settings/**', '/subscriptions/**', '/templates/my-templates'],
}