Skip to content

Commit

Permalink
feat(examples): added nuxt 3 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewcourtice committed Feb 26, 2022
1 parent 4dcc809 commit e79beea
Show file tree
Hide file tree
Showing 9 changed files with 3,731 additions and 66 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ dist
docs/public

# vuepress build output
.vuepress/dist
.vuepress/dist/
.vuepress/.temp/

.nuxt/
.output/

.DS_STORE
.idea

Expand Down
29 changes: 29 additions & 0 deletions examples/nuxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Nuxt 3 Minimal Starter

We recommend to look at the [documentation](https://v3.nuxtjs.org).

## Setup

Make sure to install the dependencies

```bash
yarn install
```

## Development

Start the development server on http://localhost:3000

```bash
yarn dev
```

## Production

Build the application for production:

```bash
yarn build
```

Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment).
24 changes: 24 additions & 0 deletions examples/nuxt/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div>
<div>
<div>{{ state }}</div>
<input type="text" v-model="firstName">
<input type="text" v-model="lastName">
<div>
<button @click="reset()">Reset</button>
</div>
</div>
<NuxtWelcome />
</div>
</template>

<script lang="ts" setup>
import {
state,
reset,
computeState
} from './store';
const firstName = computeState(s => s.firstName);
const lastName = computeState(s => s.lastName);
</script>
10 changes: 10 additions & 0 deletions examples/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
defineNuxtConfig,
} from 'nuxt3';

// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
modules: [
'@nuxtjs/harlem',
],
});
17 changes: 17 additions & 0 deletions examples/nuxt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"private": true,
"scripts": {
"dev": "nuxi dev",
"build": "nuxi build",
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"nuxt3": "latest"
},
"dependencies": {
"@harlem/extension-compose": "^2.2.3",
"@harlem/extension-reset": "^2.2.3",
"@harlem/extension-storage": "^2.2.3",
"@nuxtjs/harlem": "^1.0.1"
}
}
22 changes: 22 additions & 0 deletions examples/nuxt/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import composeExtension from '@harlem/extension-compose';
import storageExtension from '@harlem/extension-storage';
import resetExtension from '@harlem/extension-reset';

export const {
state,
getter,
reset,
computeState,
} = createStore('app', {
firstName: 'John',
lastName: 'Smith',
}, {
extensions: [
composeExtension(),
storageExtension({
prefix: 'nuxt',
restore: true,
}),
resetExtension(), // order is important!
],
});
4 changes: 4 additions & 0 deletions examples/nuxt/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// https://v3.nuxtjs.org/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"app",
"core",
"docs",
"examples/*",
"packages/*",
"extensions/*",
"plugins/*"
Expand Down
Loading

0 comments on commit e79beea

Please sign in to comment.