Skip to content

Commit 5fbeb58

Browse files
fagoTurtlBbx
andauthored
Add initial nuxt3 version. Solves #93 (#99)
* LDP-1851: Init a new Nuxt 3 module from Module starter template. * LDP-1851: Make basic functionality work. * LDP-1851: Add error handling and refactor. * LDP-1851: Add messages store & add error handling for menus. * LDP-1851: Add Breadcrumbs to playground page and fix double rendering on SSG. * LDP-1851: Enable auto imports. * LDP-1851: Add useDrupalCePage helper for using page data. * LDP-1851: Support passing useFetch options to useDrupalCeFetchPage. * LDP-1851: Add license file. * LDP-1851: Update module version. * LDP-1851: Update README. * LDP-1851: Add docs for exported composables. * LDP-1851: Set page state inside useDrupalCeFetchPage. * LDP-1851: Use DRUPAL_BASE_URL env for setting baseURL if available. * LDP-1851: Improve docs. Co-authored-by: Matic Fink <[email protected]>
1 parent 2bde80b commit 5fbeb58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+10457
-13344
lines changed

.editorconfig

100755100644
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# editorconfig.org
21
root = true
32

43
[*]

.eslintignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
# Common
2-
node_modules
31
dist
4-
.nuxt
5-
coverage
2+
node_modules

.eslintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": [
3+
"@nuxtjs/eslint-config-typescript"
4+
],
5+
"rules": {
6+
"@typescript-eslint/no-unused-vars": [
7+
"off"
8+
]
9+
}
10+
}

.eslintrc.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

.gitignore

100755100644
Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,56 @@
1+
# Dependencies
12
node_modules
2-
*.iml
3-
.idea
3+
4+
# Logs
45
*.log*
6+
7+
# Temp directories
8+
.temp
9+
.tmp
10+
.cache
11+
12+
# Yarn
13+
**/.yarn/cache
14+
**/.yarn/*state*
15+
16+
# Generated dirs
17+
dist
18+
19+
# Nuxt
520
.nuxt
6-
.vscode
7-
.DS_Store
21+
.output
22+
.vercel_build_output
23+
.build-*
24+
.env
25+
.netlify
26+
27+
# Env
28+
.env
29+
30+
# Testing
31+
reports
832
coverage
9-
dist
33+
*.lcov
34+
.nyc_output
35+
36+
# VSCode
37+
.vscode/*
38+
!.vscode/settings.json
39+
!.vscode/tasks.json
40+
!.vscode/launch.json
41+
!.vscode/extensions.json
42+
!.vscode/*.code-snippets
43+
44+
# Intellij idea
45+
*.iml
46+
.idea
47+
48+
# OSX
49+
.DS_Store
50+
.AppleDouble
51+
.LSOverride
52+
.AppleDB
53+
.AppleDesktop
54+
Network Trash Folder
55+
Temporary Items
56+
.apdisk

.nuxtrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
typescript.includeWorkspace=true

README.md

Lines changed: 31 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Please refer to https://stack.lupus.digital for more info.
2020

2121
## Setup
2222

23-
1. Add `nuxtjs-drupal-ce` dependency to your Nuxt.js project
23+
1. Add `nuxtjs-drupal-ce` dependency to your Nuxt project
2424

2525
```bash
2626
yarn add nuxtjs-drupal-ce # or npm install nuxtjs-drupal-ce
@@ -29,108 +29,70 @@ yarn add nuxtjs-drupal-ce # or npm install nuxtjs-drupal-ce
2929
2. Add `nuxtjs-drupal-ce` to the `modules` section of `nuxt.config.js`
3030

3131
```js
32-
{
33-
buildModules: [
32+
export default defineNuxtConfig({
33+
modules: [
3434
'nuxtjs-drupal-ce',
3535
],
36-
'drupal-ce', {
36+
drupalCe: {
3737
baseURL: 'https://your-drupal.example.com',
3838
// more options...
3939
}
40-
}
40+
})
4141
```
42-
3. Get started quickly by scaffolding initial files:
43-
```bash
44-
rm -f layouts/default.vue && $(npm bin)/nuxt-drupal-ce-init
45-
```
46-
47-
You may also take a look at the [example project](https://github.com/drunomics/lupus-nuxtjs-drupal-stack-example).
4842

4943
## Options
5044

5145
- `baseURL`: The Drupal base URL. Defaults to the `DRUPAL_BASE_URL`
5246
environment variable if provided, otherwise to `http://localhost:8888`.
5347

48+
- `menuEndpoint`: The menu endpoint pattern used for fetching menus. Defaults to 'api/menu_items/$$$NAME$$$' as fitting
49+
to the API provided by the [Rest menu items](https://www.drupal.org/project/rest_menu_items) Drupal module.
50+
`$$$NAME$$$` is replaced by the menu name being fetched.
51+
52+
53+
## TODO list of options (not yet implemented)
54+
5455
- `addRequestFormat`: If set to `true`, the `_format=custom_elements` URL parameter
55-
is added automatically to requests. Defaults to `true`.
56-
56+
is added automatically to requests. Defaults to `true`.
57+
5758
- `addRequestContentFormat`: If specified, the given value is added as `_content_format`
5859
URL parameter to requests. Disabled by default.
5960

60-
- `addVueCompiler`: If enabled, the Vue compiler is added to the runtime build. This
61-
is necessary if you want to render custom elements markup on runtime. Defaults to `true`.
62-
63-
- `menuEndpoint`: The menu endpoint pattern used for fetching menus. Defaults to 'api/menu_items/$$$NAME$$$' as fitting
64-
to the API provided by the [Rest menu items](https://www.drupal.org/project/rest_menu_items) Drupal module.
65-
`$$$NAME$$$` is replaced by the menu name being fetched. To enable menu fetching, un-comment the nuxtServerInit action
66-
in `store/init.js`.
67-
6861
- `useLocalizedMenuEndpoint`: If enabled, the menu endpoint will use a language prefix as configured by [nuxtjs/i18n](https://i18n.nuxtjs.org) module. Defaults to `true`.
6962

70-
- `useProxy`: If set to `dev-only` and nuxt is in dev-mode, the module automatically
71-
configures `/api` to the Drupal backend via
72-
[@nuxtjs/proxy](https://github.com/nuxt-community/proxy-module) and uses it instead of
63+
- `useProxy`: If set to `dev-only` and nuxt is in dev-mode, the module automatically
64+
configures `/api` to the Drupal backend via
65+
[@nuxtjs/proxy](https://github.com/nuxt-community/proxy-module) and uses it instead of
7366
the Drupal backend, such that there are no CORS issues. Other values supported are
7467
`always` or false.
75-
Note: When using `always` the module must be added to the nuxt `modules` section instead
76-
of the `buildModules` section.
77-
78-
- `axios`: Options to pass-through to the `drupal-ce`
79-
[axios](https://github.com/nuxt-community/axios-module) instance.
68+
Note: When using `always` the module must be added to the nuxt `modules` section instead
69+
of the `buildModules` section.
8070

8171
- `customErrorPages`: By default, error pages provided by Drupal (e.g. 403, 404 page) are shown,
82-
while keeping the right status code. By enabling customErrorPages, the regular Nuxt error
83-
pages are shown instead, such that the pages can be customized with Nuxt. Defaults to `false`.
84-
85-
- `pageErrorHandler`: The default page error handler can be overridden. Example:
86-
```javascript
87-
pageErrorHandler (error, commit, context, options) {
88-
context.error({
89-
statusCode: error.response.status,
90-
message: error.message
91-
})
92-
}
93-
```
94-
95-
- `menuErrorHandler`: The default menu error handler can be overridden. Example:
96-
```javascript
97-
menuErrorHandler (error, commit, context, options) {
98-
commit('addMessage', {
99-
type: 'error',
100-
message: `Custom menu error: ${error.message}.`
101-
})
102-
}
103-
```
72+
while keeping the right status code. By enabling customErrorPages, the regular Nuxt error
73+
pages are shown instead, such that the pages can be customized with Nuxt. Defaults to `false`.
10474

75+
- `pageErrorHandler`: The default page error handler can be overridden.
10576

106-
## Known issues
77+
- `menuErrorHandler`: The default menu error handler can be overridden.
10778

108-
### Decoding HTML entities in plain-text strings
10979

110-
Vue2 has [known problem](https://github.com/vuejs/vue/issues/8805) when decoding HTML entities
111-
of plain-text strings that are delivered as custom element attributes. While it correctly decodes
112-
some HTML-encoded characters, it does not handle all of them.
80+
## Options not supported in 2.x version
11381

114-
The problem has been fixed in Vue3.
82+
- `addVueCompiler`: This is necessary if you want to render custom elements markup on runtime.
83+
If you need this, you may find a solution in this [GitHub issue](https://github.com/nuxt/nuxt/issues/13843).
11584

116-
#### Filter "decodeSpecialChars"
117-
118-
For Vue2, this nuxt-module provides a Vue filter that can be used to work-a-round the issue.
119-
Consider "teaser-text" being a prop containing a plain-text string. In that case, it's
120-
recommended to use the provided filter:
121-
122-
`{{ teaserText | decodeSpecialChars }}`
85+
- `axios`: Options to pass-through to the `drupal-ce`
86+
[axios](https://github.com/nuxt-community/axios-module) instance.
12387

12488

12589
## Development
12690

12791
1. Clone this repository
128-
2. Install dependencies using `yarn install` or `npm install`
129-
3. Start development server using `npm run dev`
130-
131-
## Testing
92+
2. Install dependencies using `npm install`
93+
3. Use `npm run dev` to start [playground](./playground) in development mode.
94+
- Run `npm run dev:prepare` to generate type stubs.
13295

133-
Run `npm run test` or `yarn test`.
13496

13597
## License
13698

babel.config.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/nuxt-drupal-ce-init.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

commitlint.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)