Skip to content

Commit 58ed66c

Browse files
authored
Merge pull request #358 from cmu-delphi/sgratzl/docs
docs: update README with more guides
2 parents 00535e6 + 494196d commit 58ed66c

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

README.md

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ In order to convert the Rmd files to HTML files for Hugo you also need to:
7979
1. Activate the environment: `conda activate www-main`
8080
1. Install extra R dependencies: `Rscript ./dependencies.R`
8181

82+
As an alternative you can use Docker and Docker Compose. Then it reduces to `docker-compose up -d` to create a docker container for the current environment. In the following you would need to jump into the container to execute the upcoming command via `docker-compose exec r bash`.
83+
8284
#### Commands
8385

8486
1. Activate the environment: `conda activate www-main`
@@ -93,15 +95,88 @@ In order to convert the Rmd files to HTML files for Hugo you also need to:
9395
blogdown also has an integrated server `blogdown::serve_site()` which will render RMarkdown files on the fly and does a similar thing as `hugo server -D`.
9496
A shortcut is available through `npm run start:blog`.
9597

96-
#### Adding a new blog post
98+
## Adding a new blog post
99+
100+
*Prerequisite*: Installed Blog Editor environment from the previous section
101+
102+
### Create new blog file
103+
104+
Create a new file `content/blog` with a naming convention of `YYYY-MM-DD-short-title.Rmd`. The date is the creation date. Copy the template post or another example to start with. *Note*: Starting the file with an underscore (e.g. `_2021-04-20-jj-vaccine.Rmd`), will stop this file from being automatically checked by the Github Action CI. Only do this when the public CI cannot build this post, if for example private data is used.
97105

98106
In case you use new dependencies don't forget to either edit `environment.yml` or `dependencies.R`.
99-
A Github action should runs when Rmd files changes so it will verify that the blog post can be built.
107+
A Github action should run when Rmd files changes so it will verify that the blog post can be built.
100108
However, the converted HTML file along with all generated images are committed to the repository.
101109
This simplifies the deployment and ensures that we have a blog post even when the API or data changes.
102110

111+
### Edit Blog Header
112+
113+
The header of a blog file contains numerous attributes to be defined, including: name, publication date (`date`), tags, a short summary (at most 150 characters), and a list of authors. The author list `authors` is a list of people keys, see below for how to add people.
114+
115+
The `heroImage` is an optional hero image banner. The image is optional but its thumbnail version is not. However, the template post has good default value for this one. The hero image should be a JPG file with 1120x440 pixels. The thumbnail hero image should be a JPG file with 300x200 pixels. The files should be stored in `/content/blog/images`.
116+
117+
The `related` list is a list of related blog links identified by their file name without the Rmd suffix.
118+
119+
### Linking within the blog post
120+
121+
In order to generate links that are relative to the whole website there are two short codes for R Markdown available.
103122

104-
### Release Process
123+
#### Linking to another page
124+
125+
using the `reflink` shortcode. For example, `r blogdown::shortcode_html("reflink", "2020-09-18-google-survey", "Google")` will generate a relative link to the blog post with the filename `2020-09-18-google-survey` and anchor text `Google`.
126+
127+
#### Linking to the API docs
128+
129+
using the `apireflink` shortcode. For example, `r blogdown::shortcode_html("apireflink", "api/covidcast.html", "COVIDcast API")` will generate a link to the API docs and its sub page `api/covidcast.html` and will look like: [`COVIDcast API`](https://cmu-delphi.github.io/delphi-epidata/).
130+
131+
### Creating wide figures
132+
133+
In case of a wide figure, one can break out of the layout by adding the `out.extra = 'class="wide-figure"'` extra argument to the corresponding R chunk.
134+
135+
e.g.,
136+
```
137+
{r, message = FALSE, warning = FALSE, fig.width = 9, fig.height = 5, out.extra = 'class="wide-figure"'}
138+
ggplot(...)
139+
```
140+
141+
### Adding static images
142+
143+
Static images (e.g. pre-generated plots) should be stored in a `/static/blog/<BLOGFILE_NAME>_files` directory and referenced using something like
144+
145+
```
146+
![](/blog/2021-04-29-vaccine-trends-hispanic_files/hesitancy_over_time_hispanic_and_white_adults.png)
147+
```
148+
149+
### Building the blog file
150+
151+
see before using `Rscript -e 'blogdown::build_site(local=TRUE, run_hugo=FALSE, build_rmd="content/blog/<NAME>.Rmd")'` where `<NAME>` should be replaced by the name of the Rmd file. **The generated files should be committed to this repository to ensure reproducibility.**
152+
153+
154+
## Adding new people (team, blog authors)
155+
156+
People on this website are centrally managed in the `/content/people/index.md` file. Each entry should have the following attributes:
157+
158+
* `key` ... short key to identify this person when referencing them in the blog section
159+
* `firstName`, `lastName`, `affiliation`
160+
* `image` ... name of the head shot image (preferred 500x500px in JPG format) stored in `/content/people/headshots`
161+
* `description` ... used within the blog footer as an about the author text
162+
* `note` ...optional note about past contributors
163+
* `link` ... optional used for linking to a personal website
164+
* `team` ... list of teams this person is part of. used to assign places on the teams page. possible values are:
165+
* `core` ... core member
166+
* `blog` ... blog author
167+
* `highlight` ... highlight person on front page
168+
* `external` ... external person not to be listed in the teams page
169+
* `past` ... past member team section
170+
* `leadership` ... ryan and roni
171+
* `contributors` ... contributor team section
172+
* `google` ... google team section
173+
174+
175+
## Adding new news item
176+
177+
News items are short announcements that should be persistent. The are centrally managed in the `/content/news/headless` directory. Each news item is its own file with content, title, and publication date.
178+
179+
## Release Process
105180

106181
The release consists of multiple steps which can be all done via the GitHub website:
107182

@@ -115,4 +190,3 @@ The release consists of multiple steps which can be all done via the GitHub webs
115190
1. create docker image and the production system will be notified to pull this update
116191
1. Once the jobs are completed the new release should be available at https://delphi.cmu.edu within minutes.
117192
1. Done
118-

0 commit comments

Comments
 (0)