Commit 4c74a861 authored by Tobias Schmidt's avatar Tobias Schmidt

ADd warning for outdated versioned content

parent 4ca8a08f
...@@ -54,6 +54,7 @@ compile '*' do ...@@ -54,6 +54,7 @@ compile '*' do
elsif item[:extension] == 'md' elsif item[:extension] == 'md'
filter :redcarpet, options: {filter_html: true, autolink: true, no_intraemphasis: true, fenced_code_blocks: true, gh_blockcode: true, tables: true}, renderer_options: {with_toc_data: true} filter :redcarpet, options: {filter_html: true, autolink: true, no_intraemphasis: true, fenced_code_blocks: true, gh_blockcode: true, tables: true}, renderer_options: {with_toc_data: true}
filter :normalize_links, item[:repo_docs] if item[:repo_docs] filter :normalize_links, item[:repo_docs] if item[:repo_docs]
filter :outdated_content, item[:repo_docs] if item[:repo_docs] && item[:repo_docs][:outdated]
filter :add_anchors filter :add_anchors
filter :bootstrappify filter :bootstrappify
filter :admonition filter :admonition
......
# encoding: utf-8
require 'nokogiri'
class OutdatedContent < ::Nanoc::Filter
identifier :outdated_content
def run(content, params = {})
doc = Nokogiri::HTML(content)
# TODO(ts): We need to link to the same page or the first child without hardcoding /getting_started/.
warning = %(<p>CAUTION: This page documents an old version of Prometheus.
Check out the <a href="#{params[:outdated]}getting_started/">latest version</a>.</p>)
body = doc.css('body')
if first = body.children.first
first.add_previous_sibling(warning)
else
body << Nokogiri::HTML::DocumentFragment.parse(warning)
end
doc.to_s
end
end
...@@ -82,6 +82,7 @@ data_sources: ...@@ -82,6 +82,7 @@ data_sources:
name: '1.8' name: '1.8'
repository: https://github.com/prometheus/prometheus.git repository: https://github.com/prometheus/prometheus.git
refspec: release-1.8 refspec: release-1.8
outdated: /docs/prometheus/latest/
- -
type: static type: static
items_root: /assets/ items_root: /assets/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment