Skip to content

Commit 4bb3b53

Browse files
committed
feat: include full content path in pub_dir arg
Give users full control over output path and allows outputting to language specific sub-folders. Also remove --kind from Hugo new command based on Hugo 0.89 release notes.
1 parent 061ef0e commit 4bb3b53

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To help us develop this Academic CLI tool and the associated Wowchemy software s
2424

2525
Support development of the Academic CLI:
2626

27-
- ❤️ [Become a **backer** and **unlock rewards**](https://wowchemy.com/sponsor/)
27+
- ❤️ [Become a **GitHub Sponsor** and **unlock perks**](https://github.com/sponsors/gcushen)
2828
- ☕️ [**Donate a coffee**](https://paypal.me/cushen)
2929
- 👩‍💻 [**Contribute**](#contribute)
3030

@@ -65,16 +65,20 @@ Use the `cd` command to navigate to your website folder in the terminal:
6565

6666
academic import --bibtex my_publications.bib
6767

68+
**Import publications to a specific folder (e.g. `content/zh/publication`):**
69+
70+
academic import --bibtex my_publications.bib --publication-dir "content/zh/publication"
71+
6872
Optional arguments:
6973

70-
* `--help` Help
71-
* `--featured` Flag publications as *featured* (to appear in *Featured Publications* widget)
74+
* `--publication-dir PUBLICATION_DIR` Folder to import publications to (defaults to `content/publication`)
7275
* `--overwrite` Overwrite existing publications
73-
* `--publication-dir PUBLICATION_DIR` Path to your publications directory (defaults to `publication`)
7476
* `--normalize` Normalize tags by converting them to lowercase and capitalizing the first letter
77+
* `--featured` Flag publications as *featured* (to appear in *Featured Publications* widget)
7578
* `--verbose` or `-v` Show verbose messages
79+
* `--help` Help
7680

77-
After importing publications, [a full text PDF and image can be associated with each item and further details added via extra parameters](https://wowchemy.com/docs/content/publications/#command-line).
81+
After importing publications, [a full text PDF and image can be associated with each item and further details added via extra parameters](https://wowchemy.com/docs/content/publications/).
7882

7983
**Run a Hugo command (pass-through):**
8084

@@ -99,6 +103,4 @@ Preparing a contribution:
99103

100104
Copyright 2018-present [George Cushen](https://georgecushen.com).
101105

102-
Licensed under the [MIT License](https://github.com/wowchemy/hugo-academic-cli/blob/master/LICENSE.md).
103-
104-
[![Analytics](https://ga-beacon.appspot.com/UA-78646709-2/hugo-academic-cli/readme?pixel)](https://github.com/igrigorik/ga-beacon)
106+
Licensed under the [MIT License](https://github.com/wowchemy/hugo-academic-cli/blob/main/LICENSE.md).

academic/cli.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ def parse_args(args):
4242
)
4343
parser_a.add_argument("--bibtex", required=False, type=str, help="File path to your BibTeX file")
4444
parser_a.add_argument(
45-
"--publication-dir",
46-
required=False,
47-
type=str,
48-
default="publication",
49-
help="Directory that your publications are stored in (default `publication`)",
45+
"--publication-dir", required=False, type=str, default="publication", help="Path to import publications to (default `content/publication`)",
5046
)
5147
parser_a.add_argument("--featured", action="store_true", help="Flag publications as featured")
5248
parser_a.add_argument("--overwrite", action="store_true", help="Overwrite existing publications")

academic/import_bibtex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def import_bibtex(
21-
bibtex, pub_dir="publication", featured=False, overwrite=False, normalize=False, dry_run=False,
21+
bibtex, pub_dir=os.path.join("content", "publication"), featured=False, overwrite=False, normalize=False, dry_run=False,
2222
):
2323
"""Import publications from BibTeX file"""
2424
from academic.cli import AcademicError, log
@@ -42,14 +42,14 @@ def import_bibtex(
4242

4343

4444
def parse_bibtex_entry(
45-
entry, pub_dir="publication", featured=False, overwrite=False, normalize=False, dry_run=False,
45+
entry, pub_dir=os.path.join("content", "publication"), featured=False, overwrite=False, normalize=False, dry_run=False,
4646
):
4747
"""Parse a bibtex entry and generate corresponding publication bundle"""
4848
from academic.cli import log
4949

5050
log.info(f"Parsing entry {entry['ID']}")
5151

52-
bundle_path = f"content/{pub_dir}/{slugify(entry['ID'])}"
52+
bundle_path = os.path.join(pub_dir, slugify(entry["ID"]))
5353
markdown_path = os.path.join(bundle_path, "index.md")
5454
cite_path = os.path.join(bundle_path, "cite.bib")
5555
date = datetime.utcnow()
@@ -77,7 +77,7 @@ def parse_bibtex_entry(
7777
# Prepare YAML front matter for Markdown file.
7878
hugo = utils.hugo_in_docker_or_local()
7979
if not dry_run:
80-
subprocess.call(f"{hugo} new {markdown_path} --kind publication", shell=True)
80+
subprocess.call(f"{hugo} new {markdown_path}", shell=True)
8181
if "docker-compose" in hugo:
8282
time.sleep(2)
8383

academic/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.7.0"
1+
version = "0.8.0"

0 commit comments

Comments
 (0)