# Wiki.js Blog Writer Pipeline Automated pipeline that fetches a page from a [Wiki.js](https://js.wiki) instance, turns it into a blog post using Google Gemini, translates it, and publishes it back to the wiki under `/blog/`. ## How it works ``` Wiki.js page → SOURCE.md → BLOGPOST.md → TRANSLATED_BLOGPOST.md → Wiki.js /blog/ fetch write translate upload ``` 1. **fetch** — Downloads a Wiki.js page as Markdown via GraphQL 2. **write** — Gemini reads `INSTRUCTIONS.md` and writes a blog post from `SOURCE.md` in the configured language 3. **translate** — Gemini translates the blog post into the target language 4. **upload** — Publishes the translated post to Wiki.js under `/blog/{kebab-case-title}`; creates the page if it doesn't exist, updates it if it does ## Requirements - Python 3.8+ - A running Wiki.js instance with API access - A Google Gemini API key (get one free at [aistudio.google.com](https://aistudio.google.com)) ## Setup **1. Clone the repo and enter the directory** ```bash git clone cd blog_writer ``` **2. Copy the example env file and fill in your values** ```bash cp .env.example .env ``` | Variable | Description | |---|---| | `WIKI_BASE_DOMAIN` | Base URL of your Wiki.js instance, e.g. `https://wiki.example.com` | | `WIKI_TOKEN` | Wiki.js API bearer token (Admin → API Access) | | `GEMINI_API_KEY` | Google Gemini API key | | `ORIGINAL_LANG` | Language for the generated blog post (default: `Hungarian`) | | `TRANSLATE_LANG` | Target language for translation (default: `English`) | **3. Create an `INSTRUCTIONS.md` file** This file tells Gemini how to write the blog post — tone, structure, length, style, etc. Example: ```markdown Write an engaging blog post aimed at a general technical audience. Use a friendly but professional tone. Keep it under 600 words. Start with a short hook, then summarize the key points, and end with a call to action. Do not use bullet points — write in flowing paragraphs. ``` ## Usage ```bash # Fetch a wiki page make fetch URL=/path/to/page # Generate the blog post make write # Translate it make translate # Upload to Wiki.js make upload # Run the full pipeline (write → translate → upload) make all ``` > `make fetch` must be run separately with a `URL` argument before `make all`. ## File overview | File | Description | |---|---| | `tool.py` | Main Python script | | `Makefile` | Convenience wrapper around `tool.py` | | `.env` | Your local environment variables (never commit this) | | `.env.example` | Example env file safe to commit | | `INSTRUCTIONS.md` | Gemini prompt instructions for blog post style | | `SOURCE.md` | Raw Markdown fetched from Wiki.js | | `BLOGPOST.md` | Generated blog post in `ORIGINAL_LANG` | | `TRANSLATED_BLOGPOST.md` | Translated blog post in `TRANSLATE_LANG` | ## Notes - The `# H1` title is extracted from `TRANSLATED_BLOGPOST.md` and used as both the Wiki.js page title and the URL slug — it is stripped from the content body to avoid duplication. - If a page already exists at the target path, it will be updated rather than duplicated. - Add `.env`, `SOURCE.md`, `BLOGPOST.md`, and `TRANSLATED_BLOGPOST.md` to your `.gitignore`.