| Title: | Create and Edit 'Quarto' Blog Posts |
|---|---|
| Description: | Provides interactive 'RStudio' and 'Positron' dialogs for creating 'Quarto' blog posts with structured YAML front matter and editing the metadata of existing posts. The package can scaffold post directories, create 'index.qmd' files, optionally copy images, and add COinS (ContextObjects in Spans) metadata for automatic bibliographic import into reference managers such as 'Zotero'. |
| Authors: | Peter Baumgartner [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-4526-8791>) |
| Maintainer: | Peter Baumgartner <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.0.9000 |
| Built: | 2026-09-30 14:04:57 UTC |
| Source: | https://github.com/petzi53/qpost |
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.
add_coins(file_path = NULL, backup = TRUE)add_coins(file_path = NULL, backup = TRUE)
file_path |
Path to the |
backup |
Logical. Create a |
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.
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-title and url only)
From .Rprofile options (lang and license only)
Omitted if not found anywhere
The required fields title and date must be present in the YAML header.
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.
file_path is resolved in this order:
The file_path argument, 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_path
to be supplied directly.
Invisibly returns the generated COinS chunk as a character string. Messages and the chunk code are printed to the console.
# Create a minimal Quarto project in a temporary directory tmp <- tempfile() dir.create(tmp) 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 minimal Quarto project in a temporary directory tmp <- tempfile() dir.create(tmp) 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)
edit_post() opens the same interactive dialog as qpost(), pre-populated
with the metadata from an existing post. On submit it rewrites only the YAML
front matter, leaving the post body untouched.
edit_post(file_path = NULL, backup = TRUE)edit_post(file_path = NULL, backup = TRUE)
file_path |
Optional path to a |
backup |
Logical. If |
edit_post() requires a pane-capable IDE (RStudio or Positron) because it
relies on rstudioapi to display the dialog. It cannot be used in a
plain R console or non-interactive script.
Changing the title
When you modify the title in the dialog and click Done, you are asked whether to create a new post directory for the new title:
Yes — copies all files from the old post directory into a new
directory named after the new title's kebab-case slug. The original
directory is renamed to _old-slug.bak/ and its index.qmd has
draft: true set. The new file is opened in the editor automatically.
No — updates only the YAML title: field; the directory name
stays unchanged.
Important: if the post has already been published, creating a new directory changes its URL. This will break existing links, bookmarks, and search-engine entries pointing to the old address.
The backup directory is protected from accidental publication by two
independent mechanisms: the leading _ in its name causes Quarto to
skip it during rendering (consistent with Quarto's own _freeze/ and
_site/ convention), and draft: true in the YAML acts as an
additional human-readable signal. To recover the old title, rename the
directory by removing the leading _ and the .bak suffix.
The dialog shows a reminder in the title field as soon as it detects a change, so you are always aware before clicking Done.
date-modified
This field is automatically set to today's date on every save.
Nothing. The side effect is an updated YAML front matter in the
target .qmd file.
edit_post()edit_post()
qpost() opens an interactive dialog for entering a post's title and
other metadata, then scaffolds the corresponding blog post file.
qpost()qpost()
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.
Nothing. What matters are the side effects:
create a folder named with the date followed by the kebab-case post title
create an index.qmd file
copy the (optional) image file into the folder
populate the YAML front matter
open the new file in RStudio or Positron for editing
qpost()qpost()