Skip to content

Commit 09f9ae8

Browse files
🐸 Create nuxt module
1 parent 5a4a235 commit 09f9ae8

24 files changed

+216
-10485
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) RoboMx <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+59-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,73 @@
55
# Nuxt i18n Netlify CMS Module
66

77
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FRoboMx%2Fnuxt-i18n-netlify-cms&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
8+
[![npm version][npm-version-src]][npm-version-href]
9+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
10+
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
11+
[![Codecov][codecov-src]][codecov-href]
12+
[![License][license-src]][license-href]
813

14+
> Create admin panel to manage i18n content using Netlify CMS
915
10-
## Screenshot
16+
[📖 **Release Notes**](./CHANGELOG.md)
1117

12-
<img src="static/i18n-content.jpeg" alt="i18n content manage" width="600px">
18+
## Setup
19+
20+
1. Add `@nuxt/i18n-netlify-cms` dependency to your project
21+
22+
```bash
23+
yarn add @nuxt/i18n-netlify-cms # or npm install @nuxt/i18n-netlify-cms
24+
```
25+
26+
2. Add `@nuxt/i18n-netlify-cms` to the `modules` section of `nuxt.config.js`
1327

14-
## Server
28+
```js
29+
{
30+
modules: [
31+
// Simple usage
32+
'@nuxt/i18n-netlify-cms',
1533

16-
`yarn start`
34+
// With options
35+
['@nuxt/i18n-netlify-cms', { /* module options */ }]
36+
]
37+
}
38+
```
39+
40+
## Development
41+
42+
1. Clone this repository
43+
2. Install dependencies using `yarn install` or `npm install`
44+
3. Start development server using `npm run dev`
45+
46+
47+
## Screenshot
1748

18-
Note: It will start the Netlify CMS proxy server if `netlifyCmsProxyServer: true` is added in i18n options.
49+
<img src="static/i18n-content.jpeg" alt="i18n content manage" width="600px">
1950

2051
## References
2152

2253
* [Nuxt i18n external JSON setup](https://phrase.com/blog/posts/nuxt-js-tutorial-i18n/#External_JSON_or_JS_Files)
2354
* [Create Nuxt Module](https://nuxtjs.org/blog/creating-a-nuxt-module)
55+
56+
## License
57+
58+
[MIT License](./LICENSE)
59+
60+
Copyright (c) RoboMX <[email protected]>
61+
62+
63+
<!-- Badges -->
64+
[npm-version-src]: https://img.shields.io/npm/v/@nuxt/i18n-netlify-cms/latest.svg
65+
[npm-version-href]: https://npmjs.com/package/@nuxt/i18n-netlify-cms
66+
67+
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxt/i18n-netlify-cms.svg
68+
[npm-downloads-href]: https://npmjs.com/package/@nuxt/i18n-netlify-cms
69+
70+
[github-actions-ci-src]: https://github.com/robomx/nuxt-18n-netlify-cms/workflows/ci/badge.svg
71+
[github-actions-ci-href]: https://github.com/robomx/nuxt-18n-netlify-cms/actions?query=workflow%3Aci
72+
73+
[codecov-src]: https://img.shields.io/codecov/c/github/robomx/nuxt-18n-netlify-cms.svg
74+
[codecov-href]: https://codecov.io/gh/robomx/nuxt-18n-netlify-cms
75+
76+
[license-src]: https://img.shields.io/npm/l/@nuxt/i18n-netlify-cms.svg
77+
[license-href]: https://npmjs.com/package/@nuxt/i18n-netlify-cms

babel.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env', {
5+
targets: {
6+
esmodules: true
7+
}
8+
}
9+
]
10+
]
11+
}

commitlint.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
module.exports = {
2-
extends: ['@commitlint/config-conventional'],
2+
extends: [
3+
'@commitlint/config-conventional'
4+
]
35
}

example/nuxt.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { resolve } = require('path')
2+
3+
module.exports = {
4+
rootDir: resolve(__dirname, '..'),
5+
buildDir: resolve(__dirname, '.nuxt'),
6+
srcDir: __dirname,
7+
modules: [
8+
{ handler: require('../') }
9+
]
10+
}

example/pages/index.vue

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div>
3+
Works!
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
10+
}
11+
</script>

husky.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
hooks: {
3+
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
4+
'pre-commit': 'yarn lint',
5+
'pre-push': 'yarn lint'
6+
}
7+
}

jest.config.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
collectCoverage: true,
4+
collectCoverageFrom: [
5+
'lib/**/*.js',
6+
'!lib/plugin.js'
7+
],
8+
moduleNameMapper: {
9+
'^~/(.*)$': '<rootDir>/lib/$1',
10+
'^~~$': '<rootDir>',
11+
'^@@$': '<rootDir>',
12+
'^@/(.*)$': '<rootDir>/lib/$1'
13+
},
14+
transform: {
15+
'^.+\\.js$': 'babel-jest'
16+
}
17+
}

lib/module.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { resolve } = require('path')
2+
3+
module.exports = async function (moduleOptions) {
4+
const options = {
5+
...this.options['@nuxt/i18n-netlify-cms'],
6+
...moduleOptions
7+
}
8+
9+
this.addPlugin({
10+
src: resolve(__dirname, 'plugin.js'),
11+
fileName: '@nuxt/i18n-netlify-cms.js',
12+
options
13+
})
14+
}
15+
16+
module.exports.meta = require('../package.json')

lib/plugin.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default async function ({ router, store }) {
2+
3+
4+
}

locales/en/test.json

-9
This file was deleted.

locales/fr/test.json

-9
This file was deleted.

modules/nuxtI18nNetlifyCms/index.js

-30
This file was deleted.

nuxt.config.js

-51
This file was deleted.

package.json

100644100755
+34-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
{
2-
"name": "nuxt-i18n-netlify-cms-example",
3-
"version": "1.0.0",
4-
"private": true,
2+
"name": "@nuxtjs/i18n-netlify-cms",
3+
"version": "2020.0.0",
4+
"description": "Create admin panel to manage i18n content using Netlify CMS",
5+
"repository": "robomx/nuxt-18n-netlify-cms",
6+
"license": "MIT",
7+
"contributors": [
8+
"Mexson Fernandes <[email protected]>",
9+
"Ansh Cena <[email protected]>"
10+
],
11+
"files": [
12+
"lib"
13+
],
14+
"main": "lib/module.js",
515
"scripts": {
6-
"dev": "nuxt",
7-
"build": "nuxt build",
8-
"start": "nuxt start",
9-
"generate": "nuxt generate",
10-
"lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .",
11-
"lint:style": "stylelint **/*.{vue,css} --ignore-path .gitignore",
12-
"lint": "yarn lint:js && yarn lint:style"
13-
},
14-
"dependencies": {
15-
"core-js": "^3.6.5",
16-
"nuxt": "^2.14.6",
17-
"nuxt-i18n": "^6.15.4"
16+
"dev": "nuxt example",
17+
"lint": "eslint --ext .js,.vue .",
18+
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
19+
"test": "yarn lint && jest"
1820
},
21+
"dependencies": {},
1922
"devDependencies": {
20-
"@commitlint/cli": "^11.0.0",
21-
"@commitlint/config-conventional": "^11.0.0",
22-
"@nuxtjs/eslint-config": "^3.1.0",
23-
"@nuxtjs/eslint-module": "^2.0.0",
24-
"@nuxtjs/stylelint-module": "^4.0.0",
25-
"@nuxtjs/tailwindcss": "^3.1.0",
26-
"babel-eslint": "^10.1.0",
27-
"eslint": "^7.10.0",
28-
"eslint-config-prettier": "^6.12.0",
29-
"eslint-plugin-nuxt": "^1.0.0",
30-
"eslint-plugin-prettier": "^3.1.4",
31-
"netlify-cms-proxy-server": "^1.3.7",
32-
"prettier": "^2.1.2",
33-
"stylelint": "^13.7.2",
34-
"stylelint-config-prettier": "^8.0.2",
35-
"stylelint-config-standard": "^20.0.0"
23+
"@babel/core": "latest",
24+
"@babel/preset-env": "latest",
25+
"@commitlint/cli": "latest",
26+
"@commitlint/config-conventional": "latest",
27+
"@nuxtjs/eslint-config": "latest",
28+
"@nuxtjs/module-test-utils": "latest",
29+
"babel-eslint": "latest",
30+
"babel-jest": "latest",
31+
"eslint": "latest",
32+
"husky": "latest",
33+
"jest": "latest",
34+
"nuxt-edge": "latest",
35+
"standard-version": "latest"
36+
},
37+
"publishConfig": {
38+
"access": "public"
3639
}
3740
}

0 commit comments

Comments
 (0)