Skip to content

Commit c3684e3

Browse files
improve: LDP-2708: Update playground with changes from demo and fix scaffold (#316)
* improve: LDP-2708: Update playground with changes from demo * LDP-2708: Remove console log * LDP-2708: Improve init to create directories * LDP-2708: Add layouts to package * LDP-2708: Remove vite config --------- Co-authored-by: Matic Fink <[email protected]>
1 parent f6b0119 commit c3684e3

File tree

7 files changed

+101
-27
lines changed

7 files changed

+101
-27
lines changed

bin/nuxt-drupal-ce-init.cjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ const target = '.'
99
function copyFile(source, target) {
1010
const targetFile = target + '/' + path.basename(source)
1111

12-
// If target is a directory, a new file with the same name will be created
12+
// Create the target directory if it doesn't exist
13+
const targetDir = path.dirname(targetFile)
14+
if (!fs.existsSync(targetDir)) {
15+
fs.mkdirSync(targetDir, { recursive: true })
16+
console.log(targetDir + ' - Directory created.')
17+
}
18+
19+
// If target is a file that doesn't exist, create it
1320
if (!fs.existsSync(targetFile)) {
1421
console.log(targetFile + ' - Created.')
22+
fs.readFileSync(source)
1523
fs.writeFileSync(targetFile, fs.readFileSync(source))
1624
}
1725
else {
@@ -33,7 +41,9 @@ function syncDir(directory) {
3341
// Here we want to make sure our directories exist.
3442
fs.mkdirSync('./components/global', { recursive: true })
3543
fs.mkdirSync('./pages', { recursive: true })
44+
fs.mkdirSync('./layouts', { recursive: true })
3645

3746
syncDir('pages')
47+
syncDir('layouts')
3848
syncDir('components')
3949
copyFile(scaffoldDir + '/app.vue', target)

eslint.config.mjs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
1+
import withNuxt from './.nuxt/eslint.config.mjs'
22

3-
export default createConfigForNuxt({
4-
features: {
5-
tooling: true,
6-
stylistic: true,
7-
},
8-
}).override('nuxt/rules', {
9-
rules: {
10-
'vue/no-v-html': 'off',
11-
'no-useless-escape': 'off',
12-
'vue/multi-word-component-names': 'off',
13-
'@typescript-eslint/no-explicit-any': 'off',
14-
'@typescript-eslint/no-unused-expressions': 'off',
15-
},
16-
ignores: ['playground/server'],
17-
})
3+
export default withNuxt([
4+
{
5+
rules: {
6+
'vue/no-v-html': 'off',
7+
'no-useless-escape': 'off',
8+
'vue/multi-word-component-names': 'off',
9+
'@typescript-eslint/no-explicit-any': 'off',
10+
'@typescript-eslint/no-unused-expressions': 'off',
11+
},
12+
ignores: ['playground/server'],
13+
}
14+
])

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"dist",
1919
"playground/components",
2020
"playground/pages",
21-
"playground/app.vue"
21+
"playground/app.vue",
22+
"playground/layouts"
2223
],
2324
"scripts": {
2425
"prepack": "nuxt-module-build build",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<template>
2+
<ul class="account-menu">
3+
<li
4+
v-for="menuItem in accountMenu"
5+
:key="menuItem.key"
6+
>
7+
<a
8+
class="item"
9+
:href="menuItem.relative"
10+
>
11+
{{ menuItem.title }}
12+
</a>
13+
</li>
14+
</ul>
15+
</template>
16+
17+
<script setup lang="ts">
18+
const accountMenu = await useDrupalCe().fetchMenu('account')
19+
</script>
20+
21+
<style lang="css" scoped>
22+
.account-menu {
23+
display: inline-flex;
24+
list-style: none;
25+
}
26+
27+
.item {
28+
margin: 0 1rem;
29+
text-decoration: none;
30+
color: #222;
31+
}
32+
</style>

playground/components/global/drupal-form--default.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ defineProps<{
1919
method: string
2020
}>()
2121
defineSlots<{
22-
default();
22+
default()
2323
}>()
2424
</script>
25+
26+
<style>
27+
form {
28+
padding: 0 1rem;
29+
}
30+
31+
label {
32+
display: block;
33+
margin-bottom: 0.325rem;
34+
}
35+
36+
input {
37+
max-width: 90%;
38+
padding: 0.5rem;
39+
margin-bottom: 0.75rem;
40+
}
41+
</style>

playground/layouts/default.vue

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
<template>
2-
<header>
3-
<SiteLanguageSwitcher v-if="useNuxtApp().$i18n" />
4-
<NavigationMain />
5-
</header>
6-
<SiteMessages />
7-
<main id="main">
8-
<slot />
9-
</main>
2+
<div>
3+
<header>
4+
<SiteLanguageSwitcher v-if="useNuxtApp().$i18n" />
5+
<NavigationMain />
6+
</header>
7+
<SiteMessages />
8+
<main id="main">
9+
<slot />
10+
</main>
11+
<footer>
12+
<NavigationAccount />
13+
</footer>
14+
</div>
1015
</template>
16+
17+
<style>
18+
#main {
19+
min-height: 70vh;
20+
}
21+
body {
22+
background-color: white;
23+
}
24+
</style>

playground/nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export default defineNuxtConfig({
66
DrupalCe,
77
],
88
compatibilityDate: '2024-12-16',
9+
nitro: {
10+
compressPublicAssets: true,
11+
},
912
drupalCe: {
1013
drupalBaseUrl: 'http://127.0.0.1:3000',
1114
ceApiEndpoint: '/ce-api',

0 commit comments

Comments
 (0)