├── .editorconfig
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── README.md
├── components
├── AppLogo.vue
├── ImageViewer.vue
├── Price.vue
├── ProductList.vue
├── README.md
└── SanityImage.vue
├── css
├── global.css
└── typography.css
├── layouts
├── README.md
└── default.vue
├── nuxt.config.js
├── package-lock.json
├── package.json
├── pages
├── README.md
├── category
│ ├── _category.vue
│ └── index.vue
├── index.vue
├── product
│ ├── _product.vue
│ └── index.vue
└── vendor
│ ├── _vendor.vue
│ └── index.vue
├── plugins
├── README.md
└── globalData.js
├── sanity.js
├── static
├── README.md
└── favicon.ico
├── store
├── README.md
└── index.js
├── utils
└── localize.js
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_size = 2
6 | indent_style = space
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | browser: true,
5 | node: true
6 | },
7 | parserOptions: {
8 | parser: 'babel-eslint'
9 | },
10 | extends: [
11 | 'eslint:recommended',
12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
14 | 'plugin:vue/recommended',
15 | 'plugin:prettier/recommended'
16 | ],
17 | // required to lint *.vue files
18 | plugins: ['vue', 'prettier'],
19 | // add your custom rules here
20 | rules: {
21 | semi: [2, 'never'],
22 | 'vue/max-attributes-per-line': 'off',
23 | 'prettier/prettier': 'error'
24 | }
25 | };
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 |
4 | # logs
5 | npm-debug.log
6 |
7 | # Nuxt build
8 | .nuxt
9 |
10 | # Nuxt generate
11 | dist
12 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # The Transglobal Candy Store
2 |
3 | A frontend example in Vue.js and Nuxt.js for the Sanity.io e-commerce schema
4 |
5 | 🔗 [Read the blog post](https://www.sanity.io/blog/e-commerce-vue-nuxt-snipcart)
6 |
7 | 
8 |
9 |
10 | ## Quickstart on local
11 |
12 | ``` bash
13 | # install dependencies
14 | $ npm install
15 |
16 | # serve with hot reload at localhost:3000
17 | $ npm run dev
18 | ```
19 |
20 | Tips:
21 | - Make sure you are running on http://localhost:3000. If not sanity and snipcart will fail due to CORS origins.
22 | - Vue.js requires a recent Node version so if it fails on startup you might need an upgrade.
23 |
24 | ## Using your own sanity.io data
25 |
26 | You're about five minutes away from running this example with your own data. You'll need to set up a Sanity studio for this so:
27 |
28 | - If you don't have Sanity CLI version 0.130.0 or later, install or upgrade it with `npm install -g @sanity/cli`
29 | - Initialize a new project with `sanity init` and select the e-commerce schema
30 | - `sanity start` will start your studio and let you start adding your products!
31 | - Go to `sanity.json` and locate your `projectId` and `dataset`
32 |
33 | Head back to this project and in `sanity.js` change the `projectId` and `dataset` values to the ones you found above
34 |
35 | Tips:
36 | - Remember to add CORS manage.sanity.io (ex. http://localhost:3000 to run locally)
37 | - You can `sanity deploy` your editor to share it with others
38 |
39 | ## Install your own snipcart
40 | - Go to http://snipcart.com
41 | - Register and copy your API-key from snipcart
42 | - In `nuxt.config.js` paste it into `data-api-key`
43 | - Remember to add your domain/url in your Snicart settings (https://app.snipcart.com/dashboard/account/domains)
44 |
45 | ## Build production server or static project
46 | ``` bash
47 | # build for production and launch server
48 | $ npm run build
49 | $ npm start
50 |
51 | # generate static project
52 | $ npm run generate
53 | ```
54 |
55 | If you want to host this on Netlify, as a static build, follow [these steps](https://www.sanity.io/blog/tutorial-host-your-sanity-based-next-js-project-on-netlify#3-deploy-your-blog-on-netlify) while switching out the `generate` command above and changing the output directory from `out` to `dist`. Note: Nuxt is intended to run as a universal/isomorphic app and will make calls to the Sanity CDN.
56 |
57 | The queries are by default limited to 100 items. This project is just an example, but
58 | it is possible to expand it with pagination or forever-scroll. To get more items,
59 | just add ex [0..1000] to the end of your query https://www.sanity.io/docs/data-store/query-cheat-sheet#slice-operations
60 |
61 | For detailed explanations on how Nuxt.js work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
62 |
--------------------------------------------------------------------------------
/components/AppLogo.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
16 |
--------------------------------------------------------------------------------
/components/ImageViewer.vue:
--------------------------------------------------------------------------------
1 |
2 |
10 | A minimal front-end for the sanity e-commerce example schema, written on
11 | vue.js and
12 | nuxt.js with a client-side shopping
13 | cart from Snipcart.
14 |