Skip to contents

Creates a directory with relative path ./YYYY (where YYYY is the value of year) and copies the listing template at "./_templates/YYYY.qmd" to YYYY.qmd and, for the latter, replaces YYYY with the value of year, both in the file name and in the file itself. Additionally, an introduction post and a _metadata.yml may be created. See Details for more information.

Usage

aoc_new_year(year = NULL, intro = TRUE)

Arguments

year

An integer representing the year, from 2015 to the current year. Defaults to the current year.

intro

Logical. Whether to include an introduction post.

Value

The path to the new year directory (invisibly)

Details

The listing page, ./YYYY.qmd (where YYYY is the value of year) picks up posts which are in the subdirectory ./YYYY/day (which echoes the URL structure of the Advent of Code website). Note that the website will fail to render if there are no posts under the day directory. To avoid that problem, by default an introduction post introduction is created, assuming that the directory ./_templates/YYYY-intro exists (which it does in the website template https://github.com/EllaKaye/advent-of-code-website-template.) If you don't want an introduction post, set intro = FALSE. An introduction post can also be created separately with aoc_new_intro() or deleted with aoc_delete_intro(). Without an introduction post, note that you will need at least one other post, e.g. through a call to aoc_new_day() before rendering the website.

Additionally, if there is a file ./_templates/_metadata.yml, this will be copied into ./YYYY/day/_metadata.yml. This file is used to set the metadata only for the posts in the day directory.

If there is no intro post and no _metadata.yml file, then only the "./YYYY" directory will be created, not the subdirectory ./YYYY/day. The latter will then be created on the first call to aoc_new_day() for that year. In this case, the website will render after a call to aoc_new_year().

Examples

if (FALSE) aoc_new_year(2022) # \dontrun{}