'Nuxt RSS Feed dc:creator field
I have created an RSS feed using the @nuxtjs/feed module. Everything is mostly working except I want to use dc:creator instead of author. I have seen RSS feeds that use this field but little in the way of creating a feed that uses it.
Here is my feed function from nuxt.config.js,
feed() {
const client = Prismic.client('https://my-api.cdn.prismic.io/api/v2');
return {
async create(feed) {
feed.addCategory('Most Recent');
const articles = await client.query(
Prismic.Predicates.at('document.type', 'article'),
{
orderings: '[document.last_publication_date desc]',
fetchLinks: ['author.author_name'],
pageSize: 10,
},
);
articles.results.forEach((post) => {
let myText = '';
if (post.data.body.length > 0) {
if (post.data.body[0].primary.text_content.length > 0) {
myText = post.data.body[0].primary.text_content[0].text;
}
}
let myAuthor = '';
if (post.data.article_authors.length > 0) {
myAuthor = post.data.article_authors[0].author.data.author_name;
}
feed.addItem({
content: myText,
image: post.data.splash_image.url,
author: [
{
name: myAuthor,
email: '[email protected]',
},
],
creator: myAuthor,
title: post.data.splash_title,
link: post.href,
date: new Date(post.last_publication_date),
id: post.href,
description: myText,
});
});
},
cacheTime: 1000 * 60 * 15,
type: 'rss2',
path: '/feed',
};
},
This gives me the following xml feed:
<item>
<title><![CDATA[Test article with HTML embed]]></title>
<link>my_url</link>
<guid>my_url</guid>
<pubDate>Fri, 20 May 2022 17:21:20 GMT</pubDate>
<description><![CDATA[this is a rich text block]]></description>
<content:encoded><![CDATA[this is a rich text block]]></content:encoded>
<author>[email protected] (author name)</author>
<enclosure url="img_url" length="0" type="image_url"/>
</item>
Does anyone know why the dc:creator line never appears? How do I use it properly?
Solution 1:[1]
Instead of default_reporter, using check_reporter works fine:
## myproj/code.R
library(testthat)
# code ---------------------
if (fun_1() + fun_2() == 3) {
message("good job")
}
#> Error in fun_1(): could not find function "fun_1"
# funs ---------------------
fun_1 <- function() 1 # OK
fun_2 <- function() 3 # KO
# tests --------------------
with_reporter(check_reporter(), {
test_that("fun_1 works", {
expect_equal(fun_1(), 1)
})
test_that("fun_2 works", {
expect_equal(fun_2(), 2)
})
})
#> == Failed tests ================================================================
#> -- Failure (<text>:19:5): fun_2 works ------------------------------------------
#> fun_2() not equal to 2.
#> 1/1 mismatches
#> [1] 3 - 2 == 1
#>
#> [ FAIL 1 | WARN 0 | SKIP 0 | PASS 1 ]
Created on 2021-12-27 by the reprex package (v2.0.1)
Session infosessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.1.2 (2021-11-01)
#> os Windows 10 x64 (build 22523)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz Europe/Berlin
#> date 2021-12-27
#> pandoc 2.14.0.3 @ C:/Bin/RStudio/bin/pandoc/ (via rmarkdown)
#>
#> - Packages -------------------------------------------------------------------
#> package * version date (UTC) lib source
#> cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.2)
#> crayon 1.4.2 2021-10-29 [1] CRAN (R 4.1.2)
#> desc 1.4.0 2021-09-28 [1] CRAN (R 4.1.2)
#> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.2)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.2)
#> glue 1.6.0 2021-12-17 [1] CRAN (R 4.1.2)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.1.2)
#> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.2)
#> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.2)
#> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.2)
#> pkgload 1.2.4 2021-11-30 [1] CRAN (R 4.1.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.2)
#> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.2)
#> rlang 0.4.12 2021-10-18 [1] CRAN (R 4.1.2)
#> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.2)
#> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.2)
#> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
#> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.2)
#> testthat * 3.1.1 2021-12-03 [1] CRAN (R 4.1.2)
#> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.2)
#> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.1)
#>
#> [1] C:/Bin/R/R-4.1.2/library
#>
#> ------------------------------------------------------------------------------
Moreover, I have just discovered that if I write tests on a script, in RStudio, a button appears to facilitate the testing:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Corrado |

