Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ jobs:
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
# bash -el required so conda activation persists (README: IMPORTANT)
shell: bash -el {0}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: conda-incubator/setup-miniconda@v3
with:
Expand All @@ -45,6 +46,7 @@ jobs:
activate-environment: osl-web
auto-update-conda: true
conda-solver: libmamba
conda-remove-defaults: true

- name: Install dependencies
run: |
Expand All @@ -56,7 +58,7 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
run: |
pre-commit install
pre-commit run --all-file --verbose
pre-commit run --all-files --verbose

- name: Build the book
run: |
Expand Down
19 changes: 15 additions & 4 deletions .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ groups:
help: pre-build step
backend: bash
run: |
set -e
mkdir -p build
# Directory to search for .ipynb files
# Directory to search for blog sources
export SEARCH_DIR="pages/blog"

# Find all .ipynb files, excluding .ipynb_checkpoints,
# and convert them to Markdown named 'index.md'
# 1) Convert legacy .ipynb posts to Markdown (for now)
# This keeps existing notebook-based posts working while we
# migrate everything to Quarto.
find "$SEARCH_DIR" -path "*/.ipynb_checkpoints/*" -prune -o -name \
"*.ipynb" -exec sh -c \
'jupyter nbconvert --to markdown --template=theme/custom-markdown.tpl --output-dir "$(dirname "$0")" --output "index" "$0"' {} \;

# remove console colors from md files
# 2) Convert .qmd blog posts to Markdown using Quarto
# Run quarto render from inside each blog folder (Quarto rejects --output path).
if command -v quarto >/dev/null 2>&1; then
find "$SEARCH_DIR" -name "*.qmd" -exec sh -c \
'dir=$(dirname "$0"); base=$(basename "$0" .qmd); (cd "$dir" && quarto render "$base.qmd" --to gfm)' {} \;
else
echo "[WW] Quarto is not available on PATH; .qmd files will not be rendered."
fi

# 3) Remove console colors from generated md files
find "$SEARCH_DIR" -name \
"index.md" -exec sh -c \
'cat "$(dirname "$0")/index.md" | python scripts/clean-output.py > "$(dirname "$0")/temp_index.md" && mv "$(dirname "$0")/temp_index.md" "$(dirname "$0")/index.md"' {} \;
Expand Down
26 changes: 13 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,22 @@ dependencies and activate it.

### Creating a New Blog Post

1. **Prepare the Blog Post:**
1. **Prepare the Blog Post (Quarto-first workflow):**

- Navigate to `pages/blog` and create a new folder with a slugified version
of your blog post's title. Use
[https://slugify.online/](https://slugify.online/) to generate a slug.
- Inside this folder, create your blog post file:
- For Markdown: `index.md`
- For Jupyter Notebooks: `index.ipynb` (use Jupyter Lab to create this
directly)
- Inside this folder, create your blog post as a **Quarto document**:
- `index.qmd`

2. **Include a Header Image:**
- Place a header image (either `header.png` or `header.jpg`) in your blog
post folder. Make sure the image is under a free license.

### Metadata and Formatting

- **Markdown Posts:** Add a metadata block at the beginning of your `index.md`
file:
- **Quarto (`.qmd`) Posts:** Add a metadata block at the beginning of your
`index.qmd` file:

```markdown
---
Expand All @@ -75,20 +73,22 @@ dependencies and activate it.
---
```

- **Jupyter Notebook Posts:** The first cell of your `index.ipynb` should be in
`raw` mode containing the same metadata as above.
The body of the file uses standard Markdown plus any Quarto features you need
(code chunks, figures, etc.). During the build, `makim pages.build` will
render `index.qmd` to `index.md` using Quarto so that MkDocs can consume the
generated Markdown.

3. **Building and Viewing:**
- If using a Jupyter Notebook, run `makim pages.build` to convert the
notebook into a Markdown file (`index.md`).
- Add the generated `index.md` to your repository as it will be used to
render the webpage.
- Run `makim pages.build` to render `index.qmd` to `index.md` and build the
site. The generated `index.md` is used to render the webpage.

## Final Steps

Before submitting your blog post:

- Ensure all files are added to your repository.
- For new or migrated posts, confirm that `index.qmd` exists and that
`makim pages.build` successfully generates the corresponding `index.md`.
- Submit a pull request to the main `opensciencelabs.github.io` repository for
review.

Expand Down
1 change: 1 addition & 0 deletions conda/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependencies:
- pip
- poetry
- nodejs
- quarto
Loading
Loading