SEO improvements
							parent
							
								
									94f457748e
								
							
						
					
					
						commit
						de0b81d6be
					
				
							
								
								
									
										6
									
								
								app.js
								
								
								
								
							
							
						
						
									
										6
									
								
								app.js
								
								
								
								
							|  | @ -314,6 +314,12 @@ handlebars = handlebars.create({ | ||||||
|                 return'd-none'; |                 return'd-none'; | ||||||
|             } |             } | ||||||
|             return''; |             return''; | ||||||
|  |         }, | ||||||
|  |         snip: (text) => { | ||||||
|  |             if(text.length > 155){ | ||||||
|  |                 return text.substring(0, 155) + '...'; | ||||||
|  |             } | ||||||
|  |             return text; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| { | { | ||||||
|   "name": "express-cart", |   "name": "express-cart", | ||||||
|   "version": "1.1.15", |   "version": "1.1.16", | ||||||
|   "lockfileVersion": 1, |   "lockfileVersion": 1, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|  | @ -2967,6 +2967,11 @@ | ||||||
|         "once": "^1.4.0" |         "once": "^1.4.0" | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "ent": { | ||||||
|  |       "version": "2.2.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", | ||||||
|  |       "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=" | ||||||
|  |     }, | ||||||
|     "entities": { |     "entities": { | ||||||
|       "version": "1.1.1", |       "version": "1.1.1", | ||||||
|       "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", |       "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", | ||||||
|  | @ -5960,6 +5965,16 @@ | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|  |     "is-natural-number": { | ||||||
|  |       "version": "4.0.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", | ||||||
|  |       "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=" | ||||||
|  |     }, | ||||||
|  |     "is-natural-number-string": { | ||||||
|  |       "version": "1.0.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/is-natural-number-string/-/is-natural-number-string-1.0.1.tgz", | ||||||
|  |       "integrity": "sha1-0OvxwBH64tOwc02MgBFuJRKkoug=" | ||||||
|  |     }, | ||||||
|     "is-negated-glob": { |     "is-negated-glob": { | ||||||
|       "version": "1.0.0", |       "version": "1.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", |       "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", | ||||||
|  | @ -6523,6 +6538,11 @@ | ||||||
|       "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", |       "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", | ||||||
|       "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=" |       "integrity": "sha1-G7nzFO9ri63tE7VJFpsqlF62jk0=" | ||||||
|     }, |     }, | ||||||
|  |     "lodash.trim": { | ||||||
|  |       "version": "4.5.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/lodash.trim/-/lodash.trim-4.5.1.tgz", | ||||||
|  |       "integrity": "sha1-NkJefukL5KpeJ7zruFt9EepHqlc=" | ||||||
|  |     }, | ||||||
|     "lodash.uniq": { |     "lodash.uniq": { | ||||||
|       "version": "4.5.0", |       "version": "4.5.0", | ||||||
|       "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", |       "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", | ||||||
|  | @ -6533,6 +6553,11 @@ | ||||||
|       "resolved": "https://registry.npmjs.org/lodash.unset/-/lodash.unset-4.5.2.tgz", |       "resolved": "https://registry.npmjs.org/lodash.unset/-/lodash.unset-4.5.2.tgz", | ||||||
|       "integrity": "sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=" |       "integrity": "sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=" | ||||||
|     }, |     }, | ||||||
|  |     "lodash.without": { | ||||||
|  |       "version": "4.4.0", | ||||||
|  |       "resolved": "https://registry.npmjs.org/lodash.without/-/lodash.without-4.4.0.tgz", | ||||||
|  |       "integrity": "sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=" | ||||||
|  |     }, | ||||||
|     "log-symbols": { |     "log-symbols": { | ||||||
|       "version": "2.2.0", |       "version": "2.2.0", | ||||||
|       "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", |       "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", | ||||||
|  | @ -8102,6 +8127,45 @@ | ||||||
|       "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", |       "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", | ||||||
|       "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" |       "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" | ||||||
|     }, |     }, | ||||||
|  |     "ranges-apply": { | ||||||
|  |       "version": "3.0.48", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ranges-apply/-/ranges-apply-3.0.48.tgz", | ||||||
|  |       "integrity": "sha512-BnNKJGVJ70290B/h9dekLqZAqpA5zziUao5J93Zm0o/+x55ZoN+Sx2DIIGgnvNQ5e8W2kN7CvM6k5mBMxLWnxQ==", | ||||||
|  |       "requires": { | ||||||
|  |         "is-natural-number-string": "^1.0.1", | ||||||
|  |         "ranges-merge": "^4.2.31" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "ranges-merge": { | ||||||
|  |       "version": "4.2.31", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ranges-merge/-/ranges-merge-4.2.31.tgz", | ||||||
|  |       "integrity": "sha512-YCoKrdj5juCPNoFipewrf/agmEXulgEkzcLhsUhlcZXZ5uMsVOdbRJNVdkPlZvvkqiKkzCNjrUYk2Yl3DHVmew==", | ||||||
|  |       "requires": { | ||||||
|  |         "lodash.clonedeep": "^4.5.0", | ||||||
|  |         "lodash.isplainobject": "^4.0.6", | ||||||
|  |         "ranges-sort": "^3.10.46" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "ranges-push": { | ||||||
|  |       "version": "3.6.15", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ranges-push/-/ranges-push-3.6.15.tgz", | ||||||
|  |       "integrity": "sha512-i1uEcKCgyUs8JMNn363bREAChUoDeUZgg6eMjvKa8ay7G7Veh7qhEUb8taetcQ3V93FE4ubLk/MHcSuTvPtzTg==", | ||||||
|  |       "requires": { | ||||||
|  |         "is-natural-number-string": "^1.0.1", | ||||||
|  |         "lodash.clonedeep": "^4.5.0", | ||||||
|  |         "ranges-merge": "^4.2.31", | ||||||
|  |         "string-collapse-leading-whitespace": "^2.0.12", | ||||||
|  |         "string-trim-spaces-only": "^2.8.9" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "ranges-sort": { | ||||||
|  |       "version": "3.10.46", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ranges-sort/-/ranges-sort-3.10.46.tgz", | ||||||
|  |       "integrity": "sha512-H07aLdjKQRz3tUNHCj5P9Tof1vH35J4c3atXl8T/fs3SATKgzpkjACz9MfuuKgvQsXOFau2GDvQ/hl6Szw39/Q==", | ||||||
|  |       "requires": { | ||||||
|  |         "is-natural-number": "^4.0.1" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "raw-body": { |     "raw-body": { | ||||||
|       "version": "2.4.0", |       "version": "2.4.0", | ||||||
|       "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", |       "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", | ||||||
|  | @ -9185,6 +9249,39 @@ | ||||||
|       "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", |       "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", | ||||||
|       "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" |       "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" | ||||||
|     }, |     }, | ||||||
|  |     "string-collapse-leading-whitespace": { | ||||||
|  |       "version": "2.0.12", | ||||||
|  |       "resolved": "https://registry.npmjs.org/string-collapse-leading-whitespace/-/string-collapse-leading-whitespace-2.0.12.tgz", | ||||||
|  |       "integrity": "sha512-LQoIozpzquQCxt3ARdnuPAp0IFcQFfMgVKDVMYpvmrfyUSA17pLuSOD8h3HfYJNn0uTnw0eb5xsiIPTyzlzxCw==" | ||||||
|  |     }, | ||||||
|  |     "string-left-right": { | ||||||
|  |       "version": "2.3.14", | ||||||
|  |       "resolved": "https://registry.npmjs.org/string-left-right/-/string-left-right-2.3.14.tgz", | ||||||
|  |       "integrity": "sha512-Z6/TNpG+aDijZyO0K32dPOI0d8R2uzXWhiibGMj+AZIqOBUY0BJnZ96OSNYQohSuABfZRu03POo/3rEhrxfLZw==", | ||||||
|  |       "requires": { | ||||||
|  |         "lodash.clonedeep": "^4.5.0", | ||||||
|  |         "lodash.isplainobject": "^4.0.6" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "string-strip-html": { | ||||||
|  |       "version": "4.3.14", | ||||||
|  |       "resolved": "https://registry.npmjs.org/string-strip-html/-/string-strip-html-4.3.14.tgz", | ||||||
|  |       "integrity": "sha512-CpX4dR8388T5HwYMKqS17K3MGls0yuec7m5hK6hbWGvxpJPVXJIfMd+ZTCHLgHVoWZew6sjBqI6bpERol/tGxw==", | ||||||
|  |       "requires": { | ||||||
|  |         "ent": "^2.2.0", | ||||||
|  |         "lodash.isplainobject": "^4.0.6", | ||||||
|  |         "lodash.trim": "^4.5.1", | ||||||
|  |         "lodash.without": "^4.4.0", | ||||||
|  |         "ranges-apply": "^3.0.48", | ||||||
|  |         "ranges-push": "^3.6.15", | ||||||
|  |         "string-left-right": "^2.3.14" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |     "string-trim-spaces-only": { | ||||||
|  |       "version": "2.8.9", | ||||||
|  |       "resolved": "https://registry.npmjs.org/string-trim-spaces-only/-/string-trim-spaces-only-2.8.9.tgz", | ||||||
|  |       "integrity": "sha512-atfGwUCChsXQ0WEqX1Ju2YYC/6yqpnq8fL8jl2BUpjNR13b+s6q/SmmdDG10H+t4JB8/cRi9klyYuwctvgjFJg==" | ||||||
|  |     }, | ||||||
|     "string-width": { |     "string-width": { | ||||||
|       "version": "1.0.2", |       "version": "1.0.2", | ||||||
|       "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", |       "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", | ||||||
|  |  | ||||||
|  | @ -66,6 +66,7 @@ | ||||||
|     "rimraf": "^2.7.1", |     "rimraf": "^2.7.1", | ||||||
|     "sanitize-html": "^1.20.1", |     "sanitize-html": "^1.20.1", | ||||||
|     "sitemap": "^1.6.0", |     "sitemap": "^1.6.0", | ||||||
|  |     "string-strip-html": "^4.3.14", | ||||||
|     "strip-bom": "^3.0.0", |     "strip-bom": "^3.0.0", | ||||||
|     "stripe": "^7.12.0", |     "stripe": "^7.12.0", | ||||||
|     "uglifycss": "0.0.27", |     "uglifycss": "0.0.27", | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ const express = require('express'); | ||||||
| const router = express.Router(); | const router = express.Router(); | ||||||
| const colors = require('colors'); | const colors = require('colors'); | ||||||
| const hash = require('object-hash'); | const hash = require('object-hash'); | ||||||
|  | const stripHtml = require('string-strip-html'); | ||||||
| const moment = require('moment'); | const moment = require('moment'); | ||||||
| const _ = require('lodash'); | const _ = require('lodash'); | ||||||
| const { | const { | ||||||
|  | @ -320,7 +321,7 @@ router.get('/product/:id', async (req, res) => { | ||||||
|         result: product, |         result: product, | ||||||
|         productOptions: productOptions, |         productOptions: productOptions, | ||||||
|         images: images, |         images: images, | ||||||
|         productDescription: product.productDescription, |         productDescription: stripHtml(product.productDescription), | ||||||
|         metaDescription: config.cartTitle + ' - ' + product.productTitle, |         metaDescription: config.cartTitle + ' - ' + product.productTitle, | ||||||
|         config: config, |         config: config, | ||||||
|         session: req.session, |         session: req.session, | ||||||
|  |  | ||||||
|  | @ -14,9 +14,9 @@ | ||||||
|         {{/if}} |         {{/if}} | ||||||
| 		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | 		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> | ||||||
|         {{#if metaDescription}} |         {{#if metaDescription}} | ||||||
|         <meta name="description" content="{{metaDescription}}"> |         <meta name="description" content="{{snip metaDescription}}"> | ||||||
|         {{else}} |         {{else}} | ||||||
| 		<meta name="description" content="{{config.cartDescription}}"> | 		<meta name="description" content="{{snip config.cartDescription}}"> | ||||||
|         {{/if}} |         {{/if}} | ||||||
| 		<meta name="keywords" content="{{config.cartTitle}}"> | 		<meta name="keywords" content="{{config.cartTitle}}"> | ||||||
|         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous" /> |         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous" /> | ||||||
|  | @ -55,15 +55,31 @@ | ||||||
|         {{/if}} |         {{/if}} | ||||||
|         <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tokenfield/0.12.0/bootstrap-tokenfield.min.js" integrity="sha256-jdwX0QzXB7z7Xc7Vz0ovtIHWO5qIZWg0aLcGv44JDgE=" crossorigin="anonymous"></script> |         <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tokenfield/0.12.0/bootstrap-tokenfield.min.js" integrity="sha256-jdwX0QzXB7z7Xc7Vz0ovtIHWO5qIZWg0aLcGv44JDgE=" crossorigin="anonymous"></script> | ||||||
|         <!-- SEO data --> |         <!-- SEO data --> | ||||||
|  |         {{#if pageUrl}} | ||||||
|  |         <link rel="canonical" href="{{pageUrl}}" /> | ||||||
|  |         {{else}} | ||||||
|         <link rel="canonical" href="{{config.baseUrl}}" /> |         <link rel="canonical" href="{{config.baseUrl}}" /> | ||||||
|  |         {{/if}} | ||||||
|         <meta name="referrer" content="origin" /> |         <meta name="referrer" content="origin" /> | ||||||
|         <meta property="og:site_name" content="{{config.cartTitle}}" /> |         <meta property="og:site_name" content="{{config.cartTitle}}" /> | ||||||
|         <meta property="og:type" content="website" /> |         <meta property="og:type" content="website" /> | ||||||
|         <meta property="og:title" content="{{title}}" /> |         <meta property="og:title" content="{{title}}" /> | ||||||
|  |         {{#if pageUrl}} | ||||||
|  |         <meta property="og:url" content="{{pageUrl}}" /> | ||||||
|  |         {{else}} | ||||||
|         <meta property="og:url" content="{{config.baseUrl}}" /> |         <meta property="og:url" content="{{config.baseUrl}}" /> | ||||||
|  |         {{/if}} | ||||||
|  |         {{#if result.productImage}} | ||||||
|  |         <meta property="og:image" content="{{result.productImage}}" /> | ||||||
|  |         {{/if}} | ||||||
|         <meta name="twitter:card" content="summary" /> |         <meta name="twitter:card" content="summary" /> | ||||||
|         <meta name="twitter:title" content="{{title}}" /> |         <meta name="twitter:title" content="{{title}}" /> | ||||||
|         <meta name="twitter:url" content="{{config.baseUrl}}" /> |         <meta name="twitter:url" content="{{config.baseUrl}}" /> | ||||||
|  |         {{#if pageUrl}} | ||||||
|  |         <meta name="twitter:url" content="{{pageUrl}}" /> | ||||||
|  |         {{else}} | ||||||
|  |         <meta name="twitter:url" content="{{config.baseUrl}}" /> | ||||||
|  |         {{/if}} | ||||||
|         <script type="application/ld+json"> |         <script type="application/ld+json"> | ||||||
|             { |             { | ||||||
|                 "@context": "http://schema.org", |                 "@context": "http://schema.org", | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue