Skip to content

Commit

Permalink
add minimal example
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Apr 8, 2024
1 parent 508baa4 commit f7e39ce
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/minimal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/dist/
15 changes: 15 additions & 0 deletions examples/minimal/components/Counter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<button type="button" @click="state.count++">Counter {{ state.count }}</button>
</template>

<script lang="ts">
import { reactive } from 'vue'
export default {
setup(props) {
const state = reactive({ count: 0 })
return {
state
}
}
}
</script>
15 changes: 15 additions & 0 deletions examples/minimal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite build && vite preview"
},
"dependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"vike": "^0.4.165",
"vike-vue": "0.6.3",
"vite": "^5.1.1",
"vue": "^3.4.18"
},
"type": "module"
}
48 changes: 48 additions & 0 deletions examples/minimal/pages/+Layout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<template>
<div class="layout">
<div class="navigation">
<a class="navitem" href="/">Home</a>
<a class="navitem" href="/about">About</a>
</div>
<div class="content"><slot /></div>
</div>
</template>

<style>
body {
margin: 0;
font-family: sans-serif;
}
* {
box-sizing: border-box;
}
a {
text-decoration: none;
}
</style>

<style scoped>
.layout {
display: flex;
max-width: 900px;
margin: auto;
}
.content {
padding: 20px;
border-left: 2px solid #eee;
padding-bottom: 50px;
min-height: 100vh;
}
.navigation {
padding: 20px;
padding-top: 42px;
flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: center;
line-height: 1.8em;
}
.navitem {
padding: 3px;
}
</style>
6 changes: 6 additions & 0 deletions examples/minimal/pages/+config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import vikeVue from 'vike-vue/config'

// Default configs (can be overridden by pages)
export default {
extends: vikeVue
}
4 changes: 4 additions & 0 deletions examples/minimal/pages/about/+Page.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template>
<h1>About</h1>
<p>Example of using Vike.</p>
</template>
14 changes: 14 additions & 0 deletions examples/minimal/pages/index/+Page.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<h1>My Vike + Vue app</h1>
This page is:
<ul>
<li>Rendered to HTML.</li>
<li>Interactive. <Counter /></li>
</ul>
</template>

<script lang="ts">
import Counter from '../../components/Counter.vue'
const components = { Counter }
export default { components }
</script>
8 changes: 8 additions & 0 deletions examples/minimal/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Minimal example of using `vike-vue`.

```bash
git clone [email protected]:vikejs/vike-vue
cd vike-vue/examples/minimal/
npm install
npm run dev
```
6 changes: 6 additions & 0 deletions examples/minimal/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import vue from '@vitejs/plugin-vue'
import vike from 'vike/plugin'

export default {
plugins: [vue(), vike()]
}
35 changes: 34 additions & 1 deletion pnpm-lock.yaml

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

0 comments on commit f7e39ce

Please sign in to comment.