diff --git a/README.md b/README.md
index 3c0f85d..63d7cc5 100644
--- a/README.md
+++ b/README.md
@@ -6,35 +6,20 @@ Combined with aggressive back-end caching, we'll end up with a web site that fee
This is a complex example with many moving parts. It's definitely not for beginners. You should already be familiar with technologies involved: [React](https://reactjs.org/), [Nginx caching](https://www.nginx.com/blog/nginx-caching-guide/), and of course [WordPress](https://wordpress.org/) itself.
-* [Live demo](#live-demo)
-* [Server-side rendering](#server-side-rendering)
-* [Back-end services](#back-end-services)
-* [Uncached page access](#uncached-page-access)
-* [Cached page access](#cached-page-access)
-* [Cache purging](#cache-purging)
-* [Getting started](#getting-started)
-* [Docker Compose configuration](#docker-compose-configuration)
-* [Nginx configuration](#nginx-configuration)
-* [Back-end JavaScript](#back-end-javaScript)
-* [Front-end JavaScript](#front-end-javaScript)
-* [Cordova deployment](#cordova-deployment)
-* [Final words](#final-words)
-
## Live demo
-For the purpose of demonstrating what the example code can do, I've prepared three web sites:
+For the purpose of demonstrating what the example code can do, I've prepared two web sites:
* [pfj.trambar.io](https://pfj.trambar.io)
* [et.trambar.io](https://et.trambar.io)
-* [rwt.trambar.io](https://rwt.trambar.io)
-All three are hosted on the same AWS [A1 medium instance](https://aws.amazon.com/ec2/instance-types/a1/). It's powered by a single core of a [Graviton CPU](https://www.phoronix.com/scan.php?page=article&item=ec2-graviton-performance&num=1) and backed by 2G of RAM. In terms of computational resources, we have roughly one fourth that of a phone. Not much. For our system though, it's more than enough. Most requests will result in cache hits. Nginx will spend most of its time sending data already in memory. We'll be IO-bound long before we're CPU-bound.
+Both are hosted on the same AWS [A1 medium instance](https://aws.amazon.com/ec2/instance-types/a1/). It's powered by a single core of a [Graviton CPU](https://www.phoronix.com/scan.php?page=article&item=ec2-graviton-performance&num=1) and backed by 2G of RAM. In terms of computational resources, we have roughly one fourth that of a phone. Not much. For our system though, it's more than enough. Most requests will result in cache hits. Nginx will spend most of its time sending data already in memory. We'll be IO-bound long before we're CPU-bound.
[pfj.trambar.io](https://pfj.trambar.io) obtains its data from a test WordPress instance running on the same server. It's populated with random lorem ipsum text. You can log into the [WordPress admin page](https://pfj.trambar.io/wp-admin/) and post a article using the account `bdickus` (password: `incontinentia`). Publication of a new article will trigger a cache purge. The article should appear in the front page automatically after 30 seconds or so (no need to hit refresh button).
You can see a list of what's in the Nginx cache [here](https://pfj.trambar.io/.cache).
-[et.trambar.io](https://et.trambar.io) and [rwt.trambar.io](https://rwt.trambar.io) obtain their data from [ExtremeTech](https://www.extremetech.com/) and [Real World Tech](https://www.realworldtech.com/) respectively. They are meant to give you a better sense of how the example code fares with real-world contents. Both sites have close to two decades' worth of articles. Our server does not receive cache purge commands from these WordPress instances so the contents could be out of date. Cache misses will also lead to slightly longer pauses.
+[et.trambar.io](https://et.trambar.io) obtains its data from [ExtremeTech](https://www.extremetech.com/). It's meant to give you a better sense of how the example code fares with real-world contents. The site has close to two decades' worth of articles. Our server does not receive cache purge commands from this WordPress instance so the contents could be out of date. Cache misses will also lead to slightly longer pauses.
## Server-side rendering
@@ -153,14 +138,7 @@ The first two headers added using [add_header](http://nginx.org/en/docs/http/ngx

-## Back-end JavaScript
-
-* [HTML page generation](#html-page-generation)
-* [JSON data retrieval](#json-data-retrieval)
-* [Purge request handling](#purge-request-handling)
-* [Timestamp handling](#timestamp-handling)
-
-### HTML page generation
+## HTML page generation
The following Express handler ([index.js](https://github.com/trambarhq/relaks-wordpress-example/blob/master/server/index.js#L101)) is invoked when Nginx asks for an HTML page. This should happen infrequently as page navigation is handled client-side. Most visitors will enter the site through the root page and that's inevitably cached.
@@ -198,16 +176,17 @@ async function generate(path, target) {
let host = NGINX_HOST;
// create a fetch() that remembers the URLs used
let sourceURLs = [];
+ let agent = new HTTP.Agent({ keepAlive: true });
let fetch = (url, options) => {
if (url.startsWith(host)) {
sourceURLs.push(url.substr(host.length));
options = addHostHeader(options);
+ options.agent = agent;
}
return CrossFetch(url, options);
};
let options = { host, path, target, fetch };
- let rootNode = await FrontEnd.render(options);
- let appHTML = ReactDOMServer.renderToString(rootNode);
+ let appHTML = await FrontEnd.render(options);
let htmlTemplate = await FS.readFileAsync(HTML_TEMPLATE, 'utf-8');
let html = htmlTemplate.replace(``, appHTML);
if (target === 'hydrate') {
@@ -221,33 +200,32 @@ async function generate(path, target) {
`FrontEnd.render()` returns a ReactElement containing plain HTML child elements. We use [React DOM Server](https://reactjs.org/docs/react-dom-server.html#rendertostring) to convert that to actual HTML text. Then we stick it into our [HTML template](https://github.com/trambarhq/relaks-wordpress-example/blob/master/src/index.html), where a HTML comment sits inside the element that would host the root React component.
-`FrontEnd.render()` is a function exported by our front-end's [bootstrap code](https://github.com/trambarhq/relaks-wordpress-example/blob/master/src/main.js#L67):
+`FrontEnd.render()` is a function exported by our front-end code(https://github.com/trambarhq/relaks-wordpress-example/blob/master/src/ssr.js#L67):
```javascript
-async function serverSideRender(options) {
- let basePath = process.env.BASE_PATH;
- let dataSource = new WordpressDataSource({
+async function render(options) {
+ const dataSource = new WordpressDataSource({
baseURL: options.host + basePath + 'json',
fetchFunc: options.fetch,
});
dataSource.activate();
- let routeManager = new RouteManager({
+ const routeManager = new RouteManager({
routes,
basePath,
});
routeManager.addEventListener('beforechange', (evt) => {
- let route = new Route(routeManager, dataSource);
+ const route = new Route(routeManager, dataSource);
evt.postponeDefault(route.setParameters(evt, false));
});
routeManager.activate();
await routeManager.start(options.path);
- let ssrElement = createElement(FrontEnd, { dataSource, routeManager, ssr: options.target });
- return harvest(ssrElement);
+ const ssrElement = createElement(FrontEnd, { dataSource, routeManager, ssr: options.target });
+ const rootNode = await harvest(ssrElement);
+ const appHTML = renderToString(rootNode);
+ return appHTML;
}
-
-exports.render = serverSideRender;
```
The code initiates the data source and the route manager. Using these as props, it creates the root React element `
');-1!==t&&(e=e.substr(0,t));return e}(a.a.get(n,"excerpt.rendered","")),d=t.prefetchObjectURL(n),f=a.a.get(n,"date_gmt"),h=f?s()(f).format("L"):"";return r?u.a.createElement("div",{className:"post-list-view with-media"},u.a.createElement("div",{className:"media"},u.a.createElement(c,{media:r})),u.a.createElement("div",{className:"text"},u.a.createElement("div",{className:"headline"},u.a.createElement("h3",{className:"title"},u.a.createElement("a",{href:d},u.a.createElement(l.a,{text:i}))),u.a.createElement("div",{className:"date"},h)),u.a.createElement("div",{className:"excerpt"},u.a.createElement(l.a,{text:o})))):u.a.createElement("div",{className:"post-list-view"},u.a.createElement("div",{className:"headline"},u.a.createElement("h3",{className:"title"},u.a.createElement("a",{href:d},u.a.createElement(l.a,{text:i}))),u.a.createElement("div",{className:"date"},h)),u.a.createElement("div",{className:"excerpt"},u.a.createElement(l.a,{text:o})))}function f(e){var t=e.route,n=e.posts,r=e.medias,i=e.minimum,s=e.maximum;return Object(o.useEffect)(function(){var e=function(e){l(.5)};return document.addEventListener("scroll",e),function(){document.removeEventListener("scroll",e)}}),Object(o.useEffect)(function(){n&&n.more&&n.lengtht.scrollHeight*e&&n&&n.more&&n.lengtha&&(r=s,a=u)}}if(-1!=r){var c=i[r];return i.splice(r,1),c.result}}},function(e,t,n){"use strict";n.d(t,"b",function(){return o}),n.d(t,"a",function(){return u}),n.d(t,"d",function(){return l}),n.d(t,"c",function(){return c});var r,a=n(0),i=n.n(a),s=n(22);function o(e){var t=function t(n){r=Object(a.useState)({});var i={func:t,props:n},o=s.a.acquire(r,i);Object(a.useEffect)(function(){return o.mount(),function(){o.hasEnded()||o.cancel()}},[o]),o.run(function(){return e(n)}),r=void 0;var u=o.getError();if(u)throw u;return o.getElement()};return t.renderAsyncEx=function(n){r=[{},function(e){}];var a={func:t,props:n},i=s.a.start(r,a);i.noProgress=!0;var o=e(n);return r=void 0,o&&"function"==typeof o.then?o.then(function(e){return void 0===e&&(e=i.progressElement),e}):o},e.propTypes&&(t.propTypes=e.propTypes),e.defaultProps&&(t.defaultProps=e.defaultProps),t.displayName=e.displayName||e.name,t}function u(e,t){var n=o(e),r=i.a.memo(n,t);return r.defaultProps||(r.defaultProps=n.defaultProps),r}function l(e,t){var n=s.a.get(r);return n.delay(e,t,!0),[n.show,n.check,n.delay]}function c(){var e=Object(a.useState)(),t=e[0],n=e[1];return[t,Object(a.useCallback)(function(e){n(new Date)})]}},function(e,t,n){try{var r=n(287);if("function"!=typeof r.inherits)throw"";e.exports=r.inherits}catch(t){e.exports=n(288)}},function(e,t,n){var r=n(14),a=n(76),i=n(57),s=Object.defineProperty;t.f=n(21)?Object.defineProperty:function(e,t,n){if(r(e),t=i(t,!0),r(n),a)try{return s(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){e.exports=!n(26)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(e,t,n){"use strict";n.d(t,"a",function(){return i});var r=n(34),a=n(16);function i(e,t){this.progressElement=void 0,this.progressAvailable=!1,this.progressForced=!1,this.promisedElement=void 0,this.promisedAvailable=!1,this.elementRendered=t?t.elementRendered:null,this.deferredError=void 0,this.showingProgress=!1,this.delayEmpty=a.b("delayWhenEmpty"),this.delayRendered=a.b("delayWhenRendered"),this.canceled=!1,this.completed=!1,this.checked=!1,this.mounted=!1,this.initial=!0,this.synchronous=!1,this.prevProps={},this.prevPropsAsync={},this.updateTimeout=0,this.startTime=new Date,this.handlers={},this.target=e,this.context=void 0,this.setContext=void 0,this.show=this.show.bind(this),this.check=this.check.bind(this),this.delay=this.delay.bind(this),this.resolve=this.resolve.bind(this),this.reject=this.reject.bind(this),t&&(this.prevProps=t.target.props,t.canceled?this.prevPropsAsync=t.prevPropsAsync:this.prevPropsAsync=t.target.props,this.elementRendered=t.elementRendered,this.initial=!1)}var s=i.prototype;function o(e){if(!e)throw new Error("Unable to obtain state variable");var t=e[0],n=t.cycle;return n&&(n.context=t,n.setContext=e[1]),n}function u(e,t){var n=e[0],r=new i(t,n.cycle);return r.context=n,r.setContext=e[1],n.cycle=r,r}s.hasEnded=function(){return this.completed||this.canceled},s.isRerendering=function(){return!this.hasEnded()&&(this.promisedAvailable||this.progressAvailable||this.deferredError)},s.run=function(e){if(!this.deferredError){this.synchronous=!0;try{var t=e();t&&"function"==typeof t.then?t.then(this.resolve,this.reject):this.resolve(t)}catch(e){this.reject(e)}this.synchronous=!1}},s.resolve=function(e){if(this.clear(),!this.hasEnded()){if(!this.checked)return void this.reject(new Error("Missing call to show() prior to await"));if(void 0===e)if(void 0!==this.progressElement)e=this.progressElement;else if(this.elementRendered)return void this.complete();this.progressElement=void 0,this.progressAvailable=!1,this.promisedElement=e,this.promisedAvailable=!0,this.rerender()}},s.reject=function(e){this.clear(),e instanceof r.a||this.hasEnded()||(this.deferredError=e,this.mounted&&this.rerender())},s.mount=function(){this.mounted=!0,this.initial&&this.isRerendering()&&this.rerender()},s.getElement=function(){return this.promisedAvailable?(this.elementRendered=this.promisedElement,this.promisedElement=void 0,this.promisedAvailable=!1,this.complete()):this.progressAvailable&&(this.elementRendered=this.progressElement,this.progressElement=void 0,this.progressAvailable=!1,this.progress()),this.elementRendered},s.getError=function(){if(this.deferredError){var e=this.deferredError;return this.deferredError=void 0,this.cancel(),e}},s.getPrevProps=function(e){return e?this.prevPropsAsync:this.prevProps},s.substitute=function(e){this.promisedElement=e,this.promisedAvailable=!0;var t=this;setTimeout(function(){t.setContext({cycle:t})},0)},s.on=function(e,t){this.handlers[e]=t},s.show=function(e,t){if(this.check(),this.progressElement=e,this.noProgress)return!1;var n;if((n=this.showingProgress?0:"always"===t?0:"initial"!==t||this.elementRendered?this.elementRendered?this.delayRendered:this.delayEmpty:0)>0){if(n!==1/0&&!this.updateTimeout){var r=this;this.updateTimeout=setTimeout(function(){0!==r.updateTimeout&&r.update()},n)}return!1}return this.update(),!0},s.update=function(e){this.progressAvailable=!0,this.progressForced=e,(this.initial||this.mounted)&&this.rerender()},s.check=function(){if(!this.noProgress){if(this.synchronous&&(this.checked=!0,this.isRerendering()))throw new r.a;if(this.canceled)throw new r.a}},s.delay=function(e,t){"number"==typeof e&&(this.delayEmpty=e),"number"==typeof t&&(this.delayRendered=t)},s.cancel=function(){this.clear(),this.canceled||(this.canceled=!0,this.notify("cancel"))},s.complete=function(){this.clear(),this.completed||(this.completed=!0,this.notify("complete"))},s.progress=function(){this.showingProgress||this.progressForced||(this.showingProgress=!0),this.notify("progress")},s.clear=function(){this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=0)},s.rerender=function(){this.synchronous||this.hasEnded()||this.context.cycle===this&&this.setContext({cycle:this})},s.notify=function(e){var t=this.handlers[e];t&&t({type:e,elapsed:new Date-this.startTime,target:this.target})},s.constructor.get=o,s.constructor.start=u,s.constructor.acquire=function(e,t){var n=o(e);if(n&&(n.hasEnded()?n=void 0:n.isRerendering()||(n.cancel(),n=void 0)),!n&&(n=u(e,t)).initial){var r=a.a(t);r&&n.substitute(r)}return n}},function(e,t,n){var r=n(19),a=n(44);e.exports=n(21)?function(e,t,n){return r.f(e,t,a(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){e.exports={default:n(247),__esModule:!0}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){e.exports={}},function(e,t,n){var r=n(79),a=n(55);e.exports=function(e){return r(a(e))}},function(e,t,n){var r=n(218),a=n(223);function i(t,n){return delete e.exports[t],e.exports[t]=n,n}e.exports={Parser:r,Tokenizer:n(219),ElementType:n(30),DomHandler:a,get FeedHandler(){return i("FeedHandler",n(290))},get Stream(){return i("Stream",n(301))},get WritableStream(){return i("WritableStream",n(226))},get ProxyHandler(){return i("ProxyHandler",n(306))},get DomUtils(){return i("DomUtils",n(225))},get CollectingHandler(){return i("CollectingHandler",n(307))},DefaultHandler:a,get RssHandler(){return i("RssHandler",this.FeedHandler)},parseDOM:function(e,t){var n=new a(t);return new r(n,t).end(e),n.dom},parseFeed:function(t,n){var a=new e.exports.FeedHandler(n);return new r(a,n).end(t),a.dom},createDomStream:function(e,t,n){var i=new a(e,t,n);return new r(i,t)},EVENTS:{attribute:2,cdatastart:0,cdataend:0,text:1,processinginstruction:2,comment:1,commentend:0,closetag:1,opentag:2,opentagname:1,error:1,end:0}}},function(e,t){e.exports={Text:"text",Directive:"directive",Comment:"comment",Script:"script",Style:"style",Tag:"tag",CDATA:"cdata",Doctype:"doctype",isTag:function(e){return"tag"===e.type||"script"===e.type||"style"===e.type}}},function(e,t,n){"use strict";n.d(t,"a",function(){return m}),n.d(t,"b",function(){return p});var r=n(3),a=n.n(r),i=n(4),s=n.n(i),o=n(32),u=n.n(o),l=n(33),c=n.n(l),d=n(2),f=n.n(d),h=n(40),_=n(52),m=function(){function e(t,n){var r=this;u()(this,e),this.transformNode=function(e){if("tag"===e.type){var t=r.params.siteURL,n="http:"+t.substr(6);if("a"===e.name){var a=f.a.trim(e.attribs.href),i=void 0;a&&(f.a.startsWith(a,"/")||(f.a.startsWith(a,t)?a=a.substr(t.length):f.a.startsWith(a,n)?a=a.substr(n.length):i="_blank"),f.a.startsWith(a,"/wp-content/")&&(a=t+a),f.a.startsWith(a,"/")&&(a=a.replace(/\/\d+\/?$/,""),a=r.routeManager.applyFallback(a),r.loadPageData(a)),e.attribs.href=a,e.attribs.target=i)}else if("img"===e.name){var s=f.a.trim(e.attribs.src);s&&!/^https?:/.test(s)&&(s=t+s,e.attribs.src=s)}}else"text"===e.type&&(e.data=f.a.trimStart(e.data,"\r\n"))},this.routeManager=t,this.name=t.name,this.params=t.params,this.history=t.history,this.url=t.url,this.dataSource=n}return c()(e,[{key:"change",value:function(e,t){return this.routeManager.change(e,t)}},{key:"getRootURL",value:function(){return this.composeURL({path:"/"})}},{key:"getSearchURL",value:function(e){return this.composeURL({path:"/",query:{s:e}})}},{key:"getArchiveURL",value:function(e){var t=e.year,n=e.month;return this.composeURL({path:"/date/"+t+"/"+f.a.padStart(n,2,"0")+"/"})}},{key:"getObjectURL",value:function(e){var t=this.params.siteURL,n=e.link;if(!f.a.startsWith(n,t))throw new Error("Object URL does not match site URL");var r=n.substr(t.length);return this.composeURL({path:r})}},{key:"prefetchArchiveURL",value:function(e){var t=this,n=this.getArchiveURL(e);return setTimeout(function(){t.loadPageData(n)},50),n}},{key:"prefetchObjectURL",value:function(e){var t=this,n=this.getObjectURL(e);return setTimeout(function(){t.loadPageData(n)},50),n}},{key:"composeURL",value:function(e){var t=this.routeManager.context;this.routeManager.rewrite("to",e,t);var n=this.routeManager.compose(e);return n=this.routeManager.applyFallback(n)}},{key:"setParameters",value:function(){var e=s()(a.a.mark(function e(t,r){var i;return a.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getParameters(t.path,t.query);case 2:if(!(i=e.sent)){e.next=8;break}i.module=n(278)("./"+i.pageType+"-page"),f.a.assign(t.params,i),e.next=15;break;case 8:if(!r){e.next=14;break}return e.next=11,this.routeManager.change("/");case 11:return e.abrupt("return",!1);case 14:throw new _.RelaksRouteManagerError(404,"Route not found");case 15:case"end":return e.stop()}},e,this)}));return function(t,n){return e.apply(this,arguments)}}()},{key:"getParameters",value:function(){var e=s()(a.a.mark(function e(t,n,r){var i,s,o,u,l,c,d,_,m,p,y,v,g,M,b,L,k,w,Y,T,D;return a.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return i=new h.a(this.dataSource),e.next=3,i.fetchSite();case 3:if(s=e.sent,o=f.a.trimEnd(s.url,"/"),u=f.a.trimEnd(o+t,"/"),l=function(e){return f.a.trimEnd(e.link,"/")===u},c=f.a.filter(f.a.split(t,"/")),!(d=n.s)){e.next=11;break}return e.abrupt("return",{pageType:"search",search:d,siteURL:o});case 11:if("/"!==t){e.next=13;break}return e.abrupt("return",{pageType:"welcome",siteURL:o});case 13:if("date"!==c[0]||!/^\d+$/.test(c[1])||!/^\d+$/.test(c[2])||3!=c.length){e.next=18;break}return _={year:parseInt(c[1]),month:parseInt(c[2])},e.abrupt("return",{pageType:"archive",date:_,siteURL:o});case 18:if(!/^\d+$/.test(c[0])||!/^\d+$/.test(c[1])||2!=c.length){e.next=21;break}return m={year:parseInt(c[0]),month:parseInt(c[1])},e.abrupt("return",{pageType:"archive",date:m,siteURL:o});case 21:if("archives"!==c[0]||!/^\d+$/.test(c[1])){e.next=28;break}return p=parseInt(c[1]),e.next=25,i.fetchPost(p);case 25:if(!(y=e.sent)){e.next=28;break}return e.abrupt("return",{pageType:"post",postSlug:y.slug,siteURL:o});case 28:return e.next=30,i.fetchPages();case 30:if(v=e.sent,!(g=f.a.find(v,l))){e.next=34;break}return e.abrupt("return",{pageType:"page",pageSlug:g.slug,siteURL:o});case 34:return e.next=36,i.fetchCategories();case 36:if(M=e.sent,!(b=f.a.find(M,l))){e.next=40;break}return e.abrupt("return",{pageType:"category",categorySlug:b.slug,siteURL:o});case 40:return e.next=42,i.fetchTopTags();case 42:if(L=e.sent,!(k=f.a.find(L,l))){e.next=46;break}return e.abrupt("return",{pageType:"tag",tagSlug:k.slug,siteURL:o});case 46:if("tag"!==c[0]||2!==c.length){e.next=52;break}return e.next=49,i.fetchTag(c[1]);case 49:if(!(w=e.sent)){e.next=52;break}return e.abrupt("return",{pageType:"tag",tagSlug:w.slug,siteURL:o});case 52:return Y=f.a.last(c),/^\d+\-/.test(Y)&&(Y=Y.replace(/^\d+\-/,"")),e.next=56,i.fetchPost(Y);case 56:if(!e.sent){e.next=59;break}return e.abrupt("return",{pageType:"post",postSlug:Y,siteURL:o});case 59:return T=f.a.last(c),e.next=62,i.fetchTag(T);case 62:if(!(D=e.sent)){e.next=65;break}return e.abrupt("return",{pageType:"tag",tagSlug:D.slug,siteURL:o});case 65:case"end":return e.stop()}},e,this)}));return function(t,n,r){return e.apply(this,arguments)}}()},{key:"loadPageData",value:function(){var e=s()(a.a.mark(function e(t){var n,r,i,s,o,u;return a.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=this.routeManager.parse(t),r={},this.routeManager.rewrite("from",n,r),e.next=6,this.getParameters(n.path,n.query);case 6:if(!(i=e.sent)){e.next=38;break}if(s=new h.a(this.dataSource),!i.postSlug){e.next=14;break}return e.next=12,s.fetchPost(i.postSlug);case 12:e.next=38;break;case 14:if(!i.pageSlug){e.next=19;break}return e.next=17,s.fetchPage(i.pageSlug);case 17:e.next=38;break;case 19:if(!i.tagSlug){e.next=27;break}return e.next=22,s.fetchTag(i.tagSlug);case 22:return o=e.sent,e.next=25,s.fetchPostsWithTag(o);case 25:e.next=38;break;case 27:if(!i.categorySlug){e.next=35;break}return e.next=30,s.fetchCategory(i.categorySlug);case 30:return u=e.sent,e.next=33,s.fetchPostsInCategory(u);case 33:e.next=38;break;case 35:if(!i.date){e.next=38;break}return e.next=38,s.fetchPostsInMonth(i.date);case 38:e.next=43;break;case 40:e.prev=40,e.t0=e.catch(0),console.log(e.t0);case 43:case"end":return e.stop()}},e,this,[[0,40]])}));return function(t){return e.apply(this,arguments)}}()}]),e}(),p={page:{path:"*"}}},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},function(e,t,n){"use strict";t.__esModule=!0;var r,a=n(269),i=(r=a)&&r.__esModule?r:{default:r};t.default=function(){function e(e,t){for(var n=0;n