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

Commit 16d318d

Browse files
feat: integrate with feed (#58)
1 parent 458caeb commit 16d318d

16 files changed

+116
-1
lines changed

Diff for: docs/config/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,18 @@ It will be enabled when `endpoint` is provided. e.g.
249249
```
250250
[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.
251251

252+
## feed
252253

254+
- Type: `object`
255+
- Default: `{}`
256+
- Required: `false`
257+
258+
It will be enabled when `canonical_base` is provided. e.g.
259+
260+
```js
261+
{
262+
canonical_base: 'https://yoursite'
263+
}
264+
```
265+
266+
All the generated files will be placed under your output directory. If you wish to make further configuration, please check out [vuepress-plugin-feed](https://github.com/webmasterish/vuepress-plugin-feed).

Diff for: docs/guide/getting-started.md

+23
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,29 @@ In your theme, You'll probably offer users options whether to enable or not. You
460460

461461
Please head [UI-customization](https://vuepress-plugin-mailchimp.billyyyyy3320.com/#ui-customization) if you don't like the default UI.
462462

463+
## Feed
464+
465+
Feed is another approach to allow your users to get your latest content. RSS, Atom, and even JSON feeds are the right tools for the job. Let's see an example:
466+
467+
```JavaScript
468+
// .vuepress/config.js
469+
module.exports = {
470+
plugins: [
471+
[
472+
'@vuepress/blog',
473+
{
474+
feed: {
475+
canonical_base: 'http://yoursite',
476+
},
477+
},
478+
],
479+
],
480+
}
481+
```
482+
483+
After building, you'll be able to find them (`rss.xml`, `feed.atom`, `feed.json`) in you output directory (`dist`).
484+
485+
463486
## Examples
464487

465488
There're some [examples](https://github.com/vuepressjs/vuepress-plugin-blog/tree/master/examples) under this project help us test this plugin. They're also simplest examples for you after reading all the concept above.

Diff for: examples/sitemap/.vuepress/config.js renamed to examples/sitemap+feed/.vuepress/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = {
2626
sitemap: {
2727
hostname: 'https://yourdomain'
2828
},
29+
feed:{
30+
canonical_base: 'http://localhost:8080',
31+
}
2932
}],
3033
],
3134
}

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"dayjs": "^1.8.19",
5757
"vuejs-paginate": "^2.1.0",
5858
"vuepress-plugin-disqus": "^0.2.0",
59+
"vuepress-plugin-feed": "^0.1.8",
5960
"vuepress-plugin-mailchimp": "^1.4.1",
6061
"vuepress-plugin-sitemap": "^2.3.1"
6162
},

Diff for: src/node/handleOptions.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,23 @@ export function handleOptions(
233233
}
234234
}
235235

236-
if (!!(options.newsletter && options.newsletter.endpoint)) {
236+
if (options.newsletter && options.newsletter.endpoint) {
237237
plugins.push(['vuepress-plugin-mailchimp', options.newsletter]);
238238
services.email.enabled = true;
239239
}
240240

241+
if (options.feed && options.feed.canonical_base) {
242+
/* eslint-disable @typescript-eslint/camelcase */
243+
const defaultFeedOptions = {
244+
posts_directories: [] as string[],
245+
};
246+
directories.forEach(dir => {
247+
defaultFeedOptions.posts_directories.push(dir.dirname);
248+
});
249+
const feedOptions = Object.assign({}, defaultFeedOptions, options.feed);
250+
plugins.push(['vuepress-plugin-feed', feedOptions]);
251+
}
252+
241253
const processedData = {
242254
pageEnhancers,
243255
frontmatterClassificationPages,

Diff for: src/node/interface/Options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export interface BlogPluginOptions {
158158
globalPagination: PaginationConfig;
159159
//TODO: define types
160160
sitemap: any;
161+
feed: any;
161162
comment: Comment;
162163
newsletter: Newsletter;
163164
}

Diff for: yarn.lock

+61
Original file line numberDiff line numberDiff line change
@@ -3987,6 +3987,14 @@ faye-websocket@~0.11.1:
39873987
dependencies:
39883988
websocket-driver ">=0.5.1"
39893989

3990+
3991+
version "2.0.4"
3992+
resolved "https://registry.yarnpkg.com/feed/-/feed-2.0.4.tgz#14cd71b3bae1e965b81f7e0c5927e8941de996f8"
3993+
integrity sha512-sWatfulDP6d18qVaWcu34qmq9ml6UeN6nHSBJpNZ2muBqxjPAdT375whPYAHP+gqLfyabtYU5qf2Dv4nqtlp0w==
3994+
dependencies:
3995+
luxon "^1.3.3"
3996+
xml "^1.0.1"
3997+
39903998
figgy-pudding@^3.5.1:
39913999
version "3.5.1"
39924000
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"
@@ -5879,6 +5887,16 @@ lodash.debounce@^4.0.8:
58795887
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
58805888
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
58815889

5890+
5891+
version "4.6.1"
5892+
resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz#512e9bd721d272d94e3d3a63653fa17516741ca6"
5893+
integrity sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==
5894+
5895+
5896+
version "4.4.0"
5897+
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
5898+
integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=
5899+
58825900
lodash.ismatch@^4.4.0:
58835901
version "4.4.0"
58845902
resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
@@ -5919,6 +5937,16 @@ lodash.templatesettings@^4.0.0:
59195937
dependencies:
59205938
lodash._reinterpolate "^3.0.0"
59215939

5940+
lodash.trimend@^4.5.1:
5941+
version "4.5.1"
5942+
resolved "https://registry.yarnpkg.com/lodash.trimend/-/lodash.trimend-4.5.1.tgz#12804437286b98cad8996b79414e11300114082f"
5943+
integrity sha1-EoBENyhrmMrYmWt5QU4RMAEUCC8=
5944+
5945+
lodash.trimstart@^4.5.1:
5946+
version "4.5.1"
5947+
resolved "https://registry.yarnpkg.com/lodash.trimstart/-/lodash.trimstart-4.5.1.tgz#8ff4dec532d82486af59573c39445914e944a7f1"
5948+
integrity sha1-j/TexTLYJIavWVc8OURZFOlEp/E=
5949+
59225950
59235951
version "4.0.1"
59245952
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
@@ -6002,6 +6030,11 @@ lru-cache@^5.1.1:
60026030
dependencies:
60036031
yallist "^3.0.2"
60046032

6033+
luxon@^1.3.3:
6034+
version "1.21.3"
6035+
resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.21.3.tgz#f1d5c2a7e855d039836cf4954f883ecac8fc4727"
6036+
integrity sha512-lLRwNcNnkZLuv13A1FUuZRZmTWF7ro2ricYvb0L9cvBYHPvZhQdKwrYnZzi103D2XKmlVmxWpdn2wfIiOt2YEw==
6037+
60056038
make-dir@^1.0.0:
60066039
version "1.3.0"
60076040
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
@@ -8096,6 +8129,11 @@ [email protected]:
80968129
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
80978130
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=
80988131

8132+
8133+
version "0.3.0"
8134+
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98"
8135+
integrity sha1-XktmdJOpNXlyjz1S7MHbnKUF3Jg=
8136+
80998137
remove-trailing-separator@^1.0.1:
81008138
version "1.1.0"
81018139
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
@@ -9028,6 +9066,11 @@ strip-json-comments@~2.0.1:
90289066
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
90299067
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
90309068

9069+
9070+
version "3.1.1"
9071+
resolved "https://registry.yarnpkg.com/striptags/-/striptags-3.1.1.tgz#c8c3e7fdd6fb4bb3a32a3b752e5b5e3e38093ebd"
9072+
integrity sha1-yMPn/db7S7OjKjt1LltePjgJPr0=
9073+
90319074
stylehacks@^4.0.0:
90329075
version "4.0.3"
90339076
resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-4.0.3.tgz#6718fcaf4d1e07d8a1318690881e8d96726a71d5"
@@ -9857,6 +9900,19 @@ vuepress-plugin-disqus@^0.2.0:
98579900
dependencies:
98589901
vue-disqus "^3.0.5"
98599902

9903+
vuepress-plugin-feed@^0.1.8:
9904+
version "0.1.8"
9905+
resolved "https://registry.yarnpkg.com/vuepress-plugin-feed/-/vuepress-plugin-feed-0.1.8.tgz#134c69f98c71994d17f926e3c7c2ad006f573195"
9906+
integrity sha512-ZDJ2KTAxdeXiykBKOWTht4qleImaY9OEbm9cqQdc/54j0P45ax1PhJjsq5aTs3GcIE1nbZKLCd4fSzhRY6bijg==
9907+
dependencies:
9908+
feed "2.0.4"
9909+
lodash.defaultsdeep "4.6.1"
9910+
lodash.isempty "4.4.0"
9911+
lodash.trimend "^4.5.1"
9912+
lodash.trimstart "^4.5.1"
9913+
remove-markdown "0.3.0"
9914+
striptags "3.1.1"
9915+
98609916
vuepress-plugin-mailchimp@^1.4.1:
98619917
version "1.4.1"
98629918
resolved "https://registry.yarnpkg.com/vuepress-plugin-mailchimp/-/vuepress-plugin-mailchimp-1.4.1.tgz#458c4a65f633b0690acd650400e3af6769c947f2"
@@ -10171,6 +10227,11 @@ xdg-basedir@^3.0.0:
1017110227
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
1017210228
integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=
1017310229

10230+
xml@^1.0.1:
10231+
version "1.0.1"
10232+
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
10233+
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
10234+
1017410235
xmlbuilder@^13.0.0:
1017510236
version "13.0.2"
1017610237
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-13.0.2.tgz#02ae33614b6a047d1c32b5389c1fdacb2bce47a7"

0 commit comments

Comments
 (0)