Skip to content

Commit bb8d4d9

Browse files
committed
explain how pages are added as feed items
1 parent 1b15b25 commit bb8d4d9

File tree

1 file changed

+55
-38
lines changed

1 file changed

+55
-38
lines changed

README.md

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,29 @@ feed:
7272
name: Contributor
7373
email: contributor@doamin.tld
7474
link: http://doamin.tld
75-
75+
7676
---
7777

7878
```
7979

8080

81+
## How pages are added as feed items
82+
83+
A page is auto added as a feed item if one the following conditions is met:
84+
85+
- `frontmatter.feed.enable === true`
86+
- `frontmatter.type === 'post'`
87+
- it resides in whatever the `posts_directories` are set to (the defaults are `blog` and `_posts`)
88+
89+
if you need to exclude a particular page that meets one of the conditions above,
90+
you can use `frontmatter.feed.enable === false`.
91+
92+
Details on how pages are filtered can be found in [`PLUGIN.is_feed_page()`](index.js).
93+
94+
The `PLUGIN.is_feed_page()` function is the default way of filtering the pages,
95+
you can override it using `is_feed_page` option (see [Options section](#options) below).
96+
97+
8198
## Options
8299

83100
> See Plugin Option API [official docs](https://vuepress.vuejs.org/plugin/option-api.html)
@@ -104,14 +121,14 @@ const {
104121
// @see: https://github.com/jpmonette/feed#example
105122

106123
const feed_options = {
107-
124+
108125
title,
109126
description,
110127
generator: PLUGIN.homepage,
111128

112129
// ---------------------------------------------------------------------------
113-
114-
// the following are auto populated in PLUGIN.get_options()
130+
131+
// the following are auto populated in PLUGIN.get_options()
115132
// if they are not set as options
116133
/*
117134
id,
@@ -120,7 +137,7 @@ const feed_options = {
120137
*/
121138

122139
// ---------------------------------------------------------------------------
123-
140+
124141
// ref:
125142
/*
126143
title: "Feed Title",
@@ -142,31 +159,31 @@ const feed_options = {
142159
link: "https://example.com/johndoe"
143160
}
144161
*/
145-
162+
146163
};
147164

148165
// -----------------------------------------------------------------------------
149-
166+
150167
const default_options = {
151-
168+
152169
// required; it can also be used as enable/disable
153-
170+
154171
canonical_base: '',
155172

156173
// ---------------------------------------------------------------------------
157-
174+
158175
// Feed class options - @see: https://github.com/jpmonette/feed#example
159176
// optional - auto-populated based on context.getSiteData()
160-
177+
161178
feed_options,
162179

163180
// ---------------------------------------------------------------------------
164-
181+
165182
// @notes:
166183
// property name is also the name of the jpmonette/feed package function
167-
184+
168185
feeds: {
169-
186+
170187
rss2: {
171188
enable : true,
172189
file_name : 'rss.xml',
@@ -178,7 +195,7 @@ const default_options = {
178195
},
179196

180197
// -------------------------------------------------------------------------
181-
198+
182199
atom1: {
183200
enable : true,
184201
file_name : 'feed.atom',
@@ -190,7 +207,7 @@ const default_options = {
190207
},
191208

192209
// -------------------------------------------------------------------------
193-
210+
194211
json1: {
195212
enable : true,
196213
file_name : 'feed.json',
@@ -200,82 +217,82 @@ const default_options = {
200217
title : '%%site_title%% JSON Feed',
201218
}
202219
},
203-
220+
204221
},
205222

206223
// ---------------------------------------------------------------------------
207-
224+
208225
// page/post description sources
209-
226+
210227
// order of what gets the highest priority:
211228
//
212229
// 1. frontmatter
213230
// 2. page excerpt
214231
// 3. content markdown paragraph
215232
// 4. content regular html <p>
216-
233+
217234
description_sources: [
218-
235+
219236
'frontmatter',
220237
'excerpt',
221-
238+
222239
// markdown paragraph regex
223240
// @todo: needs work
224241
//
225242
/^((?:(?!^#)(?!^\-|\+)(?!^[0-9]+\.)(?!^!\[.*?\]\((.*?)\))(?!^\[\[.*?\]\])(?!^\{\{.*?\}\})[^\n]|\n(?! *\n))+)(?:\n *)+\n/gim,
226243
//
227244
// this excludes blockquotes using `(?!^>)`
228245
///^((?:(?!^#)(?!^\-|\+)(?!^[0-9]+\.)(?!^!\[.*?\]\((.*?)\))(?!^>)(?!^\[\[.*?\]\])(?!^\{\{.*?\}\})[^\n]|\n(?! *\n))+)(?:\n *)+\n/gim,
229-
246+
230247
// html paragraph regex
231248
/<p(?:.*?)>(.*?)<\/p>/i,
232-
249+
233250
],
234251

235252
// ---------------------------------------------------------------------------
236-
253+
237254
// page/post image sources
238255

239256
// order of what gets the highest priority:
240257
//
241258
// 1. frontmatter
242259
// 2. content markdown image such as `![alt text](http://url)`
243260
// 3. content regular html img
244-
261+
245262
image_sources: [
246-
263+
247264
'frontmatter',
248-
265+
249266
/!\[.*?\]\((.*?)\)/i, // markdown image regex
250267
/<img.*?src=['"](.*?)['"]/i, // html image regex
251-
268+
252269
],
253270

254271
// ---------------------------------------------------------------------------
255-
256-
// pages in current directories will be auto added as feed
272+
273+
// pages in current directories will be auto added as feed
257274
// unless they are disabled using their frontmatter
258275
// this option is used by the default is_feed_page function
259-
276+
260277
posts_directories: ['/blog/', '/_posts/'],
261278

262279
// ---------------------------------------------------------------------------
263-
280+
264281
// function to check if the page is to be used in a feed item
265-
282+
266283
is_feed_page: PLUGIN.is_feed_page, // function
267284

268285
// ---------------------------------------------------------------------------
269-
286+
270287
count: 20,
271288

272289
// ---------------------------------------------------------------------------
273-
290+
274291
// supported - use in config as needed
275-
292+
276293
// category
277294
// contributor
278-
295+
279296
};
280297
```
281298

0 commit comments

Comments
 (0)