├── .gitignore
├── LICENSE
├── README.md
├── enhanceAppFile.js
├── index.js
├── package-lock.json
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Runtime data
9 | pids
10 | *.pid
11 | *.seed
12 | *.pid.lock
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # Bower dependency directory (https://bower.io/)
27 | bower_components
28 |
29 | # node-waf configuration
30 | .lock-wscript
31 |
32 | # Compiled binary addons (https://nodejs.org/api/addons.html)
33 | build/Release
34 |
35 | # Dependency directories
36 | node_modules/
37 | jspm_packages/
38 |
39 | # TypeScript v1 declaration files
40 | typings/
41 |
42 | # Optional npm cache directory
43 | .npm
44 |
45 | # Optional eslint cache
46 | .eslintcache
47 |
48 | # Optional REPL history
49 | .node_repl_history
50 |
51 | # Output of 'npm pack'
52 | *.tgz
53 |
54 | # Yarn Integrity file
55 | .yarn-integrity
56 |
57 | # dotenv environment variables file
58 | .env
59 |
60 | # next.js build output
61 | .next
62 |
63 | .DS_Store
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Loris Leiva
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vuepress Plugin Disqus
2 | 🔌 Register a global `` component to add to your layouts.
3 |
4 | This plugins is a vuepress wrapper of [vue-disqus](https://github.com/ktquez/vue-disqus).
5 |
6 | ## Installation
7 |
8 | ```bash
9 | npm i vuepress-plugin-disqus -D
10 | ```
11 |
12 | ## Register the plugin
13 |
14 | ```js
15 | plugins: {
16 | 'disqus': { /* options */ }
17 | },
18 | ```
19 |
20 | Please check out [Config](#config) for options.
21 |
22 | Note that Vuepress allows multiple syntaxes to register plugins. See [Vuepress documentation on how to use a plugin](https://vuepress.vuejs.org/plugin/using-a-plugin.html) for more information.
23 |
24 | ## Use the Disqus component
25 |
26 | This plugin present a out-of-box SSR-friendly component - ``. Just put it wherever you like, and Disqus will be embedded in the right place. For example:
27 |
28 | ```html
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | ```
37 | Or you can simply put it in your `.md` file.
38 | ```markdown
39 | ## Hello VuePress
40 |
41 | This is a demo.
42 |
43 |
44 | ```
45 |
46 | You can use all the props and events defined by [vue-disqus](https://github.com/ktquez/vue-disqus).
47 |
48 | Prop | Data Type | required | Description
49 | --------------- | ---------- | --------- | -----------
50 | `shortname` | String | true | Your disqus shortname.
51 | `url` | String | false | Your URL where Disqus is present
52 | `title` | String | false | Title that identifies the current page.
53 | `identifier` | String | false | The page's unique identifier
54 | `sso_config` | Object | false | Single sign-on (SSO)
55 | `api_key` | String | false | Your API key disqus
56 | `remote_auth_s3`| String | false | implementation with Laravel/PHP
57 | `language` | String | false | Language overrides
58 |
59 | ## Config
60 |
61 | See the table above. All the props are also configuration options for this plugin. They'll be passed to every `Disqus` component. You're still able to override it by passing down props. Note that if you don't set language, it'll use VuePress's $lang as default language.
62 |
63 | There's still one option available - `name` which specifies the name of the disqus component. Defaults to: `Disqus`.
64 |
65 |
--------------------------------------------------------------------------------
/enhanceAppFile.js:
--------------------------------------------------------------------------------
1 | export default ({ Vue }) => {
2 | const options = JSON.parse(DISQUS_OPTIONS);
3 |
4 | const name = options.name || "Disqus"
5 | const component = () => import('vue-disqus/src/vue-disqus.vue')
6 |
7 | // options will be pass down as props to the components later
8 | delete options.name
9 |
10 | Vue.component(name, {
11 | functional: true,
12 | render(h, { parent, props }) {
13 | // Get default lang
14 | let DefaultLanguage;
15 | // The default value is en-US, but it's not a option for Disqus localization
16 | if (parent.$lang === "en-US") {
17 | DefaultLanguage = "en";
18 | } else {
19 | DefaultLanguage = parent.$lang.replace(/\-/, "_");
20 | }
21 |
22 | // SSR-friendly
23 | if (parent._isMounted) {
24 | return h(component, {
25 | // Priority: VuePress's $lang as default language < global configuration < props
26 | props: Object.assign({ language: DefaultLanguage }, options, props)
27 | });
28 | } else {
29 | parent.$once("hook:mounted", () => {
30 | parent.$forceUpdate();
31 | });
32 | }
33 | }
34 | });
35 | };
36 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 |
3 | module.exports = (options) => ({
4 | name: "disqus",
5 |
6 | enhanceAppFiles: [path.resolve(__dirname, "enhanceAppFile.js")],
7 |
8 | define: {
9 | DISQUS_OPTIONS: JSON.stringify(options)
10 | }
11 | })
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vuepress-plugin-disqus",
3 | "version": "0.2.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "vue-disqus": {
8 | "version": "3.0.5",
9 | "resolved": "https://registry.npmjs.org/vue-disqus/-/vue-disqus-3.0.5.tgz",
10 | "integrity": "sha512-T3Y68lXf5W2lYt6j4Y3kZ4opLPH0EAzqriy11MS4D4Q2+UN0tFuUXeYP1MxfvdyaCEboXSM6CUswxsULuNV70Q=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vuepress-plugin-disqus",
3 | "version": "0.2.0",
4 | "description": "Register a global Disqus component to add to your layouts",
5 | "main": "index.js",
6 | "keywords": [
7 | "vuepress",
8 | "plugin",
9 | "disqus"
10 | ],
11 | "repository": {
12 | "type": "git",
13 | "url": "git+https://github.com/lorisleiva/vuepress-plugin-disqus.git"
14 | },
15 | "author": "Loris Leiva",
16 | "license": "MIT",
17 | "bugs": {
18 | "url": "https://github.com/lorisleiva/vuepress-plugin-disqus/issues"
19 | },
20 | "homepage": "https://github.com/lorisleiva/vuepress-plugin-disqus#readme",
21 | "dependencies": {
22 | "vue-disqus": "^3.0.5"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------