diff --git a/Makefile b/Makefile index 1407ffb..f5ed851 100755 --- a/Makefile +++ b/Makefile @@ -23,13 +23,14 @@ DIR_PUBLIC_TMP=.public_tmp HUGO_CMD=${HUGO_DIR}/hugo -.PHONY: help preview update-search-index clear-search-index list-draft html generate-public-pages clear-generated-public-pages index-public-pages clear-public-pages-index clear install uninstall uninstall-hugo uninstall-pagefind +.PHONY: help preview update-search-index clear-search-index newsletter list-draft html generate-public-pages clear-generated-public-pages index-public-pages clear-public-pages-index clear install uninstall uninstall-hugo uninstall-pagefind #: Display this help (i.e. list all available targets). (DEFAULT TARGET) help: @echo "\nMake targets for ivoa-web:\n" @echo "* help Display help (default target).\n" @echo "* preview Start the preview service (on port 1313). All required tools\n are installed/upgraded automatically, when needed.\n" + @echo "* newsletter Create a new newsletter.\n" @echo "* html Generate the HTML version of the IVOA Website (with search\n index).\n" @echo "* list-draft List all draft pages (i.e. all pages only visible in preview\n mode).\n" @echo "* clear Delete local search index and generated public pages.\n" @@ -69,6 +70,24 @@ clear-search-index: rm -rf "${PAGEFIND_INDEX_DIR}"; \ fi +DIR_NEWSLETTER := content/newsletter +ID_LAST_NEWSLETTER := $(shell ls -1 $(DIR_NEWSLETTER) | grep '^[0-9]\+\.md$$' | sort -rn | head -n1 | sed 's/^0*\([1-9][0-9]*\)\.md$$/\1/' ) +NEXT_NEWSLETTER := $(shell printf "%03d.md" "$$(( $(ID_LAST_NEWSLETTER) + 1 ))") + +#: Create a new newsletter. +newsletter: install + @if ${HUGO_CMD} new content "newsletter/$(NEXT_NEWSLETTER)" ; \ + then \ + echo "(from the template 'archetypes/newsletter.md')" ; \ + echo "=> Next steps are yours:" ; \ + echo " 1. Edit the file '$(DIR_NEWSLETTER)/$(NEXT_NEWSLETTER)'" ; \ + echo " 2. Replace all occurences of 'TBD'" ; \ + echo " 3. Add any other content" ; \ + echo " 4. Commit and push changes" ; \ + else \ + echo "=> FAILED to create the newsletter '$(DIR_NEWSLETTER)/$(NEXT_NEWSLETTER)'!" ; \ + fi + #: List all draft pages (i.e. all pages only visible in preview mode). list-draft: install @echo diff --git a/NEWSLETTER.md b/NEWSLETTER.md index fe5cdf5..cdeb739 100644 --- a/NEWSLETTER.md +++ b/NEWSLETTER.md @@ -1,7 +1,7 @@ # How to create a newsletter? -## Using a template +## From template A newsletter is a content with a fairly similar structure from one newsletter to another. In order to help creation of such content, it is possible to use a kind @@ -10,6 +10,19 @@ of template (Hugo calls this an One exists for newsletters (and can be modified when desired ; see next main section ["How to edit the template?"](#how-to-create-a-newsletter)). +## Using the `make` command (recommended) + +1. Run the command `make newsletter` + +2. Edit the file returned by this command. There are content placeholders all + over this file ; search for all occurences of `TBD` and you will find them. + Just replace them by the content you would like to have. + +## Using the Hugo command + +This method is what the `make` command does behind the scene. These instructions +are given here for information and documentation. + To create a newsletter: 1. (Optional) Ensure Hugo is locally installed (`make install`). @@ -27,6 +40,10 @@ To create a newsletter: ## Manual method +This method is exactly what the Hugo command does behind the scene. Using this +method will make you create a newsletter completely from scratch. No template +will be used ; you will start from an empty file. + 1. Create a file called `XXX.md` (where `XXX` is the number of the newsletter to create ; e.g. `026`) in the directory `content/newsletter/`.