| 1 | const Rule = require("html-validate").Rule; |
| 2 | |
| 3 | class HtmlTitle extends Rule { |
| 4 | documentation(context) { |
| 5 | return { |
| 6 | description: "Title of the page must be defined" |
| 7 | }; |
| 8 | } |
| 9 | |
| 10 | setup() { |
| 11 | this.on("dom:ready", event => { |
| 12 | const title = event.document.querySelector('html head title'); |
| 13 | if (title === null) { |
| 14 | this.report(event.document.querySelector('html'), "Missing <title> tag in the <head>"); |
| 15 | } |
| 16 | else if (!title.textContent || title.textContent.trim().length === 0) { |
| 17 | this.report(title, "No title specified"); |
| 18 | } |
| 19 | else if (title.textContent[0] === '-') { |
| 20 | this.report(title, "Title starts with the dash `-`, add the `title` front matter to the Hugo content"); |
| 21 | } |
| 22 | else if (title.textContent.startsWith('Untitled')) { |
| 23 | this.report(title, "Title starts with the `Untitled` make sure that the Asciidoc file starts with level 1 heading"); |
| 24 | } |
| 25 | }); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | class RelativeLinks extends Rule { |
| 30 | documentation(context) { |
nothing calls this directly
no outgoing calls
no test coverage detected