From 62520d1d3869f236b1b807336c2efb3ef13abf7b Mon Sep 17 00:00:00 2001 From: Barb Paduch Date: Tue, 30 May 2017 08:53:05 -0400 Subject: [PATCH] Add functionality to import CORS guide --- .gitignore | 1 + gulpfile.js | 1 + scripts/import_docs.js | 11 +++++++---- scripts/import_docs.json | 9 ++++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2b84217d22a..494021172be 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ content/learn/design-principles.md content/docs/reference/spec.md content/docs/reference/spec/*.md content/docs/reference/components/**/*.md +content/docs/guides/amp-core-requests.md diff --git a/gulpfile.js b/gulpfile.js index 3236c7347a2..08c22184f3a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -32,6 +32,7 @@ gulp.task('import-docs', function (cb) { if (err instanceof Error) { cb(err); } + //console.log(stdout); cb(); }); }); diff --git a/scripts/import_docs.js b/scripts/import_docs.js index 068b8f2ad7c..9afa730179d 100755 --- a/scripts/import_docs.js +++ b/scripts/import_docs.js @@ -67,10 +67,11 @@ function getDependencies(content) { // remove inline code .replace(/`[^`]+`/g, '') // find all used amp tags in the page - .match(/\s]+)[^>]*>/g); + .match(/])[^>\s]+)[^>]*>/g); + console.log("Dependencies: " + dependencies); if (dependencies) { - return Array.from(new Set(dependencies.map(item => item.match(/\s]+)[^>]*>/)[1]))); + return Array.from(new Set(dependencies.map(item => item.match(/])[^>\s]+)[^>]*>/)[1]))); } return null; @@ -80,12 +81,13 @@ function getDependencies(content) { function savePage(config, callback) { var optionalTOC = config.content.indexOf('[TOC]') > -1 ? 'toc: true\n' : ''; + var optionalCategory = (config.category ? "\n$category: " + config.category : ''); var optionalDependencies = getDependencies(config.content); optionalDependencies = optionalDependencies ? '\ncomponents:\n' + ' - ' + optionalDependencies.join('\n - ') + '\n' : ''; var frontMatter = `--- $title: "${config.title}" -$order: ${config.order || 0} +$order: ${config.order || 0}${optionalCategory} ${optionalTOC}${optionalDependencies}--- `; @@ -139,7 +141,8 @@ importData.forEach((item) => { destination: '../content/' + item.to, content: (item.toc ? '[TOC]\n' : '') + pageContent, title: item.title, - order: item.order + order: item.order, + category: (item.category ? item.category : '') }, function (err) { if (err) throw err; console.log('Successfully imported: ' + item.title); diff --git a/scripts/import_docs.json b/scripts/import_docs.json index 1e6bf04c0b3..1b86d33bf2c 100644 --- a/scripts/import_docs.json +++ b/scripts/import_docs.json @@ -23,5 +23,12 @@ "order": 3, "from": "spec/amp-boilerplate.md", "to": "docs/reference/spec/amp-boilerplate.md" + }, + { + "title": "CORS in AMP", + "order": 10, + "from": "spec/amp-cors-requests.md", + "to": "docs/guides/amp-cors-requests.md", + "category": "Deploy" } -] \ No newline at end of file +]