Skip to content

Instantly share code, notes, and snippets.

@k-oguma
Last active September 27, 2020 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-oguma/702beb7f5a3ba0cbc0ddfdc0e37f3992 to your computer and use it in GitHub Desktop.
Save k-oguma/702beb7f5a3ba0cbc0ddfdc0e37f3992 to your computer and use it in GitHub Desktop.
It makes zenn-cli easier.
# It makes zenn-cli easier.
# Supported OS: ["macOS"]
# Requirements: make, perl
# [zenn-cli guide](https://zenn.dev/zenn/articles/zenn-cli-guide)
.PHONY: all help
.DEFAULT_GOAL := help
help: ## This help
@echo "Usage: make \033[36m[subCommand]\033[0m\n"
@printf "%-35s%s\n" "make" ": Easy zenn-cli"
@perl -lne ' /(.*):\s+?.*##\s+?(.*)/ and printf "%-s \033[36m%-30s\033[0m%s\n", "make", $$1, ": $$2"' $(MAKEFILE_LIST)
list_articles: ## View the article list.
@$(foreach val, $(notdir $(wildcard ./articles/*.md$)), echo ./articles/$(val):; printf "%-4s%s$$(grep '^title:' ./articles/$(val)|head -1)\n";)
list_books: ## View the book list.
@$(foreach val, $(dir $(wildcard ./books/*/config.yaml$)), echo $(val):; printf "%-4s%s$$(grep 'title:' $(val)/config.yaml)\n";)
article: ## Create an article. [Opt] You can specify `SLUG='****' make article_new`.
$(if $(SLUG),\
@npx zenn new:article --slug $(SLUG),\
@npx zenn new:article\
)
book: ## Create a book. [Opt] You can specify `SLUG='****' make book_new`.
$(if $(SLUG),\
@npx zenn new:book --slug $(SLUG),\
@npx zenn new:book\
)
preview: ## Open the preview
@npx zenn preview &
@open http://localhost:8000
preview_close: ## Close the preview
@kill $(shell ps aux | grep zen\[n\] | awk '{print $$2}')
emoji: ## Get emoji. You can specify `EMOJI=${keyword} make emoji`
$(if $(EMOJI),\
@w3m https://emojipedia.org/search/?q=$(EMOJI),\
@w3m https://emojipedia.org/\
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment