Commit 6c0473ef authored by Robert Speicher's avatar Robert Speicher

Merge branch 'hide-frontmatter-help-page' into 'master'

Do not show YAML frontmatter for doc pages under /help

See merge request gitlab-org/gitlab-ce!14345
parents 3ce36140 52ddf8e6
...@@ -3,8 +3,13 @@ class HelpController < ApplicationController ...@@ -3,8 +3,13 @@ class HelpController < ApplicationController
layout 'help' layout 'help'
# Taken from Jekyll
# https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13
YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
def index def index
@help_index = File.read(Rails.root.join('doc', 'README.md')) # Remove YAML frontmatter so that it doesn't look weird
@help_index = File.read(Rails.root.join('doc', 'README.md')).sub(YAML_FRONT_MATTER_REGEXP, '')
# Prefix Markdown links with `help/` unless they are external links # Prefix Markdown links with `help/` unless they are external links
# See http://rubular.com/r/X3baHTbPO2 # See http://rubular.com/r/X3baHTbPO2
...@@ -22,7 +27,8 @@ class HelpController < ApplicationController ...@@ -22,7 +27,8 @@ class HelpController < ApplicationController
path = File.join(Rails.root, 'doc', "#{@path}.md") path = File.join(Rails.root, 'doc', "#{@path}.md")
if File.exist?(path) if File.exist?(path)
@markdown = File.read(path) # Remove YAML frontmatter so that it doesn't look weird
@markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '')
render 'show.html.haml' render 'show.html.haml'
else else
......
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