Add configuration option to limit number of feeds in generated Atom feed
This stops the feed from growing ad infinitum as more and more content is added to the site.
This commit is contained in:
parent
91b24a20d6
commit
84fef97095
6
sbs
6
sbs
|
@ -105,7 +105,7 @@ new()
|
|||
|
||||
parse_configuration()
|
||||
{
|
||||
options="siteURL siteName blogDir languageCode buildOptions pushCommand"
|
||||
options="siteURL siteName blogDir languageCode buildOptions pushCommand numFeedEntries"
|
||||
for key in $options; do
|
||||
value=$(grep "$key" config.ini | cut -d'=' -f2 | xargs)
|
||||
if [ -n "$value" ]; then
|
||||
|
@ -144,7 +144,7 @@ genfeed()
|
|||
fi
|
||||
printf "%s %s\n" "$(lowdown -X date "$file")" "$file" >> "$tmp"
|
||||
done
|
||||
sort -rn "$tmp" | cut -d' ' -f2 | while read -r file; do
|
||||
sort -rn "$tmp" | cut -d' ' -f2 | head -n "$numFeedEntries" | while read -r file; do
|
||||
fileName=$(basename "$file" .md).html
|
||||
subDir=$(dirname "$file" | sed "s/content\///")
|
||||
|
||||
|
@ -320,7 +320,7 @@ case "$1" in
|
|||
push
|
||||
;;
|
||||
"version")
|
||||
echo "v1.2.1" ;
|
||||
echo "v1.3.0" ;
|
||||
;;
|
||||
*)
|
||||
echo "Unknown command. See sbs(1) for documentation."
|
||||
|
|
12
sbs.1
12
sbs.1
|
@ -33,8 +33,8 @@ the template header and footer and placing the resulting file(s) in the
|
|||
./static/ directory. If run without arguments, build everything under the
|
||||
./content/ directory.
|
||||
.It Cm genfeed
|
||||
Compile an Atom feed from all posts found under the configured blog directory,
|
||||
outputting the file to
|
||||
Compile an Atom feed containing the configured number of posts found under the
|
||||
configured blog directory, outputting the file to
|
||||
.Pa static/feed.xml .
|
||||
.It Cm new Ar subcommand
|
||||
.Bl -tag -width Ds
|
||||
|
@ -98,8 +98,14 @@ defaults are sensible and usually do not have to be changed.
|
|||
.It pushCommand
|
||||
An arbitrary shell command executed by
|
||||
.Nm
|
||||
when using the "push" command. Intended to be used for publishing your site
|
||||
when using the
|
||||
.Cm push
|
||||
command. Intended to be used for publishing your site
|
||||
(e.g. openrsync -rv static/* user@website:/var/www/html).
|
||||
.It numFeedEntries
|
||||
The number of entries (posts) to include in the atom feed generated by the
|
||||
.Cm genfeed
|
||||
command.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
.Nm
|
||||
|
|
Loading…
Reference in New Issue