| Title: | Create a 'Quarto' Blog Post |
| Version: | 1.0.0 |
| Description: | Provides an interactive 'RStudio' dialog for creating 'Quarto' blog posts with correctly structured YAML front matter. The dialog collects title, author, date, categories, and other metadata, then scaffolds the post directory, creates the 'index.qmd' file, and optionally copies an image. A companion function appends COinS (ContextObjects in Spans) metadata to posts for automatic bibliographic import into reference managers such as 'Zotero'. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1.0) |
| URL: | https://github.com/petzi53/qpost, https://www.peter-baumgartner.net/qpost/ |
| BugReports: | https://github.com/petzi53/qpost/issues |
| Imports: | fs, glue, here, htmltools, lubridate, miniUI, purrr, readr, rlang, rstudioapi, shiny, shinyFeedback, stringi, stringr, urltools, yesno, yaml |
| Suggests: | covr, knitr, rmarkdown, testthat (≥ 3.0.0), withr |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-03 15:33:56 UTC; petzi |
| Author: | Peter Baumgartner |
| Maintainer: | Peter Baumgartner <petzi53@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-12 15:20:02 UTC |
Generate and append COinS metadata to a Quarto post
Description
Automatically extracts bibliographic metadata from a Quarto post's YAML front matter and injects it as a COinS (ContextObjects in Spans) metadata chunk. COinS enables bibliographic tools like Zotero to detect and import citation information from rendered HTML.
Usage
add_coins(file_path = NULL, backup = TRUE)
Arguments
file_path |
Path to the |
backup |
Logical. Create a |
Details
Setup
To use add_coins() effectively, configure your project's .Rprofile
(at the same level as _quarto.yml) with:
options( qpost.lang = "en", qpost.license = "CC BY 4.0" )
Then restart your R session. These settings provide defaults for the
lang and license fields, which can be overridden per-post.
Auto-resolution of Metadata Fields
Four YAML fields are automatically resolved in this priority order:
Value in the document's YAML header (if present and non-empty)
Derived from
_quarto.yml(blog-titleandurlonly)From
.Rprofileoptions (langandlicenseonly)Omitted if not found anywhere
The required fields title and date must be present in the YAML header.
Generated Output
The function appends a fenced R code cell ({r} block) with output
rendered as a hidden <span class="Z3988"> containing the COinS query
string. This metadata is machine-readable but invisible in the browser.
If a COinS chunk already exists (detected by the label coins-code),
the user is prompted to confirm overwrite, and a .bak backup is created.
Determining the Target File
file_path is resolved in this order:
The
file_pathargument, if supplied.The active document in RStudio or Positron, via
rstudioapi.An interactive file picker (
file.choose()) in other interactive R sessions (e.g. a plain R console).Otherwise, the function stops with a message asking for
file_pathto be supplied directly.
Value
Invisibly returns the generated COinS chunk as a character string. Messages and the chunk code are printed to the console.
Examples
# Create a minimal Quarto project in a temporary directory
tmp <- tempdir()
writeLines(
c("project:", " type: website", "website:", " title: My Blog",
" site-url: https://example.com"),
file.path(tmp, "_quarto.yml")
)
post_file <- file.path(tmp, "index.qmd")
writeLines(
c("---", "title: Test Post", "date: 2026-01-01", "---", "", "Content."),
post_file
)
add_coins(file_path = post_file, backup = FALSE)
## Not run:
# From an RStudio or Positron editor with a .qmd file open:
add_coins()
# To skip backup:
add_coins(backup = FALSE)
# To process a file directly (no IDE required):
add_coins(file_path = "path/to/post.qmd")
## End(Not run)
Create a New Quarto Blog Post
Description
qpost() opens an interactive dialog for entering a post's title and
other metadata, then scaffolds the corresponding blog post file.
Usage
qpost()
Details
qpost() requires a pane-capable IDE (RStudio or Positron) because it
relies on rstudioapi to display the dialog and open the resulting
file. It cannot be used in a plain R console or non-interactive script.
Value
Nothing. What matters are the side effects:
create a folder named with the date followed by the kebab-case post title
create an
index.qmdfilecopy the (optional) image file into the folder
populate the YAML front matter
open the new file in RStudio or Positron for editing
Examples
qpost()