├── .firebaserc ├── .gitignore ├── README.md ├── angular.json ├── config.xml ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── firebase.json ├── functions ├── lib │ ├── index.js │ └── index.js.map ├── package-lock.json ├── package.json ├── src │ ├── index.ts │ └── renderer.ts ├── tsconfig.json └── tslint.json ├── ionic.config.json ├── package-lock.json ├── package.json ├── resources ├── README.md ├── android │ ├── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png │ └── splash │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png ├── icon.png ├── ios │ ├── icon │ │ ├── icon-1024.png │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-40@3x.png │ │ ├── icon-50.png │ │ ├── icon-50@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon-83.5@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ ├── icon-small@3x.png │ │ ├── icon.png │ │ └── icon@2x.png │ └── splash │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape@2x~ipad.png │ │ ├── Default-Landscape@~ipadpro.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait@2x~ipad.png │ │ ├── Default-Portrait@~ipadpro.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default@2x~iphone.png │ │ ├── Default@2x~universal~anyany.png │ │ └── Default~iphone.png └── splash.png ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── dolphin │ │ ├── dolphin.module.ts │ │ ├── dolphin.page.html │ │ ├── dolphin.page.scss │ │ ├── dolphin.page.spec.ts │ │ └── dolphin.page.ts │ ├── eagle │ │ ├── eagle.module.ts │ │ ├── eagle.page.html │ │ ├── eagle.page.scss │ │ ├── eagle.page.spec.ts │ │ └── eagle.page.ts │ ├── hippo │ │ ├── hippo.module.ts │ │ ├── hippo.page.html │ │ ├── hippo.page.scss │ │ ├── hippo.page.spec.ts │ │ └── hippo.page.ts │ ├── home │ │ ├── home.module.ts │ │ ├── home.page.html │ │ ├── home.page.scss │ │ ├── home.page.spec.ts │ │ └── home.page.ts │ ├── seo.service.spec.ts │ └── seo.service.ts ├── assets │ └── icon │ │ └── favicon.png ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── global.scss ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── test.ts ├── theme │ └── variables.scss ├── tsconfig.app.json └── tsconfig.spec.json ├── tsconfig.json └── tslint.json /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": { 3 | "default": "angularfirebase-267db" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | .firebase 4 | functions/node_modules 5 | functions/lib 6 | *~ 7 | *.sw[mnpcod] 8 | *.log 9 | *.tmp 10 | *.tmp.* 11 | log.txt 12 | *.sublime-project 13 | *.sublime-workspace 14 | .vscode/ 15 | npm-debug.log* 16 | 17 | .idea/ 18 | .ionic/ 19 | .sourcemaps/ 20 | .sass-cache/ 21 | .tmp/ 22 | .versions/ 23 | coverage/ 24 | www/ 25 | node_modules/ 26 | tmp/ 27 | temp/ 28 | platforms/ 29 | plugins/ 30 | plugins/android.json 31 | plugins/ios.json 32 | $RECYCLE.BIN/ 33 | 34 | .DS_Store 35 | Thumbs.db 36 | UserInterfaceState.xcuserstate 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Puppeteer on Firebase Cloud Functions 2 | 3 | Use Puppeteer for serverside rendering on Firebase Cloud Functions to make any JavaScript app SEO and linkbot friendly. 4 | 5 | - Frontend: Ionic 4 6 | - Backend: Cloud Functions (Node 8) 7 | 8 | Watch the [screencaset](https://angularfirebase.com/tag/ssr/) 9 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "projects": { 6 | "app": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "progress": false, 17 | "outputPath": "www", 18 | "index": "src/index.html", 19 | "main": "src/main.ts", 20 | "polyfills": "src/polyfills.ts", 21 | "tsConfig": "src/tsconfig.app.json", 22 | "assets": [ 23 | { 24 | "glob": "**/*", 25 | "input": "src/assets", 26 | "output": "assets" 27 | }, 28 | { 29 | "glob": "**/*.svg", 30 | "input": "node_modules/@ionic/angular/dist/ionic/svg", 31 | "output": "./svg" 32 | } 33 | ], 34 | "styles": [ 35 | { 36 | "input": "src/theme/variables.scss" 37 | }, 38 | { 39 | "input": "src/global.scss" 40 | } 41 | ], 42 | "scripts": [] 43 | }, 44 | "configurations": { 45 | "production": { 46 | "fileReplacements": [ 47 | { 48 | "replace": "src/environments/environment.ts", 49 | "with": "src/environments/environment.prod.ts" 50 | } 51 | ], 52 | "optimization": true, 53 | "outputHashing": "all", 54 | "sourceMap": false, 55 | "extractCss": true, 56 | "namedChunks": false, 57 | "aot": true, 58 | "extractLicenses": true, 59 | "vendorChunk": false, 60 | "buildOptimizer": true 61 | } 62 | } 63 | }, 64 | "serve": { 65 | "builder": "@angular-devkit/build-angular:dev-server", 66 | "options": { 67 | "browserTarget": "app:build" 68 | }, 69 | "configurations": { 70 | "production": { 71 | "browserTarget": "app:build:production" 72 | } 73 | } 74 | }, 75 | "extract-i18n": { 76 | "builder": "@angular-devkit/build-angular:extract-i18n", 77 | "options": { 78 | "browserTarget": "app:build" 79 | } 80 | }, 81 | "test": { 82 | "builder": "@angular-devkit/build-angular:karma", 83 | "options": { 84 | "main": "src/test.ts", 85 | "polyfills": "src/polyfills.ts", 86 | "tsConfig": "src/tsconfig.spec.json", 87 | "karmaConfig": "src/karma.conf.js", 88 | "styles": [ 89 | "styles.css" 90 | ], 91 | "scripts": [], 92 | "assets": [ 93 | { 94 | "glob": "favicon.ico", 95 | "input": "src/", 96 | "output": "/" 97 | }, 98 | { 99 | "glob": "**/*", 100 | "input": "src/assets", 101 | "output": "/assets" 102 | } 103 | ] 104 | } 105 | }, 106 | "lint": { 107 | "builder": "@angular-devkit/build-angular:tslint", 108 | "options": { 109 | "tsConfig": [ 110 | "src/tsconfig.app.json", 111 | "src/tsconfig.spec.json" 112 | ], 113 | "exclude": [ 114 | "**/node_modules/**" 115 | ] 116 | } 117 | }, 118 | "ionic-cordova-build": { 119 | "builder": "@ionic/ng-toolkit:cordova-build", 120 | "options": { 121 | "browserTarget": "app:build" 122 | }, 123 | "configurations": { 124 | "production": { 125 | "browserTarget": "app:build:production" 126 | } 127 | } 128 | }, 129 | "ionic-cordova-serve": { 130 | "builder": "@ionic/ng-toolkit:cordova-serve", 131 | "options": { 132 | "cordovaBuildTarget": "app:ionic-cordova-build", 133 | "devServerTarget": "app:serve" 134 | }, 135 | "configurations": { 136 | "production": { 137 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 138 | "devServerTarget": "app:serve:production" 139 | } 140 | } 141 | } 142 | } 143 | }, 144 | "app-e2e": { 145 | "root": "e2e/", 146 | "projectType": "application", 147 | "architect": { 148 | "e2e": { 149 | "builder": "@angular-devkit/build-angular:protractor", 150 | "options": { 151 | "protractorConfig": "e2e/protractor.conf.js", 152 | "devServerTarget": "app:serve" 153 | } 154 | }, 155 | "lint": { 156 | "builder": "@angular-devkit/build-angular:tslint", 157 | "options": { 158 | "tsConfig": "e2e/tsconfig.e2e.json", 159 | "exclude": [ 160 | "**/node_modules/**" 161 | ] 162 | } 163 | } 164 | } 165 | } 166 | }, 167 | "cli": { 168 | "defaultCollection": "@ionic/schematics-angular" 169 | }, 170 | "schematics": { 171 | "@ionic/schematics-angular:component": { 172 | "styleext": "scss" 173 | }, 174 | "@ionic/schematics-angular:page": { 175 | "styleext": "scss" 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ionSSR 4 | An awesome Ionic/Cordova app. 5 | Ionic Framework Team 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: 'e2e/tsconfig.e2e.json' 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('new App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toContain('The world is your oyster.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.deepCss('app-root ion-content')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/e2e", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "target": "es5" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": { 3 | "predeploy": [ 4 | "npm --prefix \"$RESOURCE_DIR\" run build" 5 | ] 6 | }, 7 | "hosting": { 8 | "public": "www", 9 | "ignore": [ 10 | "firebase.json", 11 | "**/.*", 12 | "**/node_modules/**" 13 | ], 14 | "rewrites": [{ 15 | "source": "**", 16 | "function": "ssr" 17 | }] 18 | } 19 | } -------------------------------------------------------------------------------- /functions/lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | return new (P || (P = Promise))(function (resolve, reject) { 4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 7 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 8 | }); 9 | }; 10 | Object.defineProperty(exports, "__esModule", { value: true }); 11 | const functions = require("firebase-functions"); 12 | const puppeteer = require("puppeteer"); 13 | const renderer_1 = require("./renderer"); 14 | const fetch = require("node-fetch"); 15 | const appURL = 'https://angularfirebase-267db.firebaseapp.com'; 16 | const renderURL = 'https://us-central1-angularfirebase-267db.cloudfunctions.net/render'; 17 | exports.render = functions 18 | .runWith({ memory: '1GB' }) 19 | .https.onRequest((request, response) => __awaiter(this, void 0, void 0, function* () { 20 | const browser = yield puppeteer.launch({ 21 | headless: true, 22 | args: ['--no-sandbox', '--disable-setuid-sandbox'] 23 | }); 24 | const requestURL = request.query.requestURL; 25 | const page = yield browser.newPage(); 26 | const { status, content } = yield renderer_1.serialize(page, requestURL, false); 27 | console.log(content); 28 | response.status(status).send(content); 29 | })); 30 | exports.ssr = functions.https.onRequest((request, response) => __awaiter(this, void 0, void 0, function* () { 31 | const bots = [ 32 | 'twitterbot', 33 | 'facebookexternalhit', 34 | 'linkedinbot', 35 | 'pinterest', 36 | 'slackbot' 37 | ]; 38 | const userAgent = request.headers['user-agent']; 39 | const isBot = bots.filter(bot => userAgent.toLowerCase().includes(bot)) 40 | .length; 41 | console.log(isBot, userAgent); 42 | const requestURL = appURL + request.url; 43 | console.log(requestURL); 44 | if (isBot) { 45 | const html = yield fetch(`${renderURL}?requestURL=${requestURL}`); 46 | const body = yield html.text(); 47 | response.send(body.toString()); 48 | } 49 | else { 50 | const html = yield fetch('https://angularfirebase-267db.firebaseapp.com'); 51 | const body = yield html.text(); 52 | response.send(body.toString()); 53 | } 54 | })); 55 | // export const ssr = functions 56 | // .runWith({ memory: '1GB' }) 57 | // .https.onRequest(async (request, response) => { 58 | // const page = await browser.newPage(); 59 | // await page.goto('https://angularfirebase-267db.firebaseapp.com/eagle', { 60 | // waitUntil: 'networkidle0' 61 | // }); 62 | // const content = await page.content(); 63 | // response.send(content); 64 | // const { requestURL, isMobile } = request.query; 65 | // console.log('url', requestURL); 66 | // }); 67 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /functions/lib/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,gDAAgD;AAEhD,uCAAuC;AACvC,yCAAuC;AACvC,oCAAoC;AAEpC,MAAM,MAAM,GAAG,+CAA+C,CAAC;AAC/D,MAAM,SAAS,GACb,qEAAqE,CAAC;AAE3D,QAAA,MAAM,GAAG,SAAS;KAC5B,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;KAC1B,KAAK,CAAC,SAAS,CAAC,CAAO,OAAO,EAAE,QAAQ,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC;QACrC,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,CAAC,cAAc,EAAE,0BAA0B,CAAC;KACnD,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC;IAE5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,oBAAS,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAErE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAA,CAAC,CAAC;AAEQ,QAAA,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAO,OAAO,EAAE,QAAQ,EAAE,EAAE;IACvE,MAAM,IAAI,GAAG;QACX,YAAY;QACZ,qBAAqB;QACrB,aAAa;QACb,WAAW;QACX,UAAU;KACX,CAAC;IAEF,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAW,CAAC;IAE1D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;SACpE,MAAM,CAAC;IAEV,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAE9B,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAExB,IAAI,KAAK,EAAE;QACT,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,eAAe,UAAU,EAAE,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChC;SAAM;QACL,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC1E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAE/B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;KAChC;AACH,CAAC,CAAA,CAAC,CAAC;AAEH,+BAA+B;AAC/B,8BAA8B;AAC9B,kDAAkD;AAClD,wCAAwC;AAExC,2EAA2E;AAC3E,8BAA8B;AAC9B,MAAM;AAEN,wCAAwC;AAExC,0BAA0B;AAE1B,kDAAkD;AAElD,kCAAkC;AAElC,MAAM"} -------------------------------------------------------------------------------- /functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "scripts": { 4 | "lint": "tslint --project tsconfig.json", 5 | "build": "tsc", 6 | "serve": "npm run build && firebase serve --only functions", 7 | "shell": "npm run build && firebase functions:shell", 8 | "start": "npm run shell", 9 | "deploy": "firebase deploy --only functions", 10 | "logs": "firebase functions:log" 11 | }, 12 | "main": "lib/index.js", 13 | "dependencies": { 14 | "firebase-admin": "~6.0.0", 15 | "firebase-functions": "^2.0.5", 16 | "node-fetch": "^2.2.0", 17 | "puppeteer": "^1.7.0" 18 | }, 19 | "devDependencies": { 20 | "@types/puppeteer": "^1.6.0", 21 | "tslint": "~5.8.0", 22 | "typescript": "~2.8.3" 23 | }, 24 | "engines": { 25 | "node": "8" 26 | }, 27 | "private": true 28 | } 29 | -------------------------------------------------------------------------------- /functions/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as functions from 'firebase-functions'; 2 | 3 | import * as puppeteer from 'puppeteer'; 4 | import { serialize } from './renderer'; 5 | import * as fetch from 'node-fetch'; 6 | 7 | const appURL = 'https://angularfirebase-267db.firebaseapp.com'; 8 | const renderURL = 9 | 'https://us-central1-angularfirebase-267db.cloudfunctions.net/render'; 10 | 11 | export const render = functions 12 | .runWith({ memory: '1GB' }) 13 | .https.onRequest(async (request, response) => { 14 | const browser = await puppeteer.launch({ 15 | headless: true, 16 | args: ['--no-sandbox', '--disable-setuid-sandbox'] 17 | }); 18 | 19 | const requestURL = request.query.requestURL; 20 | 21 | const page = await browser.newPage(); 22 | const { status, content } = await serialize(page, requestURL, false); 23 | 24 | response.status(status).send(content); 25 | }); 26 | 27 | export const ssr = functions.https.onRequest(async (request, response) => { 28 | const bots = [ 29 | 'twitterbot', 30 | 'facebookexternalhit', 31 | 'linkedinbot', 32 | 'pinterest', 33 | 'slackbot' 34 | ]; 35 | 36 | const userAgent = request.headers['user-agent'] as string; 37 | 38 | const isBot = bots.filter(bot => userAgent.toLowerCase().includes(bot)) 39 | .length; 40 | 41 | const requestURL = appURL + request.url; 42 | 43 | if (isBot) { 44 | const html = await fetch(`${renderURL}?requestURL=${requestURL}`); 45 | const body = await html.text(); 46 | response.send(body.toString()); 47 | } else { 48 | const html = await fetch(appURL); 49 | const body = await html.text(); 50 | 51 | response.send(body.toString()); 52 | } 53 | }); 54 | 55 | // export const ssr = functions 56 | // .runWith({ memory: '1GB' }) 57 | // .https.onRequest(async (request, response) => { 58 | // const page = await browser.newPage(); 59 | 60 | // await page.goto('https://angularfirebase-267db.firebaseapp.com/eagle', { 61 | // waitUntil: 'networkidle0' 62 | // }); 63 | 64 | // const content = await page.content(); 65 | 66 | // response.send(content); 67 | 68 | // const { requestURL, isMobile } = request.query; 69 | 70 | // console.log('url', requestURL); 71 | 72 | // }); 73 | -------------------------------------------------------------------------------- /functions/src/renderer.ts: -------------------------------------------------------------------------------- 1 | import * as puppeteer from 'puppeteer'; 2 | import * as url from 'url'; 3 | 4 | // Based on RENDERTRON 5 | // https://github.com/GoogleChrome/rendertron/blob/master/src/renderer.ts 6 | 7 | const MOBILE_USERAGENT = 8 | 'Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Mobile Safari/537.36'; 9 | 10 | export async function serialize( 11 | page: puppeteer.Page, 12 | requestUrl: string, 13 | isMobile: boolean 14 | ) { 15 | /** 16 | * Executed on the page after the page has loaded. Strips script and 17 | * import tags to prevent further loading of resources. 18 | */ 19 | function stripPage() { 20 | const elements = document.querySelectorAll('script, link[rel=import]'); 21 | 22 | for (const e of Array.from(elements)) { 23 | e.remove(); 24 | } 25 | } 26 | 27 | /** 28 | * Injects a tag which allows other resources to load. This 29 | * has no effect on serialised output, but allows it to verify render 30 | * quality. 31 | */ 32 | function injectBaseHref(origin: string) { 33 | const base = document.createElement('base'); 34 | base.setAttribute('href', origin); 35 | 36 | const bases = document.head.querySelectorAll('base'); 37 | if (bases.length) { 38 | // Patch existing if it is relative. 39 | const existingBase = bases[0].getAttribute('href') || ''; 40 | if (existingBase.startsWith('./')) { 41 | bases[0].setAttribute('href', origin + existingBase); 42 | } 43 | } else { 44 | // Only inject if it doesn't already exist. 45 | document.head.insertAdjacentElement('afterbegin', base); 46 | } 47 | } 48 | 49 | page.setViewport({ width: 1000, height: 1000, isMobile }); 50 | 51 | if (isMobile) { 52 | page.setUserAgent(MOBILE_USERAGENT); 53 | } 54 | 55 | page.evaluateOnNewDocument('customElements.forcePolyfill = true'); 56 | page.evaluateOnNewDocument('ShadyDOM = {force: true}'); 57 | page.evaluateOnNewDocument('ShadyCSS = {shimcssproperties: true}'); 58 | 59 | let response: puppeteer.Response | null = null; 60 | // Capture main frame response. This is used in the case that rendering 61 | // times out, which results in puppeteer throwing an error. This allows us 62 | // to return a partial response for what was able to be rendered in that 63 | // time frame. 64 | page.addListener('response', (r: puppeteer.Response) => { 65 | if (!response) { 66 | response = r; 67 | } 68 | }); 69 | 70 | try { 71 | // Navigate to page. Wait until there are no oustanding network requests. 72 | response = await page.goto(requestUrl, { 73 | timeout: 10000, 74 | waitUntil: 'networkidle2' 75 | }); 76 | } catch (e) { 77 | console.error(e); 78 | } 79 | 80 | if (!response) { 81 | console.error('response does not exist'); 82 | // This should only occur when the page is about:blank. See 83 | // https://github.com/GoogleChrome/puppeteer/blob/v1.5.0/docs/api.md#pagegotourl-options. 84 | return { status: 400, content: '' }; 85 | } 86 | 87 | // Set status to the initial server's response code. Check for a tag which overrides the status 89 | // code. 90 | let statusCode = response.status(); 91 | const newStatusCode = await page 92 | .$eval('meta[name="render:status_code"]', element => 93 | parseInt(element.getAttribute('content') || '') 94 | ) 95 | .catch(() => undefined); 96 | // On a repeat visit to the same origin, browser cache is enabled, so we may 97 | // encounter a 304 Not Modified. Instead we'll treat this as a 200 OK. 98 | if (statusCode === 304) { 99 | statusCode = 200; 100 | } 101 | // Original status codes which aren't 200 always return with that status 102 | // code, regardless of meta tags. 103 | if (statusCode === 200 && newStatusCode) { 104 | statusCode = newStatusCode; 105 | } 106 | 107 | // Remove script & import tags. 108 | await page.evaluate(stripPage); 109 | 110 | // Inject tag with the origin of the request (ie. no path). 111 | const parsedUrl = url.parse(requestUrl); 112 | await page.evaluate( 113 | injectBaseHref, 114 | `${parsedUrl.protocol}//${parsedUrl.host}` 115 | ); 116 | 117 | // Serialize page. 118 | const result = await page.evaluate('document.firstElementChild.outerHTML'); 119 | 120 | await page.close(); 121 | return { status: statusCode, content: result }; 122 | } 123 | -------------------------------------------------------------------------------- /functions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": ["es7", "dom"], 4 | "module": "commonjs", 5 | "noImplicitReturns": true, 6 | "outDir": "lib", 7 | "sourceMap": true, 8 | "target": "es6" 9 | }, 10 | "compileOnSave": true, 11 | "include": ["src"] 12 | } 13 | -------------------------------------------------------------------------------- /functions/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | // -- Strict errors -- 4 | // These lint rules are likely always a good idea. 5 | 6 | // Force function overloads to be declared together. This ensures readers understand APIs. 7 | "adjacent-overload-signatures": true, 8 | 9 | // Do not allow the subtle/obscure comma operator. 10 | "ban-comma-operator": true, 11 | 12 | // Do not allow internal modules or namespaces . These are deprecated in favor of ES6 modules. 13 | "no-namespace": true, 14 | 15 | // Do not allow parameters to be reassigned. To avoid bugs, developers should instead assign new values to new vars. 16 | "no-parameter-reassignment": true, 17 | 18 | // Force the use of ES6-style imports instead of /// imports. 19 | "no-reference": true, 20 | 21 | // Do not allow type assertions that do nothing. This is a big warning that the developer may not understand the 22 | // code currently being edited (they may be incorrectly handling a different type case that does not exist). 23 | "no-unnecessary-type-assertion": true, 24 | 25 | // Disallow nonsensical label usage. 26 | "label-position": true, 27 | 28 | // Disallows the (often typo) syntax if (var1 = var2). Replace with if (var2) { var1 = var2 }. 29 | "no-conditional-assignment": true, 30 | 31 | // Disallows constructors for primitive types (e.g. new Number('123'), though Number('123') is still allowed). 32 | "no-construct": true, 33 | 34 | // Do not allow super() to be called twice in a constructor. 35 | "no-duplicate-super": true, 36 | 37 | // Do not allow the same case to appear more than once in a switch block. 38 | "no-duplicate-switch-case": true, 39 | 40 | // Do not allow a variable to be declared more than once in the same block. Consider function parameters in this 41 | // rule. 42 | "no-duplicate-variable": [true, "check-parameters"], 43 | 44 | // Disallows a variable definition in an inner scope from shadowing a variable in an outer scope. Developers should 45 | // instead use a separate variable name. 46 | "no-shadowed-variable": true, 47 | 48 | // Empty blocks are almost never needed. Allow the one general exception: empty catch blocks. 49 | "no-empty": [true, "allow-empty-catch"], 50 | 51 | // Functions must either be handled directly (e.g. with a catch() handler) or returned to another function. 52 | // This is a major source of errors in Cloud Functions and the team strongly recommends leaving this rule on. 53 | "no-floating-promises": true, 54 | 55 | // Do not allow any imports for modules that are not in package.json. These will almost certainly fail when 56 | // deployed. 57 | "no-implicit-dependencies": true, 58 | 59 | // The 'this' keyword can only be used inside of classes. 60 | "no-invalid-this": true, 61 | 62 | // Do not allow strings to be thrown because they will not include stack traces. Throw Errors instead. 63 | "no-string-throw": true, 64 | 65 | // Disallow control flow statements, such as return, continue, break, and throw in finally blocks. 66 | "no-unsafe-finally": true, 67 | 68 | // Do not allow variables to be used before they are declared. 69 | "no-use-before-declare": true, 70 | 71 | // Expressions must always return a value. Avoids common errors like const myValue = functionReturningVoid(); 72 | "no-void-expression": [true, "ignore-arrow-function-shorthand"], 73 | 74 | // Disallow duplicate imports in the same file. 75 | "no-duplicate-imports": true, 76 | 77 | 78 | // -- Strong Warnings -- 79 | // These rules should almost never be needed, but may be included due to legacy code. 80 | // They are left as a warning to avoid frustration with blocked deploys when the developer 81 | // understand the warning and wants to deploy anyway. 82 | 83 | // Warn when an empty interface is defined. These are generally not useful. 84 | "no-empty-interface": {"severity": "warning"}, 85 | 86 | // Warn when an import will have side effects. 87 | "no-import-side-effect": {"severity": "warning"}, 88 | 89 | // Warn when variables are defined with var. Var has subtle meaning that can lead to bugs. Strongly prefer const for 90 | // most values and let for values that will change. 91 | "no-var-keyword": {"severity": "warning"}, 92 | 93 | // Prefer === and !== over == and !=. The latter operators support overloads that are often accidental. 94 | "triple-equals": {"severity": "warning"}, 95 | 96 | // Warn when using deprecated APIs. 97 | "deprecation": {"severity": "warning"}, 98 | 99 | // -- Light Warnigns -- 100 | // These rules are intended to help developers use better style. Simpler code has fewer bugs. These would be "info" 101 | // if TSLint supported such a level. 102 | 103 | // prefer for( ... of ... ) to an index loop when the index is only used to fetch an object from an array. 104 | // (Even better: check out utils like .map if transforming an array!) 105 | "prefer-for-of": {"severity": "warning"}, 106 | 107 | // Warns if function overloads could be unified into a single function with optional or rest parameters. 108 | "unified-signatures": {"severity": "warning"}, 109 | 110 | // Warns if code has an import or variable that is unused. 111 | "no-unused-variable": {"severity": "warning"}, 112 | 113 | // Prefer const for values that will not change. This better documents code. 114 | "prefer-const": {"severity": "warning"}, 115 | 116 | // Multi-line object liiterals and function calls should have a trailing comma. This helps avoid merge conflicts. 117 | "trailing-comma": {"severity": "warning"} 118 | }, 119 | 120 | "defaultSeverity": "error" 121 | } 122 | -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionSSR", 3 | "integrations": { 4 | "cordova": {} 5 | }, 6 | "type": "angular" 7 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ionSSR", 3 | "version": "0.0.1", 4 | "author": "Ionic Framework", 5 | "homepage": "http://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/common": "~6.1.1", 17 | "@angular/core": "~6.1.1", 18 | "@angular/forms": "~6.1.1", 19 | "@angular/http": "~6.1.1", 20 | "@angular/platform-browser": "~6.1.1", 21 | "@angular/platform-browser-dynamic": "~6.1.1", 22 | "@angular/router": "~6.1.1", 23 | "@ionic-native/core": "5.0.0-beta.14", 24 | "@ionic-native/splash-screen": "5.0.0-beta.14", 25 | "@ionic-native/status-bar": "5.0.0-beta.14", 26 | "@ionic/angular": "^4.0.0-beta.0", 27 | "core-js": "^2.5.3", 28 | "rxjs": "6.2.2", 29 | "zone.js": "^0.8.26" 30 | }, 31 | "devDependencies": { 32 | "@angular/cli": "~6.1.1", 33 | "@angular/compiler": "~6.1.1", 34 | "@angular/compiler-cli": "~6.1.1", 35 | "@angular/language-service": "~6.1.1", 36 | "@angular-devkit/architect": "~0.7.2", 37 | "@angular-devkit/build-angular": "~0.7.2", 38 | "@angular-devkit/core": "~0.7.2", 39 | "@angular-devkit/schematics": "~0.7.2", 40 | "@ionic/ng-toolkit": "^1.0.0", 41 | "@ionic/schematics-angular": "^1.0.0", 42 | "@types/jasmine": "~2.8.6", 43 | "@types/jasminewd2": "~2.0.3", 44 | "@types/node": "~10.7.1", 45 | "codelyzer": "~4.4.2", 46 | "jasmine-core": "~2.99.1", 47 | "jasmine-spec-reporter": "~4.2.1", 48 | "karma": "~3.0.0", 49 | "karma-chrome-launcher": "~2.2.0", 50 | "karma-coverage-istanbul-reporter": "~2.0.0", 51 | "karma-jasmine": "~1.1.1", 52 | "karma-jasmine-html-reporter": "^0.2.2", 53 | "protractor": "~5.4.0", 54 | "ts-node": "~7.0.0", 55 | "tslint": "~5.11.0", 56 | "typescript": "~2.7.2" 57 | }, 58 | "description": "An Ionic project" 59 | } 60 | -------------------------------------------------------------------------------- /resources/README.md: -------------------------------------------------------------------------------- 1 | These are Cordova resources. You can replace icon.png and splash.png and run 2 | `ionic cordova resources` to generate custom icons and splash screens for your 3 | app. See `ionic cordova resources --help` for details. 4 | 5 | Cordova reference documentation: 6 | 7 | - Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html 8 | - Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ 9 | -------------------------------------------------------------------------------- /resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-1024.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~universal~anyany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default@2x~universal~anyany.png -------------------------------------------------------------------------------- /resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/resources/splash.png -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', redirectTo: 'home', pathMatch: 'full' }, 6 | { path: 'home', loadChildren: './home/home.module#HomePageModule' }, 7 | { path: 'dolphin', loadChildren: './dolphin/dolphin.module#DolphinPageModule' }, 8 | { path: 'eagle', loadChildren: './eagle/eagle.module#EaglePageModule' }, 9 | { path: 'hippo', loadChildren: './hippo/hippo.module#HippoPageModule' }, 10 | ]; 11 | 12 | @NgModule({ 13 | imports: [RouterModule.forRoot(routes)], 14 | exports: [RouterModule] 15 | }) 16 | export class AppRoutingModule { } 17 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, async } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(async(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html' 10 | }) 11 | export class AppComponent { 12 | constructor( 13 | private platform: Platform, 14 | private splashScreen: SplashScreen, 15 | private statusBar: StatusBar 16 | ) { 17 | this.initializeApp(); 18 | } 19 | 20 | initializeApp() { 21 | this.platform.ready().then(() => { 22 | this.statusBar.styleDefault(); 23 | this.splashScreen.hide(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router'; 4 | 5 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 6 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 7 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 8 | 9 | import { AppComponent } from './app.component'; 10 | import { AppRoutingModule } from './app-routing.module'; 11 | 12 | @NgModule({ 13 | declarations: [AppComponent], 14 | entryComponents: [], 15 | imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], 16 | providers: [ 17 | StatusBar, 18 | SplashScreen, 19 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 20 | ], 21 | bootstrap: [AppComponent] 22 | }) 23 | export class AppModule {} 24 | -------------------------------------------------------------------------------- /src/app/dolphin/dolphin.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { Routes, RouterModule } from '@angular/router'; 5 | 6 | import { IonicModule } from '@ionic/angular'; 7 | 8 | import { DolphinPage } from './dolphin.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: '', 13 | component: DolphinPage 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [ 19 | CommonModule, 20 | FormsModule, 21 | IonicModule, 22 | RouterModule.forChild(routes) 23 | ], 24 | declarations: [DolphinPage] 25 | }) 26 | export class DolphinPageModule {} 27 | -------------------------------------------------------------------------------- /src/app/dolphin/dolphin.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dolphin 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/app/dolphin/dolphin.page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/src/app/dolphin/dolphin.page.scss -------------------------------------------------------------------------------- /src/app/dolphin/dolphin.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { DolphinPage } from './dolphin.page'; 5 | 6 | describe('DolphinPage', () => { 7 | let component: DolphinPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ DolphinPage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(DolphinPage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/dolphin/dolphin.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { SeoService } from '../seo.service'; 3 | @Component({ 4 | selector: 'app-dolphin', 5 | templateUrl: './dolphin.page.html', 6 | styleUrls: ['./dolphin.page.scss'] 7 | }) 8 | export class DolphinPage implements OnInit { 9 | constructor(seo: SeoService) { 10 | seo.addTwitterCard( 11 | 'Dolphins are magical!', 12 | 'This is an Ionic Page about Dolphins and is SEO ready via Firebase Cloud Functions', 13 | 'https://upload.wikimedia.org/wikipedia/commons/2/2d/Dolphin-Musandam_2.jpg' 14 | ); 15 | } 16 | ngOnInit() {} 17 | } 18 | -------------------------------------------------------------------------------- /src/app/eagle/eagle.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { Routes, RouterModule } from '@angular/router'; 5 | 6 | import { IonicModule } from '@ionic/angular'; 7 | 8 | import { EaglePage } from './eagle.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: '', 13 | component: EaglePage 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [ 19 | CommonModule, 20 | FormsModule, 21 | IonicModule, 22 | RouterModule.forChild(routes) 23 | ], 24 | declarations: [EaglePage] 25 | }) 26 | export class EaglePageModule {} 27 | -------------------------------------------------------------------------------- /src/app/eagle/eagle.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | eagle 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/eagle/eagle.page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/src/app/eagle/eagle.page.scss -------------------------------------------------------------------------------- /src/app/eagle/eagle.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { EaglePage } from './eagle.page'; 5 | 6 | describe('EaglePage', () => { 7 | let component: EaglePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ EaglePage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(EaglePage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/eagle/eagle.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { SeoService } from '../seo.service'; 3 | @Component({ 4 | selector: 'app-eagle', 5 | templateUrl: './eagle.page.html', 6 | styleUrls: ['./eagle.page.scss'] 7 | }) 8 | export class EaglePage implements OnInit { 9 | constructor(seo: SeoService) { 10 | seo.addTwitterCard( 11 | 'Eagles soar!', 12 | 'This is an Ionic Page about Eagles and is SEO ready via Firebase Cloud Functions', 13 | 'https://upload.wikimedia.org/wikipedia/commons/1/17/Alaskan_Bald_Eagle_cruising_for_a_salmon_dinner.jpg' 14 | ); 15 | } 16 | ngOnInit() {} 17 | } 18 | -------------------------------------------------------------------------------- /src/app/hippo/hippo.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { FormsModule } from '@angular/forms'; 4 | import { Routes, RouterModule } from '@angular/router'; 5 | 6 | import { IonicModule } from '@ionic/angular'; 7 | 8 | import { HippoPage } from './hippo.page'; 9 | 10 | const routes: Routes = [ 11 | { 12 | path: '', 13 | component: HippoPage 14 | } 15 | ]; 16 | 17 | @NgModule({ 18 | imports: [ 19 | CommonModule, 20 | FormsModule, 21 | IonicModule, 22 | RouterModule.forChild(routes) 23 | ], 24 | declarations: [HippoPage] 25 | }) 26 | export class HippoPageModule {} 27 | -------------------------------------------------------------------------------- /src/app/hippo/hippo.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | hippo 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Go Home 12 | 13 | -------------------------------------------------------------------------------- /src/app/hippo/hippo.page.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/src/app/hippo/hippo.page.scss -------------------------------------------------------------------------------- /src/app/hippo/hippo.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { HippoPage } from './hippo.page'; 5 | 6 | describe('HippoPage', () => { 7 | let component: HippoPage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HippoPage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(HippoPage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/hippo/hippo.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { SeoService } from '../seo.service'; 3 | 4 | @Component({ 5 | selector: 'app-hippo', 6 | templateUrl: './hippo.page.html', 7 | styleUrls: ['./hippo.page.scss'] 8 | }) 9 | export class HippoPage implements OnInit { 10 | isServer = true; 11 | constructor(seo: SeoService) { 12 | seo.addTwitterCard( 13 | 'Hippos are rad!', 14 | 'This is an Ionic Page about hippos and is SEO ready via Firebase Cloud Functions', 15 | 'https://upload.wikimedia.org/wikipedia/commons/9/98/Hippo_at_dawn.jpg' 16 | ); 17 | } 18 | 19 | ngOnInit() {} 20 | } 21 | -------------------------------------------------------------------------------- /src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { HomePage } from './home.page'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CommonModule, 12 | FormsModule, 13 | IonicModule, 14 | RouterModule.forChild([ 15 | { 16 | path: '', 17 | component: HomePage 18 | } 19 | ]) 20 | ], 21 | declarations: [HomePage] 22 | }) 23 | export class HomePageModule {} 24 | -------------------------------------------------------------------------------- /src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Ionic Blank 5 | 6 | 7 | 8 | 9 | 10 | The world is your oyster. 11 |

If you get lost, the docs will be your guide.

12 | 13 | Hippo 14 | Eagle 15 | Dolphin 16 | 17 |
-------------------------------------------------------------------------------- /src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HomePage ], 13 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 14 | }) 15 | .compileComponents(); 16 | })); 17 | 18 | beforeEach(() => { 19 | fixture = TestBed.createComponent(HomePage); 20 | component = fixture.componentInstance; 21 | fixture.detectChanges(); 22 | }); 23 | 24 | it('should create', () => { 25 | expect(component).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-home', 5 | templateUrl: 'home.page.html', 6 | styleUrls: ['home.page.scss'], 7 | }) 8 | export class HomePage { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/app/seo.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, inject } from '@angular/core/testing'; 2 | 3 | import { SeoService } from './seo.service'; 4 | 5 | describe('SeoService', () => { 6 | beforeEach(() => { 7 | TestBed.configureTestingModule({ 8 | providers: [SeoService] 9 | }); 10 | }); 11 | 12 | it('should be created', inject([SeoService], (service: SeoService) => { 13 | expect(service).toBeTruthy(); 14 | })); 15 | }); 16 | -------------------------------------------------------------------------------- /src/app/seo.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Meta, Title } from '@angular/platform-browser'; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class SeoService { 8 | constructor(private title: Title, private meta: Meta) {} 9 | 10 | addTwitterCard(title, description, img) { 11 | // Set HTML Document Title 12 | this.title.setTitle(title); 13 | 14 | // Add Twitter Card Metatags 15 | this.meta.updateTag({ name: 'twitter:card', content: 'summary' }); 16 | this.meta.updateTag({ name: 'twitter:site', content: '@angularfirebase' }); 17 | this.meta.updateTag({ name: 'twitter:title', content: title }); 18 | this.meta.updateTag({ name: 'twitter:description', content: description }); 19 | this.meta.updateTag({ name: 'twitter:image', content: img }); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AngularFirebase/130-cloud-functions-puppeteer/94794d565f2d09c15d71b5bfea7f56cbe5261440/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // The file contents for the current environment will overwrite these during build. 2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do 3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead. 4 | // The list of which env maps to which file can be found in `.angular-cli.json`. 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * In development mode, to ignore zone related error stack frames such as 11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can 12 | * import the following file, but please comment it out in production mode 13 | * because it will have performance impact when throw error 14 | */ 15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 16 | -------------------------------------------------------------------------------- /src/global.scss: -------------------------------------------------------------------------------- 1 | // http://ionicframework.com/docs/theming/ 2 | @import "~@ionic/angular/css/normalize.css"; 3 | @import "~@ionic/angular/css/structure.css"; 4 | @import "~@ionic/angular/css/typography.css"; 5 | @import "~@ionic/angular/css/colors.css"; 6 | 7 | @import "~@ionic/angular/css/padding.css"; 8 | @import "~@ionic/angular/css/float-elements.css"; 9 | @import "~@ionic/angular/css/text-alignment.css"; 10 | @import "~@ionic/angular/css/text-transformation.css"; 11 | @import "~@ionic/angular/css/flex-utils.css"; 12 | 13 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ionic App 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, 'coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 22 | // import 'core-js/es6/symbol'; 23 | // import 'core-js/es6/object'; 24 | // import 'core-js/es6/function'; 25 | // import 'core-js/es6/parse-int'; 26 | // import 'core-js/es6/parse-float'; 27 | // import 'core-js/es6/number'; 28 | // import 'core-js/es6/math'; 29 | // import 'core-js/es6/string'; 30 | // import 'core-js/es6/date'; 31 | // import 'core-js/es6/array'; 32 | // import 'core-js/es6/regexp'; 33 | // import 'core-js/es6/map'; 34 | // import 'core-js/es6/weak-map'; 35 | // import 'core-js/es6/set'; 36 | 37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 38 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 39 | 40 | /** IE10 and IE11 requires the following for the Reflect API. */ 41 | // import 'core-js/es6/reflect'; 42 | 43 | 44 | /** Evergreen browsers require these. **/ 45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 46 | import 'core-js/es7/reflect'; 47 | 48 | 49 | /** 50 | * Required to support Web Animations `@angular/platform-browser/animations`. 51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation 52 | **/ 53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 54 | 55 | 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by Angular itself. 59 | */ 60 | import 'zone.js/dist/zone'; // Included with Angular CLI. 61 | 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | 68 | /** 69 | * Date, currency, decimal and percent pipes. 70 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 71 | */ 72 | // import 'intl'; // Run `npm install --save intl`. 73 | /** 74 | * Need to import at least one locale-data with intl. 75 | */ 76 | // import 'intl/locale-data/jsonp/en'; 77 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #488aff; 8 | --ion-color-primary-rgb: 72,138,255; 9 | --ion-color-primary-contrast: #fff; 10 | --ion-color-primary-contrast-rgb: 255,255,255; 11 | --ion-color-primary-shade: #3f79e0; 12 | --ion-color-primary-tint: #5a96ff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #32db64; 16 | --ion-color-secondary-rgb: 50,219,100; 17 | --ion-color-secondary-contrast: #fff; 18 | --ion-color-secondary-contrast-rgb: 255,255,255; 19 | --ion-color-secondary-shade: #2cc158; 20 | --ion-color-secondary-tint: #47df74; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #f4a942; 24 | --ion-color-tertiary-rgb: 244,169,66; 25 | --ion-color-tertiary-contrast: #fff; 26 | --ion-color-tertiary-contrast-rgb: 255,255,255; 27 | --ion-color-tertiary-shade: #d7953a; 28 | --ion-color-tertiary-tint: #f5b255; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16,220,96; 33 | --ion-color-success-contrast: #fff; 34 | --ion-color-success-contrast-rgb: 255,255,255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255,206,0; 41 | --ion-color-warning-contrast: #000; 42 | --ion-color-warning-contrast-rgb: 0,0,0; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f53d3d; 48 | --ion-color-danger-rgb: 245,61,61; 49 | --ion-color-danger-contrast: #fff; 50 | --ion-color-danger-contrast-rgb: 255,255,255; 51 | --ion-color-danger-shade: #d83636; 52 | --ion-color-danger-tint: #f65050; 53 | 54 | /** light **/ 55 | --ion-color-light: #f4f4f4; 56 | --ion-color-light-rgb: 244,244,244; 57 | --ion-color-light-contrast: #000; 58 | --ion-color-light-contrast-rgb: 0,0,0; 59 | --ion-color-light-shade: #d7d7d7; 60 | --ion-color-light-tint: #f5f5f5; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152,154,162; 65 | --ion-color-medium-contrast: #000; 66 | --ion-color-medium-contrast-rgb: 0,0,0; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** dark **/ 71 | --ion-color-dark: #222; 72 | --ion-color-dark-rgb: 34,34,34; 73 | --ion-color-dark-contrast: #fff; 74 | --ion-color-dark-contrast-rgb: 255,255,255; 75 | --ion-color-dark-shade: #1e1e1e; 76 | --ion-color-dark-tint: #383838; 77 | } -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "es2015" 7 | }, 8 | "exclude": [ 9 | "test.ts", 10 | "**/*.spec.ts" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "types": [ 8 | "jasmine", 9 | "node" 10 | ] 11 | }, 12 | "files": [ 13 | "test.ts" 14 | ], 15 | "include": [ 16 | "polyfills.ts", 17 | "**/*.spec.ts", 18 | "**/*.d.ts" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "target": "es5", 11 | "lib": [ 12 | "es2017", 13 | "dom" 14 | ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-spacing": true, 20 | "indent": [ 21 | true, 22 | "spaces" 23 | ], 24 | "interface-over-type-literal": true, 25 | "label-position": true, 26 | "max-line-length": [ 27 | true, 28 | 140 29 | ], 30 | "member-access": false, 31 | "member-ordering": [ 32 | true, 33 | { 34 | "order": [ 35 | "static-field", 36 | "instance-field", 37 | "static-method", 38 | "instance-method" 39 | ] 40 | } 41 | ], 42 | "no-arg": true, 43 | "no-bitwise": true, 44 | "no-console": [ 45 | true, 46 | "debug", 47 | "info", 48 | "time", 49 | "timeEnd", 50 | "trace" 51 | ], 52 | "no-construct": true, 53 | "no-debugger": true, 54 | "no-duplicate-super": true, 55 | "no-empty": false, 56 | "no-empty-interface": true, 57 | "no-eval": true, 58 | "no-inferrable-types": [ 59 | true, 60 | "ignore-params" 61 | ], 62 | "no-misused-new": true, 63 | "no-non-null-assertion": true, 64 | "no-shadowed-variable": true, 65 | "no-string-literal": false, 66 | "no-string-throw": true, 67 | "no-switch-case-fall-through": true, 68 | "no-trailing-whitespace": true, 69 | "no-unnecessary-initializer": true, 70 | "no-unused-expression": true, 71 | "no-use-before-declare": true, 72 | "no-var-keyword": true, 73 | "object-literal-sort-keys": false, 74 | "one-line": [ 75 | true, 76 | "check-open-brace", 77 | "check-catch", 78 | "check-else", 79 | "check-whitespace" 80 | ], 81 | "prefer-const": true, 82 | "quotemark": [ 83 | true, 84 | "single" 85 | ], 86 | "radix": true, 87 | "semicolon": [ 88 | true, 89 | "always" 90 | ], 91 | "triple-equals": [ 92 | true, 93 | "allow-null-check" 94 | ], 95 | "typedef-whitespace": [ 96 | true, 97 | { 98 | "call-signature": "nospace", 99 | "index-signature": "nospace", 100 | "parameter": "nospace", 101 | "property-declaration": "nospace", 102 | "variable-declaration": "nospace" 103 | } 104 | ], 105 | "unified-signatures": true, 106 | "variable-name": false, 107 | "whitespace": [ 108 | true, 109 | "check-branch", 110 | "check-decl", 111 | "check-operator", 112 | "check-separator", 113 | "check-type" 114 | ], 115 | "directive-selector": [ 116 | true, 117 | "attribute", 118 | "app", 119 | "camelCase" 120 | ], 121 | "component-selector": [ 122 | true, 123 | "element", 124 | "app", 125 | "page", 126 | "kebab-case" 127 | ], 128 | "no-output-on-prefix": true, 129 | "use-input-property-decorator": true, 130 | "use-output-property-decorator": true, 131 | "use-host-property-decorator": true, 132 | "no-input-rename": true, 133 | "no-output-rename": true, 134 | "use-life-cycle-interface": true, 135 | "use-pipe-transform-interface": true, 136 | "directive-class-suffix": true 137 | } 138 | } 139 | --------------------------------------------------------------------------------