Skip to content

Commit

Permalink
Update the Nuxtify installation profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed Apr 21, 2024
1 parent a6d0c6e commit 5200a08
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 21 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@
"web/themes/custom/{$name}": [
"type:drupal-custom-theme"
]
},
"patches": {
"drupal/layout_paragraphs": {
"3397222 - Widget is hidden if untranslatable fields are hidden": "https://git.drupalcode.org/project/layout_paragraphs/-/merge_requests/145.diff"
}
}
}
}
12 changes: 9 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion frontend/base/layouts/preview.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<script setup lang="ts">
useHead({
bodyAttrs: {
class: '!static',
},
})
</script>

<template>
<div class="flex flex-col justify-between flex-1 gap-8 px-4 py-8 md:px-8">
<div class="flex flex-col justify-between flex-1 gap-8 px-4 pb-8 md:px-8">
<main class="flex-1 w-full mx-auto">
<slot />
</main>
Expand Down
5 changes: 0 additions & 5 deletions frontend/base/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ export default defineNuxtConfig({
},

routeRules: {
'/**': {
cache: {
maxAge: process.env.NODE_ENV === 'development' ? 0 : 60,
},
},
'/api/**': {
robots: false,
sitemap: false,
Expand Down
51 changes: 39 additions & 12 deletions frontend/base/pages/preview/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script setup lang="ts">
import type { NodeUnion } from '#build/graphql-operations'
import type { NodeUnion, RouteInternal, RoutePreviewQuery, RouteQuery } from '#build/graphql-operations'
const { finalizePendingLocaleChange } = useI18n()
// Finalize the pending locale change before fetching the route data.
await finalizePendingLocaleChange()
const { locale } = useI18n()
definePageMeta({
layout: 'preview',
})
Expand All @@ -18,6 +20,9 @@ if (process.client) {
watch(
windowHeight,
() => {
if (windowHeight.value <= 0)
return
window.parent.postMessage(
{ name: 'setFrameHeight', height: windowHeight.value },
config.public.backendUrl,
Expand All @@ -33,24 +38,46 @@ const slug = route.params.slug
const path = ref<string>(slug[0] || '' as string)
const token = ref<string>(slug[1] || '' as string)
const { data } = await useAsyncData(
'routePreview',
async () => await useGraphqlQuery(
const data = ref<NodeUnion | undefined>(undefined)
if (path.value && token.value && path.value !== 'node') {
const { data: previewData } = await useAsyncData(
'routePreview',
{
id: `${path.value}`,
token: token.value,
},
),
)
async () => await useGraphqlQuery(
'routePreview',
{
id: `${path.value}`,
token: token.value,
},
),
)
data.value = previewData.value?.data.preview as NodeUnion
}
else {
path.value = Array.isArray(route.params.slug) ? route.params.slug.join('/') : ''
const { data: pageData } = await useAsyncData(
'routePreview',
async () => await useGraphqlQuery(
'route',
{
path: `/${path.value}`,
langcode: locale.value,
},
),
)
data.value = (pageData.value?.data.route as RouteInternal)?.entity as NodeUnion
}
if (data.value?.data === null)
if (data.value === null)
showError({ statusCode: 404, statusMessage: 'Not Found' })
const page = ref<NodeUnion | undefined>(undefined)
function setPageData() {
page.value = data.value?.data?.preview as NodeUnion || undefined
page.value = data.value || undefined
}
setPageData()
Expand Down

0 comments on commit 5200a08

Please sign in to comment.