I’m wondering whether anyone else has managed to get visual reviews working with mkdocs
? I wrote a script to inject the header into the generated HTML (this is for mkdocs-material):
#!/bin/sh
# Guess the MR IID.
echo "${CI_OPEN_MERGE_REQUESTS}" >mr.txt
MR_IID=$(awk -F'[!,]' '{print$2}' mr.txt)
# Inject HTML into the correct Jinja2 template, overriding the default theme.
echo "Creating overrides directory."
mkdir -p overrides
echo "Overriding default material theme with review app extensions."
cat > overrides/main.html << HTML
{% extends "base.html" %}
{% block extrahead %}
<script defer
data-project-id='${CI_PROJECT_ID}'
data-project-path='${CI_PROJECT_PATH}'
<!-- Remove the following line to use the same script for multiple merge requests -->
data-merge-request-id='${MR_IID}'
data-mr-url='https://gitlab.com'
id='review-app-toolbar-script'
src='https://gitlab.com/assets/webpack/visual_review_toolbar.js'></script>
{% endblock %}
HTML
# Add the theme overrides to the mkdocs configuration file.
cat > custom.yml << YAML
# Used for GitLab review apps.
custom_dir: overrides
YAML
echo "Injecting new configuration to the mkdocs.yml file."
sed -i "/ name: 'material'/r custom.yml" mkdocs.yml
and the HTML does seem to appear in the <head>
element of the pages, but the review app doesn’t look any different to the site in a development environment.
Have I missed something?
TIA,
Sarah