Skip to content

Commit

Permalink
Get spec page redirects from spec pages (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin authored Jun 21, 2022
1 parent a5cdaab commit 615d79f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 0 additions & 3 deletions layouts/index.redirects
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@
/docs/{{ $lang }} /docs/instrumentation/{{ $lang }}
/docs/{{ $lang }}/* /docs/instrumentation/{{ $lang }}/:splat
{{ end -}}

/docs/reference/specification/common/common /docs/reference/specification/common
/docs/reference/specification/context/context /docs/reference/specification/context
16 changes: 13 additions & 3 deletions scripts/adjust-spec-pages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use diagnostics;

my $file = '';
my $frontMatterFromFile = '';
my $title = '';
my $linkTitle = '';
my $gD = 0;
Expand All @@ -24,7 +25,7 @@
github_project_repo: *repo
EOS

sub printTitle() {
sub printTitleAndFrontMatter() {
print "---\n";
my $titleMaybeQuoted = ($title =~ ':') ? "\"$title\"" : $title;
print "title: $titleMaybeQuoted\n";
Expand All @@ -39,6 +40,7 @@ ()
print " from: $path_base_for_github_subdir/$1_index.md\n";
print " to: $1README.md\n";
}
print "$frontMatterFromFile" if $frontMatterFromFile;
print "---\n";
}

Expand All @@ -48,12 +50,20 @@ ()
# printf STDOUT "$ARGV Got: $_" if $gD;

if ($file ne $ARGV) {
$title = '';
$file = $ARGV;
$frontMatterFromFile = '';
$title = '';
if (/^<!---?/) {
while(<>) {
last if /^-?-->/;
$frontMatterFromFile .= $_;
}
next;
}
}
if(! $title) {
($title) = /^#\s+(.*)/;
printTitle() if $title;
printTitleAndFrontMatter() if $title;
next;
}

Expand Down

0 comments on commit 615d79f

Please sign in to comment.