Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit f7dbd92

Browse files
feat: integrate mailchimp (#49)
* feat: intergrate mailchimp plugin * docs: add newsletter
1 parent 4373f16 commit f7dbd92

16 files changed

+244
-1
lines changed

docs/config/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,20 @@ Service to accomplish commenting.
218218
Other options depend on which service you pick since this feature is accomplished by the plugins below. All options except `service` will be passed directly to the plugin, so take a look at their documentation for more details:
219219
- [vuepress-plugin-disqus-comment](https://vuepress-plugin-disqus.netlify.com/#config)
220220
- [vuepress-plugin-vssue](https://vssue.js.org/guide/vuepress.html#usage)
221+
222+
## newsletter
223+
224+
- Type: `object`
225+
- Default: `{}`
226+
- Required: `false`
227+
228+
It will be enabled when `endpoint` is provided. e.g.
229+
230+
```js
231+
{
232+
endpoint: 'https://billyyyyy3320.us4.list-manage.com/subscribe/post?u=4905113ee00d8210c2004e038&id=bd18d40138'
233+
}
234+
```
235+
[vuepress-plugin-mailchimp](https://vuepress-plugin-mailchimp.billyyyyy3320.com/) is how we implement the feature. This config will be pass directly to it, so please head [vuepress-plugin-mailchimp](https://vuepress-plugin-mailchimp.billyyyyy3320.com/#config) for more details.
236+
237+

docs/guide/getting-started.md

+20
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,27 @@ module.exports = {
393393
Of course you can use whatever service you like or roll your own comment system. Just simply ignore the config.
394394
:::
395395

396+
## Newsletter
396397

398+
A blog newsletter is an email to notify subscribers you’ve published a new blog post. Emails are a great way to build relationships and engage with your readers.
399+
400+
Just like [Comment](#comment), we integrate a service to help you accomplish it easily. [MailChimp](https://mailchimp.com/) is probably the most well-known email marketing tool. The only required config option is `endpoint`, please head [vuepress-plugin-mailchimp](https://vuepress-plugin-mailchimp.billyyyyy3320.com/#install) to see how to get your own endpoint.
401+
```js
402+
// .vuepress/config.js
403+
module.exports = {
404+
plugins: [
405+
[
406+
'@vuepress/blog',
407+
{
408+
newsletter: {
409+
// Put your endpoint, not mine.
410+
endpoint: "https://billyyyyy3320.us4.list-manage.com/subscribe/post?u=4905113ee00d8210c2004e038&id=bd18d40138"
411+
},
412+
},
413+
],
414+
],
415+
}
416+
```
397417
## Writing a blog theme
398418

399419
If everything is ok, you can start to write a blog theme. Actually, there are only 2 necessary layout components to
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
title: `ULIVZ`,
3+
plugins: [
4+
[require('../../../lib/node'), {
5+
directories: [
6+
{
7+
id: 'post',
8+
dirname: '_posts',
9+
path: '/',
10+
},
11+
],
12+
frontmatters: [
13+
{
14+
id: "tag",
15+
keys: ['tag', 'tags'],
16+
path: '/tag/',
17+
frontmatter: { title: 'Tag' },
18+
},
19+
{
20+
id: "location",
21+
keys: ['location'],
22+
path: '/location/',
23+
frontmatter: { title: 'Location' },
24+
}
25+
],
26+
newsletter: {
27+
endpoint: "https://billyyyyy3320.us4.list-manage.com/subscribe/post?u=4905113ee00d8210c2004e038&id=bd18d40138"
28+
},
29+
}],
30+
],
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<ul id="default-layout">
3+
<li v-for="item in $frontmatterKey.list">
4+
<router-link class="page-link" :to="item.path">{{ item.name }}</router-link>
5+
</li>
6+
</ul>
7+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<div id="global-layout">
3+
<header style="background-color: #DDD">
4+
<router-link to="/">Home</router-link
5+
<router-link to="/tag/">Tag</router-link
6+
<router-link to="/location/">Location</router-link>
7+
</header>
8+
<DefaultGlobalLayout/>
9+
<footer style="background-color: #DDD">Powered by VuePress</footer>
10+
</div>
11+
</template>
12+
13+
<script>
14+
import GlobalLayout from '@app/components/GlobalLayout.vue'
15+
16+
export default {
17+
components: { DefaultGlobalLayout: GlobalLayout },
18+
created() {
19+
console.log()
20+
}
21+
}
22+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div>
3+
<ul id="default-layout">
4+
<li v-for="page in $pagination.pages">
5+
<router-link class="page-link" :to="page.path">{{ page.title }}</router-link>
6+
</li>
7+
</ul>
8+
<div id="pagination">
9+
<router-link v-if="$pagination.hasPrev" :to="$pagination.prevLink">Prev</router-link>
10+
<router-link v-if="$pagination.hasNext" :to="$pagination.nextLink">Next</router-link>
11+
</div>
12+
13+
<Pagination v-if="$pagination.length > 1"/>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import { Pagination } from '../../../../../lib/client/components.js'
19+
20+
export default {
21+
components: { Pagination },
22+
created() {},
23+
}
24+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<div>
3+
<Content />
4+
<SimpleNewsletter />
5+
</div>
6+
7+
</template>
8+
9+
<script>
10+
import SimpleNewsletter from "vuepress-plugin-mailchimp/src/components/SimpleNewsletter";
11+
export default {
12+
components: {
13+
SimpleNewsletter
14+
}
15+
};
16+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
date: 2018-11-7
3+
tag:
4+
- frontmatter
5+
- vuepress
6+
author: ULIVZ
7+
location: Hangzhou
8+
---
9+
10+
# Front Matter in VuePress
11+
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
date: 2019-2-26
3+
tag:
4+
- markdown
5+
- vuepress
6+
author: ULIVZ
7+
location: Hangzhou
8+
---
9+
10+
# Markdown Slot
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
date: 2019-5-6
3+
tag:
4+
- theme
5+
- blog
6+
- vuepress
7+
author: ULIVZ
8+
location: Shanghai
9+
---
10+
11+
# Writing a VuePress theme
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
date: 2019-8-15
3+
tag:
4+
- git
5+
location: Taipei
6+
---
7+
8+
# Why I like "git rebase"
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
date: 2019-9-8
3+
tag:
4+
- vuepress
5+
location: Taipei
6+
---
7+
8+
# Dive into VuePress with Plugin APIs
9+

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@vssue/vuepress-plugin-vssue": "^1.2.0",
5656
"vuejs-paginate": "^2.1.0",
5757
"vuepress-plugin-disqus-comment": "^0.2.3",
58+
"vuepress-plugin-mailchimp": "^1.2.0",
5859
"vuepress-plugin-sitemap": "^2.3.0"
5960
},
6061
"devDependencies": {

src/node/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
7070
}
7171
}
7272

73+
if (options.newsletter && options.newsletter.endpoint) {
74+
plugins.push(['vuepress-plugin-mailchimp', options.newsletter]);
75+
}
76+
7377
return {
7478
name: 'vuepress-plugin-blog',
7579

src/node/interface/Options.ts

+14
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ export interface Comment extends Partial<VssueOptions>, Partial<DisqusOptions> {
128128
service: 'vssue' | 'disqus';
129129
}
130130

131+
export interface Newsletter {
132+
endpoint: string;
133+
title: string;
134+
content: string;
135+
popupConfig: PopupConfig;
136+
}
137+
138+
interface PopupConfig {
139+
enabled: boolean;
140+
popupComponent: string;
141+
timeout: number;
142+
}
143+
131144
/**
132145
* Options for this plugin.
133146
*/
@@ -138,4 +151,5 @@ export interface BlogPluginOptions {
138151
//TODO: define types
139152
sitemap: any;
140153
comment: Comment;
154+
newsletter: Newsletter;
141155
}

yarn.lock

+35-1
Original file line numberDiff line numberDiff line change
@@ -3071,7 +3071,7 @@ de-indent@^1.0.2:
30713071
resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d"
30723072
integrity sha1-sgOOhG3DO6pXlhKNCAS0VbjB4h0=
30733073

3074-
[email protected], debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
3074+
[email protected], debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
30753075
version "2.6.9"
30763076
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
30773077
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@@ -5624,6 +5624,13 @@ jsonfile@^4.0.0:
56245624
optionalDependencies:
56255625
graceful-fs "^4.1.6"
56265626

5627+
jsonp@^0.2.1:
5628+
version "0.2.1"
5629+
resolved "https://registry.yarnpkg.com/jsonp/-/jsonp-0.2.1.tgz#a65b4fa0f10bda719a05441ea7b94c55f3e15bae"
5630+
integrity sha1-pltPoPEL2nGaBUQep7lMVfPhW64=
5631+
dependencies:
5632+
debug "^2.1.3"
5633+
56275634
jsonparse@^1.2.0:
56285635
version "1.3.1"
56295636
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
@@ -7794,6 +7801,15 @@ query-string@^5.0.1:
77947801
object-assign "^4.1.0"
77957802
strict-uri-encode "^1.0.0"
77967803

7804+
query-string@^6.9.0:
7805+
version "6.9.0"
7806+
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.9.0.tgz#1c3b727c370cf00f177c99f328fda2108f8fa3dd"
7807+
integrity sha512-KG4bhCFYapExLsUHrFt+kQVEegF2agm4cpF/VNc6pZVthIfCc/GK8t8VyNIE3nyXG9DK3Tf2EGkxjR6/uRdYsA==
7808+
dependencies:
7809+
decode-uri-component "^0.2.0"
7810+
split-on-first "^1.0.0"
7811+
strict-uri-encode "^2.0.0"
7812+
77977813
querystring-es3@^0.2.0, querystring-es3@^0.2.1:
77987814
version "0.2.1"
77997815
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
@@ -8726,6 +8742,11 @@ spdy@^4.0.1:
87268742
select-hose "^2.0.0"
87278743
spdy-transport "^3.0.0"
87288744

8745+
split-on-first@^1.0.0:
8746+
version "1.1.0"
8747+
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
8748+
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
8749+
87298750
split-string@^3.0.1, split-string@^3.0.2:
87308751
version "3.1.0"
87318752
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
@@ -8841,6 +8862,11 @@ strict-uri-encode@^1.0.0:
88418862
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
88428863
integrity sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=
88438864

8865+
strict-uri-encode@^2.0.0:
8866+
version "2.0.0"
8867+
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
8868+
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
8869+
88448870
string-argv@^0.3.0:
88458871
version "0.3.1"
88468872
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da"
@@ -9826,6 +9852,14 @@ vuepress-plugin-disqus-comment@^0.2.3:
98269852
dependencies:
98279853
vue-disqus "^3.0.5"
98289854

9855+
vuepress-plugin-mailchimp@^1.2.0:
9856+
version "1.2.0"
9857+
resolved "https://registry.yarnpkg.com/vuepress-plugin-mailchimp/-/vuepress-plugin-mailchimp-1.2.0.tgz#674ff69e94fc6b780920787685f40e2867ceb5cd"
9858+
integrity sha512-MI3hZnI8UmuVJppbnGQjUwcv5Ylx73SO3n9jt+7MFR///SEU8Dx6BHVYMLKPPMYHcIFuJstvDgsYvhCkP155vg==
9859+
dependencies:
9860+
jsonp "^0.2.1"
9861+
query-string "^6.9.0"
9862+
98299863
vuepress-plugin-sitemap@^2.3.0:
98309864
version "2.3.0"
98319865
resolved "https://registry.yarnpkg.com/vuepress-plugin-sitemap/-/vuepress-plugin-sitemap-2.3.0.tgz#4fc2573b62235ca80db237fe5e407a241067318b"

0 commit comments

Comments
 (0)