File tree 2 files changed +44
-4
lines changed
2 files changed +44
-4
lines changed Original file line number Diff line number Diff line change 18
18
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
19
# IN THE SOFTWARE.
20
20
21
+ import logging
22
+
23
+ from mkdocs .commands .build import DuplicateFilter
21
24
from mkdocs .contrib .search import SearchPlugin as BasePlugin
22
25
from mkdocs .contrib .search .search_index import SearchIndex as BaseIndex
23
26
@@ -44,12 +47,29 @@ def add_entry_from_context(self, page):
44
47
super ().add_entry_from_context (page )
45
48
entry = self ._entries [index ]
46
49
47
- # Add document tags
50
+ # Add document tags, if any
48
51
if page .meta .get ("tags" ):
49
- entry ["tags" ] = page .meta ["tags" ]
52
+ if type (page .meta ["tags" ]) is list :
53
+ entry ["tags" ] = [
54
+ str (tag ) for tag in page .meta ["tags" ]
55
+ ]
56
+ else :
57
+ log .warning (
58
+ "Skipping 'tags' due to invalid syntax [%s]: %s" ,
59
+ page .file .src_path ,
60
+ page .meta ["tags" ]
61
+ )
50
62
51
63
# Add document boost for search
52
64
if "search" in page .meta :
53
65
search = page .meta ["search" ]
54
66
if "boost" in search :
55
67
entry ["boost" ] = search ["boost" ]
68
+
69
+ # -----------------------------------------------------------------------------
70
+ # Data
71
+ # -----------------------------------------------------------------------------
72
+
73
+ # Set up logging
74
+ log = logging .getLogger ("mkdocs" )
75
+ log .addFilter (DuplicateFilter ())
Original file line number Diff line number Diff line change 18
18
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
19
# IN THE SOFTWARE.
20
20
21
+ import logging
22
+
23
+ from mkdocs .commands .build import DuplicateFilter
21
24
from mkdocs .contrib .search import SearchPlugin as BasePlugin
22
25
from mkdocs .contrib .search .search_index import SearchIndex as BaseIndex
23
26
@@ -44,12 +47,29 @@ def add_entry_from_context(self, page):
44
47
super ().add_entry_from_context (page )
45
48
entry = self ._entries [index ]
46
49
47
- # Add document tags
50
+ # Add document tags, if any
48
51
if page .meta .get ("tags" ):
49
- entry ["tags" ] = page .meta ["tags" ]
52
+ if type (page .meta ["tags" ]) is list :
53
+ entry ["tags" ] = [
54
+ str (tag ) for tag in page .meta ["tags" ]
55
+ ]
56
+ else :
57
+ log .warning (
58
+ "Skipping 'tags' due to invalid syntax [%s]: %s" ,
59
+ page .file .src_path ,
60
+ page .meta ["tags" ]
61
+ )
50
62
51
63
# Add document boost for search
52
64
if "search" in page .meta :
53
65
search = page .meta ["search" ]
54
66
if "boost" in search :
55
67
entry ["boost" ] = search ["boost" ]
68
+
69
+ # -----------------------------------------------------------------------------
70
+ # Data
71
+ # -----------------------------------------------------------------------------
72
+
73
+ # Set up logging
74
+ log = logging .getLogger ("mkdocs" )
75
+ log .addFilter (DuplicateFilter ())
You can’t perform that action at this time.
0 commit comments