Skip to content

Commit 7f5e1cf

Browse files
authored
Merge pull request OAI#4403 from ralfhandl/main-move-up-google-analytics
Repair Google Tag Manager
2 parents 2800909 + 9f91e54 commit 7f5e1cf

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

scripts/md2html/build.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ for specification in $specifications; do
5252

5353
minorVersion=${version:0:3}
5454
tempfile="$deploydir/temp/$version.html"
55+
tempfile2="$deploydir/temp/$version-2.html"
5556

5657
echo === Building $version to $destination
5758

5859
node scripts/md2html/md2html.js --maintainers $maintainers $specification "$allVersions" > $tempfile
59-
npx respec --no-sandbox --use-local --src $tempfile --out $destination
60-
rm $tempfile
60+
npx respec --no-sandbox --use-local --src $tempfile --out $tempfile2
61+
# remove unwanted Google Tag Manager and Google Analytics scripts
62+
sed -e 's/<script type="text\/javascript" async="" src="https:\/\/www.google-analytics.com\/analytics.js"><\/script>//' \
63+
-e 's/<script type="text\/javascript" async="" src="https:\/\/www.googletagmanager.com\/gtag\/js?id=G-[^"]*"><\/script>//' \
64+
$tempfile2 > $destination
6165

6266
echo === Built $destination
6367

@@ -79,6 +83,5 @@ if [ "$latestCopied" != "none" ]; then
7983
echo Latest tag is $latest, copied $latestCopied to latest.html
8084
fi
8185

82-
rm $deploydir/js/respec-w3c.*
83-
rmdir $deploydir/js
84-
rmdir $deploydir/temp
86+
rm -r $deploydir/js
87+
rm -r $deploydir/temp

scripts/md2html/md2html.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,18 @@ function preface(title,options) {
132132
// }
133133
};
134134

135-
let preface = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>${md.utils.escapeHtml(title)}</title>`;
135+
let preface = '<!DOCTYPE html><html lang="en"><head>\n'
136+
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
136137

137138
// SEO
138-
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">';
139+
preface += `<meta charset="UTF-8">\n<title>${md.utils.escapeHtml(title)}</title>`;
140+
preface += '<meta name="description" content="The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.">\n';
139141

140142
// ReSpec
141143
preface += '<meta name="color-scheme" content="light dark">';
142144
preface += '<script src="../js/respec-w3c.js" class="remove"></script>';
143-
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>`;
144-
preface += fs.readFileSync(path.resolve(__dirname,'./analytics/google.html'),'utf8');
145-
preface += '</head><body>';
145+
preface += `<script class="remove">var respecConfig = ${JSON.stringify(respec)};</script>\n`;
146+
preface += '</head>\n<body>';
146147
preface += '<style>';
147148
preface += fs.readFileSync(path.resolve(__dirname,'main.css'),'utf8').split(/\r?\n/).join(' ');
148149
preface += fs.readFileSync(path.resolve(__dirname,'gist.css'),'utf8').split(/\r?\n/).join(' ');

0 commit comments

Comments
 (0)