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

Commit

Permalink
feat: integrate with feed (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
billyyyyy3320 committed Jan 16, 2020
1 parent 458caeb commit 16d318d
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 1 deletion.
14 changes: 14 additions & 0 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,18 @@ It will be enabled when `endpoint` is provided. e.g.
```
[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.

## feed

- Type: `object`
- Default: `{}`
- Required: `false`

It will be enabled when `canonical_base` is provided. e.g.

```js
{
canonical_base: 'https://yoursite'
}
```

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).
23 changes: 23 additions & 0 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,29 @@ In your theme, You'll probably offer users options whether to enable or not. You

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

## Feed

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:

```JavaScript
// .vuepress/config.js
module.exports = {
plugins: [
[
'@vuepress/blog',
{
feed: {
canonical_base: 'http://yoursite',
},
},
],
],
}
```

After building, you'll be able to find them (`rss.xml`, `feed.atom`, `feed.json`) in you output directory (`dist`).


## Examples

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports = {
sitemap: {
hostname: 'https://yourdomain'
},
feed:{
canonical_base: 'http://localhost:8080',
}
}],
],
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"dayjs": "^1.8.19",
"vuejs-paginate": "^2.1.0",
"vuepress-plugin-disqus": "^0.2.0",
"vuepress-plugin-feed": "^0.1.8",
"vuepress-plugin-mailchimp": "^1.4.1",
"vuepress-plugin-sitemap": "^2.3.1"
},
Expand Down
14 changes: 13 additions & 1 deletion src/node/handleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,23 @@ export function handleOptions(
}
}

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

if (options.feed && options.feed.canonical_base) {
/* eslint-disable @typescript-eslint/camelcase */
const defaultFeedOptions = {
posts_directories: [] as string[],
};
directories.forEach(dir => {
defaultFeedOptions.posts_directories.push(dir.dirname);
});
const feedOptions = Object.assign({}, defaultFeedOptions, options.feed);
plugins.push(['vuepress-plugin-feed', feedOptions]);
}

const processedData = {
pageEnhancers,
frontmatterClassificationPages,
Expand Down
1 change: 1 addition & 0 deletions src/node/interface/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export interface BlogPluginOptions {
globalPagination: PaginationConfig;
//TODO: define types
sitemap: any;
feed: any;
comment: Comment;
newsletter: Newsletter;
}
61 changes: 61 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3987,6 +3987,14 @@ faye-websocket@~0.11.1:
dependencies:
websocket-driver ">=0.5.1"

feed@2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/feed/-/feed-2.0.4.tgz#14cd71b3bae1e965b81f7e0c5927e8941de996f8"
integrity sha512-sWatfulDP6d18qVaWcu34qmq9ml6UeN6nHSBJpNZ2muBqxjPAdT375whPYAHP+gqLfyabtYU5qf2Dv4nqtlp0w==
dependencies:
luxon "^1.3.3"
xml "^1.0.1"

figgy-pudding@^3.5.1:
version "3.5.1"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790"
Expand Down Expand Up @@ -5879,6 +5887,16 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=

lodash.defaultsdeep@4.6.1:
version "4.6.1"
resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz#512e9bd721d272d94e3d3a63653fa17516741ca6"
integrity sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==

lodash.isempty@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
integrity sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=

lodash.ismatch@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
Expand Down Expand Up @@ -5919,6 +5937,16 @@ lodash.templatesettings@^4.0.0:
dependencies:
lodash._reinterpolate "^3.0.0"

lodash.trimend@^4.5.1:
version "4.5.1"
resolved "https://registry.yarnpkg.com/lodash.trimend/-/lodash.trimend-4.5.1.tgz#12804437286b98cad8996b79414e11300114082f"
integrity sha1-EoBENyhrmMrYmWt5QU4RMAEUCC8=

lodash.trimstart@^4.5.1:
version "4.5.1"
resolved "https://registry.yarnpkg.com/lodash.trimstart/-/lodash.trimstart-4.5.1.tgz#8ff4dec532d82486af59573c39445914e944a7f1"
integrity sha1-j/TexTLYJIavWVc8OURZFOlEp/E=

lodash.unescape@4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.unescape/-/lodash.unescape-4.0.1.tgz#bf2249886ce514cda112fae9218cdc065211fc9c"
Expand Down Expand Up @@ -6002,6 +6030,11 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

luxon@^1.3.3:
version "1.21.3"
resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.21.3.tgz#f1d5c2a7e855d039836cf4954f883ecac8fc4727"
integrity sha512-lLRwNcNnkZLuv13A1FUuZRZmTWF7ro2ricYvb0L9cvBYHPvZhQdKwrYnZzi103D2XKmlVmxWpdn2wfIiOt2YEw==

make-dir@^1.0.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
Expand Down Expand Up @@ -8096,6 +8129,11 @@ relateurl@0.2.x:
resolved "https://registry.yarnpkg.com/relateurl/-/relateurl-0.2.7.tgz#54dbf377e51440aca90a4cd274600d3ff2d888a9"
integrity sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=

remove-markdown@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/remove-markdown/-/remove-markdown-0.3.0.tgz#5e4b667493a93579728f3d52ecc1db9ca505dc98"
integrity sha1-XktmdJOpNXlyjz1S7MHbnKUF3Jg=

remove-trailing-separator@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
Expand Down Expand Up @@ -9028,6 +9066,11 @@ strip-json-comments@~2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

striptags@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/striptags/-/striptags-3.1.1.tgz#c8c3e7fdd6fb4bb3a32a3b752e5b5e3e38093ebd"
integrity sha1-yMPn/db7S7OjKjt1LltePjgJPr0=

stylehacks@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-4.0.3.tgz#6718fcaf4d1e07d8a1318690881e8d96726a71d5"
Expand Down Expand Up @@ -9857,6 +9900,19 @@ vuepress-plugin-disqus@^0.2.0:
dependencies:
vue-disqus "^3.0.5"

vuepress-plugin-feed@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/vuepress-plugin-feed/-/vuepress-plugin-feed-0.1.8.tgz#134c69f98c71994d17f926e3c7c2ad006f573195"
integrity sha512-ZDJ2KTAxdeXiykBKOWTht4qleImaY9OEbm9cqQdc/54j0P45ax1PhJjsq5aTs3GcIE1nbZKLCd4fSzhRY6bijg==
dependencies:
feed "2.0.4"
lodash.defaultsdeep "4.6.1"
lodash.isempty "4.4.0"
lodash.trimend "^4.5.1"
lodash.trimstart "^4.5.1"
remove-markdown "0.3.0"
striptags "3.1.1"

vuepress-plugin-mailchimp@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/vuepress-plugin-mailchimp/-/vuepress-plugin-mailchimp-1.4.1.tgz#458c4a65f633b0690acd650400e3af6769c947f2"
Expand Down Expand Up @@ -10171,6 +10227,11 @@ xdg-basedir@^3.0.0:
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=

xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=

xmlbuilder@^13.0.0:
version "13.0.2"
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-13.0.2.tgz#02ae33614b6a047d1c32b5389c1fdacb2bce47a7"
Expand Down

0 comments on commit 16d318d

Please sign in to comment.