From f978782b019737162ca567021c027d246151b4aa Mon Sep 17 00:00:00 2001 From: Crphang Date: Sat, 13 Jul 2019 17:02:38 +0800 Subject: [PATCH 1/4] Add google analytics plugin --- src/plugins/googleAnalytics.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/plugins/googleAnalytics.js diff --git a/src/plugins/googleAnalytics.js b/src/plugins/googleAnalytics.js new file mode 100644 index 0000000000..8f1bd5094d --- /dev/null +++ b/src/plugins/googleAnalytics.js @@ -0,0 +1,17 @@ +function getGoogleAnalyticsTrackingCode(pluginContext) { + return ` + + + `; +} + +module.exports = { + // eslint-disable-next-line no-unused-vars + getScripts: (content, pluginContext, frontMatter, utils) => getGoogleAnalyticsTrackingCode(pluginContext), +}; From d0b0a2faab3a0446c31e409db3fa522f4f5ba5fb Mon Sep 17 00:00:00 2001 From: Crphang Date: Sun, 14 Jul 2019 18:32:45 +0800 Subject: [PATCH 2/4] Add functional test to google analytics plugin --- .../test_site/expected/bugs/index.html | 13 +++++++++++++ test/functional/test_site/expected/index.html | 13 +++++++++++++ .../test_site/expected/sub_site/index.html | 13 +++++++++++++ .../test_site/expected/testAfterSetup.html | 13 +++++++++++++ .../expected/testAnchorGeneration.html | 13 +++++++++++++ .../test_site/expected/testAntiFOUCStyles.html | 13 +++++++++++++ .../expected/testEmptyFrontmatter.html | 13 +++++++++++++ .../expected/testExternalScripts.html | 13 +++++++++++++ .../test_site/expected/testLayouts.html | 13 +++++++++++++ .../expected/testLayoutsOverride.html | 13 +++++++++++++ .../test_site/expected/testPlantUML.html | 13 +++++++++++++ .../test_site/expected/testThumbnails.html | 13 +++++++++++++ .../test_site/expected/testTooltipSpacing.html | 13 +++++++++++++ .../test_site/expected/test_md_fragment.html | 13 +++++++++++++ test/functional/test_site/site.json | 6 +++++- .../test_site/testGoogleAnalytics.md | 18 ++++++++++++++++++ 16 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 test/functional/test_site/testGoogleAnalytics.md diff --git a/test/functional/test_site/expected/bugs/index.html b/test/functional/test_site/expected/bugs/index.html index abdccb135d..c8f0ceb0ba 100644 --- a/test/functional/test_site/expected/bugs/index.html +++ b/test/functional/test_site/expected/bugs/index.html @@ -107,6 +107,19 @@