# KB Markdown Importer

WordPress plugin for importing GitLab based Markdown documentation into a versioned customer portal knowledgebase.

## Expected GitLab project structure

Each product has one GitLab project. Each documentation version is represented by a branch, for example `v1.0.0`, `v1.1.0` or `v2.0.0`.

```text
doku.md
stepbystep.md
faq.md
doku.yml
images/
  screenshot.png
```

Required:

- `doku.md`
- `stepbystep.md`
- `images/`

Optional:

- `faq.md`
- `doku.yml` for title, version and navigation order

## Features

- GitLab settings and connection test in the WordPress admin.
- Custom post type `kb_doc_page`.
- Taxonomies for products, versions and components.
- Manual GitLab sync for projects, version branches, Markdown pages and images.
- WordPress-native Markdown rendering with internal `.md` link rewriting.
- Frontend routes under `/docs/`.
- Shortcodes: `[kb_docs]`, `[kb_docs_index]`, `[kb_product_index product="..."]`, `[kb_search]`.
- Stored OLM changelog sync using the saved OLM credentials, grouped by release month.
- Product management for frontend product grouping, documentation parts and categories.
- Wide documentation app layout with an always-visible active page navigation.
- Import logs without exposing secrets.

## Product grouping

Imported GitLab projects stay as individual `kb_product` terms. In **Knowledgebase > Products**, each imported term can be assigned to a shared frontend product by setting the same frontend product name and slug. Changes are edited in one table and persisted with **Save all products**.

Example:

```text
HubSpot App    -> frontend product: HubSpot, part: App
HubSpot Modul  -> frontend product: HubSpot, part: Modul
DATEV Exporter -> frontend product: DATEV, part: Exporter
```

Products can also be assigned a category such as `CRM`, `Telefonie` or `Integrationen`; the frontend groups product cards and sidebar entries by this category.

## OLM changelog sync

The changelog is synchronized manually from **Knowledgebase > Synchronization** with `Sync OLM Changelog`, or automatically whenever the configured documentation sync interval runs. `Sync All` runs both the GitLab import and the OLM changelog sync.

The sync follows the existing Python flow: login, load OLM products, collect download IDs, load download field versions, then store only QA-approved published changelog entries in WordPress. The documentation overview reads this stored data instead of calling OLM on every page view.
