Skip to content

Commit 529e039

Browse files
committed
Initial tag support
1 parent 24d22ac commit 529e039

File tree

8 files changed

+95
-0
lines changed

8 files changed

+95
-0
lines changed

Diff for: .github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ jobs:
1313
python-version: 3.x
1414
- run: pip install mkdocs
1515
- run: pip install mkdocs-material
16+
- run: pip install git+https://github.com/srymh/MkdocsTagPlugin.git@ac1f02ba95527d11d84b5ec87f4e63851d57fc7d
1617
- run: mkdocs gh-deploy --force

Diff for: docs/Tools_Equipment/Wood_Working/Table_Saw_ts2500.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
tags:
3+
- Equipment
4+
---
5+
16
# TableSaw - ts 2500
27

38
## features

Diff for: docs/tags/Equipment.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pagetype: tagpage
3+
---
4+
5+
# Tag: Equipment
6+
7+
This is a test

Diff for: mkdocs.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ site_url: https://docs.hacman.org.uk
33
repo_url: https://github.com/HACManchester/documentation/
44
theme:
55
name: material
6+
custom_dir: 'theme'
7+
plugins:
8+
- mdoctag

Diff for: theme/main.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{% extends "base.html" %}
2+
3+
{% block site_meta %}
4+
{{ super() }}
5+
{% if page and page.meta.tags %}
6+
{% for tag in page.meta.tags %}
7+
<meta name="tag" content="{{ tag }}">
8+
{% endfor %}
9+
{% endif %}
10+
{% endblock %}
11+
12+
{% block content %}
13+
{{ super() }}
14+
{% if page and page.meta.pagetype == 'tagpage' %}
15+
{% include "tag_page.html" %}
16+
{% endif %}
17+
{% if 'mdoctag' in config.plugins %}
18+
{% include "tag_list.html" %}
19+
{% endif %}
20+
{% endblock %}

Diff for: theme/tag_list.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% if page and page.meta.tags %}
2+
<hr/ >
3+
<div class="mdoctag-tags-label">Tag</div>
4+
<div id="mdoctag-tags-list">
5+
{% for tag in page.meta.tags %}
6+
<a
7+
id="{{ 'mdoctag-tag-link-' + tag }}"
8+
class="mdoctag-tag-link"
9+
href="{{ base_url + '/' + config.plugins['mdoctag'].config['tagpage_dir'] + '/' + tag }}">
10+
{{ tag }}
11+
</a>
12+
{% endfor %}
13+
</div>
14+
<style>
15+
.mdoctag-tag-link {
16+
border: 2px solid;
17+
border-radius: 5px;
18+
padding: 2px;
19+
margin-right: 10px;
20+
}
21+
#mdoctag-tags-list {
22+
margin-bottom: 20px;
23+
}
24+
.mdoctag-tags-label {
25+
margin-bottom: 6px;
26+
}
27+
</style>
28+
{% endif %}

Diff for: theme/tag_page.html

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% if page %}
2+
{% set tag = page.file.name %}
3+
{% set data_file_url = base_url + '/' + config.plugins['mdoctag'].config['data_filename'] %}
4+
{% endif %}
5+
6+
<div id="mdoctag-tag-page-list"></div>
7+
8+
9+
<script>
10+
var tag = '{{ tag }}'; // not secure
11+
var dataFileURL = '{{ data_file_url }}' // not secure
12+
var req = new XMLHttpRequest();
13+
req.open('GET', dataFileURL, false);
14+
req.send(null);
15+
var data = JSON.parse(req.responseText);
16+
var filterd = data.filter(function(page) {
17+
return page.tags.includes(tag);
18+
});
19+
html = '<ul>';
20+
filterd.forEach(function(page) {
21+
var description = page.description.length !== 0 ? page.description : '';
22+
html += '<li><a href="' + page.url;
23+
html += '">' + page.title;
24+
html += '</a>' + ': ' + description + '</li>';
25+
});
26+
html += '</ul>';
27+
document.getElementById('mdoctag-tag-page-list').innerHTML = html;
28+
</script>

Diff for: virtenv/dev_requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Depends
22
mkdocs
33
mkdocs-material
4+
5+
# Tags for mkdocs
6+
git+https://github.com/srymh/MkdocsTagPlugin.git@ac1f02ba95527d11d84b5ec87f4e63851d57fc7d

0 commit comments

Comments
 (0)