private void renderBlog()

in generator/src/main/groovy/generator/SiteGenerator.groovy [238:286]


    private void renderBlog() {
        def asciidoctor = AsciidoctorFactory.instance
        asciidoctor.requireLibrary('asciidoctor-diagram')
        println "Rendering blogs"

        def blogDir = new File(sourcesDir, "blog")
        Map<String, Document> blogList = [:]
        Map<String, String> contents = [:]
        Map<String, String> baseDirs = [:]
        blogDir.eachFileRecurse { f ->
            if (f.name.endsWith('.adoc')) {
                def bn = f.name.substring(0, f.name.lastIndexOf('.adoc'))
                def options = Options.builder().build()
                def doc = asciidoctor.loadFile(f, options)
                println "Rendering $bn"
                def relativePath = []
                def p = f.parentFile
                while (p != blogDir) {
                    relativePath << p.name
                    p = p.parentFile
                }
                String baseDir = relativePath ? "blog${File.separator}${relativePath.join(File.separator)}" : 'blog'
                blogList[bn] = doc
                contents[bn] = f.getText('utf-8')
                baseDirs[bn] = baseDir
            }
        }
        Map<String, Set> keywords = [:]
        blogList.each { k, v ->
            String kw = v.attributes.keywords.toString()
            keywords[k] = kw?.split(',')*.trim().toSet()
            def groovyVersionInTitle = v.structuredDoctitle.combined.findAll(/(?i)(groovy \d[.]\d+[.]\d+[-\S]*)/)
            groovyVersionInTitle?.each { keywords[k] << it }
            def groovyMinorVersionInTitle = v.structuredDoctitle.combined.findAll(/(?i)(groovy \d[.]\d+)/)
            groovyMinorVersionInTitle?.each { keywords[k] << it }
        }
        Map<String, Map<String, Integer>> related = [:].withDefault { [:] }
        [blogList.keySet(), blogList.keySet()].eachCombination { String one, String two ->
            if (one != two) {
                related[one][two] = keywords[one].intersect(keywords[two]).size()
            }
        }
        blogList.keySet().each { bn ->
            def sorted = related[bn].findAll { it.value as int > 1 }.sort { it.value }.keySet().toList().reverse()
            render 'blog', bn, [notes: contents[bn], doc: blogList[bn], related: sorted.collectEntries { [it, blogList[it].structuredDoctitle.combined] }], baseDirs[bn]
        }
        render 'blogs', "index", [list: blogList], 'blog'
        renderBlogFeed blogList, 'blog'
    }