<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marius Balčytis on Medium]]></title>
        <description><![CDATA[Stories by Marius Balčytis on Medium]]></description>
        <link>https://medium.com/@mariusbalcytis?source=rss-8af8950d32d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9RU1wdRpw3rPk1ro.</url>
            <title>Stories by Marius Balčytis on Medium</title>
            <link>https://medium.com/@mariusbalcytis?source=rss-8af8950d32d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 07:00:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mariusbalcytis/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTTP/3 — let’s speed the web once more]]></title>
            <link>https://medium.com/paysera-engineering/http-3-lets-speed-the-web-once-more-d42944538738?source=rss-8af8950d32d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42944538738</guid>
            <category><![CDATA[network]]></category>
            <category><![CDATA[https]]></category>
            <dc:creator><![CDATA[Marius Balčytis]]></dc:creator>
            <pubDate>Mon, 18 Nov 2019 20:38:31 GMT</pubDate>
            <atom:updated>2019-11-18T20:38:31.120Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTTP/3 — let’s speed the web once more</h3><p>HTTP/1.0 was published in 1996, followed by HTTP/1.1 one year later.</p><p>For 18 whole years, this was the standard used for practically the whole web throughout the world, improving performance with various hacks such as asset bundling, CSS sprites, icon fonts, and so on.</p><p>Then came HTTP/2.</p><p>And now, only a few years later, even when <a href="https://w3techs.com/technologies/details/ce-http2/all/all">HTTP/2 adoption has not reached 50% yet</a>, HTTP/3 will shortly be introduced.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*CLiSx2LIlvVbSYMcWQ9oYw.png" /></figure><h4>Why the new versions? Performance, of course! ⚡</h4><p>Most of the changes introduced right from version 1.0 were oriented towards performance.</p><p>To understand what exactly affect performance and how the new versions improve on older ones, we need to dig a bit deeper into the network stack.</p><h4>TCP/IP stack</h4><p>There are two network layering models — the OSI model and TCP/IP stack. The latter is a bit simpler, so let’s stick to that. It has the following 4 layers:</p><ul><li>Application. Developers are usually interested only in this layer. In our case, this is HTTP.</li><li>Transport. Usually it’s TCP or UDP. That’s where all the magic happens with HTTP/3, but more on that later.</li><li>Internet. Usually IPv4 or IPv6.</li><li>Link. This usually routes messages using MAC addresses and handles various transport based on your Internet connection (like Ethernet, WiFi, 4G, etc.).</li></ul><figure><img alt="IP stack connections" src="https://cdn-images-1.medium.com/max/800/0*-cVxR8DfXCP2cT44.png" /></figure><p>Each layer also adds some type of encapsulation to handle specific routing protocols.</p><figure><img alt="UDP encapsulation" src="https://cdn-images-1.medium.com/max/800/0*fDADcD2AN889aG4q.png" /></figure><p>We web developers usually don’t even think about what’s going on underneath our Application protocol. We send the message and get some kind of response back. It just works!</p><p>At the lowest levels, though, machines work in a “send and forget” mode. It’s just the nature of the links — we broadcast a signal via the wire or some remote signals, and we have no way to know if it reached the recipient. That is, unless the recipient sends some signal back to us.</p><p>This means that packets can get lost for quite many different reasons:</p><ul><li>the unreliable nature of the connection. For example, interference in your WiFi signal;</li><li>over-utilised devices. Routers, switches, and operating systems have buffers for queueing packets to be transmitted. If they overflow, packets get dropped. This way devices resume to normal operation right after the peak is gone;</li><li>very similarly — link congestion.</li></ul><p>To have a better abstraction (upon which we usually rely), TCP is used in the transport layer.</p><h4>TCP</h4><p>TCP adds the following features to our connection:</p><ul><li>1️⃣3️⃣2️⃣ ordered data transfer — we get the data in the same order we sent;</li><li>1️⃣💥3️⃣ retransmission of lost packets– we get all the data we sent;</li><li>1️⃣🐛3️⃣ error-free data transfer — if any bit was misinterpreted during the transfer, the packet gets retransmitted;</li><li>flow control and congestion control — the ability to control the rate of transmission.</li></ul><p>For this to work, TCP has stateful connections, which get opened and closed. Every packet sent also gets acknowledged by the receiver.</p><figure><img alt="TCP flow" src="https://cdn-images-1.medium.com/max/262/0*jsOqCWjzgBI32DXK.png" /></figure><p>What should also be noted is that the TCP congestion control mechanism includes a concept called slow-start. This means that in the beginning of the TCP connection, we can send up to 10 TCP packets, which usually amount up to 15 KB. Only after receiving 10 ACK can we send another 20 packets, and so on.</p><h4>UDP</h4><p>UDP is an alternative to TCP, which has practically nothing added on top of the Internet layer. No session initiation, no guarantees over delivery, no mechanisms for flow control.</p><p>The UDP header consists of the following fields:</p><ul><li>source port, which is optional;</li><li>destination port;</li><li>length;</li><li>checksum, which is also optional.</li></ul><figure><img alt="UDP flow" src="https://cdn-images-1.medium.com/max/207/0*No1oVsoVU3t_nzlU.png" /></figure><h4>TLS — security layer over HTTP</h4><p>TLS nowadays is an inseparable part of HTTP. You can get certificates for free, and if you don’t use TLS you get all those ⚠️ <strong>Insecure!</strong> warnings.</p><p>This is even the case with HTTP/3, in which TLS is mandatory. So let’s look at how it works, again, from the network perspective.</p><figure><img alt="TLS flow" src="https://cdn-images-1.medium.com/max/251/0*HO2cmSetw4gw2tAo.png" /></figure><p>TLS has a few options to make fewer round-trips — False Start and Session Resumption.</p><p>False Start does not affect the protocol or any data sent, only the timing itself — the client sends Application data as soon as it gets all data needed for calculating the encryption key. Unfortunately, some servers are poorly implemented and break when this is enabled. To tackle this issue, browsers use different strategies, but basically you need to use ALPN and choose cipher suite, enabling forward secrecy for False Start to work with your server.</p><p>Session Resumption uses session IDs to reuse previously exchanged parameters between the browser and the server.</p><h4>HTTP/1.0 vs HTTP/1.1 — keep-alive connections</h4><p>What was added to HTTP/1.1, in terms of network, was keep-alive connections.</p><p>Let’s take a look at how this affects a real-world scenario.</p><figure><img alt="HTTP/1.1 Keep-alive connection flow" src="https://cdn-images-1.medium.com/max/266/0*7WWxbOGMg88kIoYe.png" /></figure><p>The average number of resources loaded by a single web page is <a href="https://httparchive.org/reports/state-of-the-web">around 70</a>, so the whole initialisation for HTTP/1.0 would add-up quite a bit.</p><p>Note: Even for HTTP/1.1, make sure you’ve enabled keep-alive connections in your server.</p><p>Unfortunately, this has a particular flaw — you must wait for a full response to send a new request. This means that we need to choose between waiting for responses to send new requests or initialising new connections, which come at a cost, as you’ve just seen.</p><p>This exact problem was tackled with HTTP/2.</p><h4>HTTP/1.1 vs HTTP/2 — single TCP connection</h4><p>To both avoid TCP and TLS initialisations <strong>and</strong> to allow concurrent requests to be sent, HTTP/2 introduced “streams”. It uses a single TCP connection but brings abstraction on top, which allows to send requests and receive responses (among other things, like server push) over the same connection.</p><p>This is how it would look on the network level:</p><figure><img alt="HTTP/2 flow" src="https://cdn-images-1.medium.com/max/352/0*iiJCSpp0yIU3jw9I.png" /></figure><p>Unfortunately, this doesn’t work that well with all those nice TCP features when we get packet losses. TCP guarantees in-order delivery of every byte sent. This means that if at least one packet is lost, the whole TCP connection will hang until those get retransmitted.</p><p>In HTTP/2 abstraction this is unintended behavior, as packet loss usually affects only one request/response among many we receive in the same connection.</p><p>With unreliable connections, it might even mean that you can get better performance with HTTP/1.1 than with HTTP/2.</p><h4>HTTP/3 vs HTTP/2 — let’s drop TCP altogether!</h4><p>To tackle those problems, a new transport protocol — <strong>QUIC</strong> — was created. It works over UDP and basically re-implements all the features provided by TCP on top of it.</p><p>What’s different from TCP is that QUIC supports streams — exactly what’s needed for HTTP/3 concurrent requests and responses. Streams are delivered in-order and they are reliable, but different streams may be delivered out-of-order.</p><p>It also has some other nice features:</p><ul><li>Connection ID, which allows you to resume your download even when your network connection (and IP) has changed;</li><li>QUIC always uses TLS 1.3 🔒. No other options of TLS, no option to send plain text;</li><li>as TLS 1.3 is used, data could be sent right after the first round-trip or even with the first packet if a cached secret exists from a previously established connection.</li></ul><p>To see the impact on the network level, this shows a situation where this would matter with HTTP/2:</p><p>With QUIC, the logo could be displayed as soon as it’s received — streams (separate responses) don’t block each other.</p><p>The HTTP/3 protocol itself is practically just a re-definition of HTTP/2 using QUIC streams for transport. It has a few other differences which are mostly just implementation details.</p><h4>Discovering an HTTP/3 Endpoint</h4><p>As HTTP/3 uses UDP instead of TCP, a browser cannot just negotiate the protocol after the connection is made to the server.</p><p>This means that our HTTP/2 or HTTP/1.1 server must provide the data about our server’s HTTP/3 availability.</p><p>For this, the Alt-svc: HTTP response header or ALT-SVC HTTP/2 response frame is used with the protocol, port, and optional host provided:</p><pre>Alt-Svc: h3-23=&quot;:443&quot;; ma=86400</pre><p>In this example, the server tells you that on the same host, 443 port (using UDP protocol), you can find draft 23 of the HTTP/3 protocol available. Also, forget this information after 24 hours.</p><h4>QUIC gotchas</h4><p>Unfortunately, there are some issues that are still to be solved to successfully use the UDP protocol for such functionality:</p><ul><li>UDP is slow. Wait, what?! What I mean is, it makes things quicker in theory and — in most cases — in terms of network. But in kernels, UDP eats CPU for breakfast and is relatively slow. Well, at least compared to TCP. This could be due to a lack of interest from developers, so we can hope that it will improve;</li><li>as UDP is used in DOS attacks, many enterprises block UDP traffic on non-53 port (which is used for DNS). To make matters even worse, some of them throttle UDP packets, making QUIC slower than TCP;</li><li>QUIC does not completely use TLS1.3, it reuses its parts. This means that most crypto libs did not have the needed interfaces. This could potentially mean dependency hell, as any QUIC client or server would either require the newest crypto lib or should bring one included with the application.</li></ul><h4>Testing and deploying</h4><p>At this moment, there aren’t any official releases, neither for popular servers nor client software.</p><p>This is quite natural, as HTTP/3 is itself still a draft — it could change a bit until fully confirmed.</p><p>CloudFlare, on the other hand, allows to turn on HTTP/3 (its draft version) with a simple toggle, even when using free plans.</p><p>They also <a href="https://blog.cloudflare.com/http3-the-past-present-and-future/#http-3-powered-by-a-delicious-quiche">provide instructions</a> for compiling cURL and nginx with QUIC support, if you’re really eager to try it out yourself.</p><h4>A note on how protocols are born nowadays</h4><p>Google. This company has reached a state where they:</p><ul><li>have the most visited servers in the world;</li><li>develop the most popular browser in the world;</li><li>have enough development resources;</li><li>have a scale where it’s worth changing the world to improve performance at least a tiny bit for each user. Well, their users add up to quite big gains.</li></ul><p>In fact, the QUIC protocol was not just thought of and implemented by Google, it was already used by 7% of internet traffic in 2017. Afterwards, in 2018, Google presented the protocol to IETF for standardisation. In other words, you’re already using almost-HTTP/3 every day for years now.</p><p>Very similarly HTTP/2 was born out of another Google protocol — SPDY.</p><p>Such a situation could scare a bit, but it also makes for a really big sandbox for Google to test, iterate and improve on such widely used protocols. Otherwise, it would be much more difficult to include many parties, test, gather all the information, and agree on improvement strategies. Thanks, Google!</p><h4>Further references</h4><p>If you want to get into more details about HTTP/3, I highly recommend <a href="https://http3-explained.haxx.se/en/">HTTP/3 explained</a>.</p><p>To dig deep into the network layer and performance optimisation — don’t miss <a href="https://hpbn.co/">High Performance Browser Networking</a>.</p><p>You can find all drafts of the protocol on the official <a href="https://quicwg.org/">QUIC working group page</a>.</p><p>Originally published at <a href="https://paysera.engineering/http-3">paysera.engineering</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d42944538738" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paysera-engineering/http-3-lets-speed-the-web-once-more-d42944538738">HTTP/3 — let’s speed the web once more</a> was originally published in <a href="https://medium.com/paysera-engineering">Paysera Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customizing Gatsby]]></title>
            <link>https://medium.com/paysera-engineering/customizing-gatsby-8da155f0c872?source=rss-8af8950d32d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8da155f0c872</guid>
            <category><![CDATA[gatsby]]></category>
            <dc:creator><![CDATA[Marius Balčytis]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 14:44:35 GMT</pubDate>
            <atom:updated>2019-03-18T14:51:03.314Z</atom:updated>
            <content:encoded><![CDATA[<p>If one of many templates to choose from is good enough for you — way to go!</p><p>Otherwise, it takes some deeper knowledge in JavaScript, Gatsby internals, React and a bit of GraphQL for customizing the functionality.</p><p>I will describe the changes we made in a bit of detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiRJnxxtfBaRhvKoF9tPmQ.png" /></figure><h4>Bootstrapping and customizing</h4><p>This blog was based on <a href="https://github.com/greglobinski/gatsby-starter-hero-blog">HeroBlog</a> Gatsby starter.</p><p>It provides a nice design, quite a few features, including our needed features — a blog with several static pages in the menu.</p><p>If the template has all features you need, it’s usually enough to customize some JSON files, find and replace some texts in the templates (no extra knowledge is needed) and provide content in markdown.</p><p>In cases where you want to extend the functionality, you’ll need to change the React components (templates), tweak GraphQL queries for data extraction and possibly write some code for Node to propagate that data.</p><p>Basically, Gatsby works as follows:</p><ul><li>you have your data model. It’s usually propagated by standard plugins and static files, but you can also change the data propagation behavior in gatsby-node.js. Plugin configuration, like where to look for static files, is located in gatsby-config.js. For example, your markdown files in the repository, using plugins, become part of your data model;</li><li>in your pages, GraphQL queries are provided to select appropriate fields from your data model;</li><li>this data is passed to React components, which render the pages.</li></ul><p>It’s quite straight-forward when you get the hand of it, but it might take some time to get used to GraphQL and React, if you haven’t yet.</p><h4>What we’ve changed</h4><p>We’ve made several different types of changes:</p><ul><li>customizing the template and configuration;</li><li>installing plugins;</li><li>extending available data structures and adding new features — custom author for each post and multiple tag support;</li><li>adding script for workflow customization — cross posting to Medium.</li></ul><h4>Installing plugins</h4><p>Gatsby has quite a lot <a href="https://www.gatsbyjs.org/plugins/">plugins to choose from</a>.</p><p>Many of them will probably be pre-installed by your chosen starting template — in our case, there were 24 of them.</p><p>Using plugins, you can add transformers (different format support as your data), extend functionality with search, analytics and other tools, add elements with a functionality like pagination and similar.</p><p>We’ve additionally installed <a href="https://www.gatsbyjs.org/packages/gatsby-remark-reading-time/">gatsby-remark-reading-time</a> and included estimated time to read the blog post.</p><p>You can check this out in <a href="https://github.com/paysera/app-engineering-blog/commit/bea65a9e85f5da23716b77e05c71088c77f8f9d8">the commit that added this feature</a>.</p><h4>Adding author support for blog posts</h4><p>Default templates usually place one pre-configured author everywhere. For our use-case, we need to easily customize the author for each post.</p><p>Intended behavior: 1. We put each author’s information in separate markdown document:</p><pre>content<br>└── authors<br>    └── j.cash.md<br>    └── e.presley.md</pre><ol><li>We include basic information in the <em>frontmatter</em> and author’s description in the body:</li></ol><pre>---<br>avatar: https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Elvis_Presley_promoting_Jailhouse_Rock.jpg/440px-Elvis_Presley_promoting_Jailhouse_Rock.jpg<br>name: Elvis Presley<br>---<br><br>Some things are meant to be<br><br>Take my hand, take my whole life too<br><br>For I can&#39;t help falling in love with you</pre><ol><li>In the post itself, we only provide the username of the author in the <em>frontmatter</em>:</li></ol><pre>---<br>title: Blog title<br>cover: cover.png<br>author: e.presley<br>---<br><br>Blog post contents</pre><p>We expect the following result in the suffix of the post:</p><p>In the post list and post header we also expect to see the name of the author, Elvis Presley in this case.</p><h4>Making this happen</h4><p>First of all, we need to make Gatsby read the contents of authors/ folder. This is done by adding a new plugin configuration in gatsby-config.js:</p><pre>{<br>        resolve: &#39;gatsby-source-filesystem&#39;,<br>        options: {<br>            name: &#39;authors&#39;,<br>            path: `${__dirname}/content/authors/`<br>        }<br>    },</pre><p>In this case, it was important to add this before /content/posts/ folder configuration – we make an assumption later on that we get authors before the posts. This allows to fill in the author data in the posts within a single loop.</p><p>This change would already allow us to get all available authors in our pages using GraphQL. In this case, we also need the username, which is in the filename, and to add the author data to the posts themselves for easier manipulation later on. To populate this data, changes to the gatsby-node.js are needed:</p><pre>// ...<br>const users = {};<br>exports.onCreateNode = ({ node, getNode, actions }) =&gt; {<br>    const { createNodeField } = actions;<br>    if (node.internal.type !== &#39;MarkdownRemark&#39;) {<br>        return;<br>    }<br>    <br>    const slug = createFilePath({ node, getNode });<br>    const fileNode = getNode(node.parent);<br>    const source = fileNode.sourceInstanceName;<br><br>    if (source === &#39;authors&#39;) {<br>        // add `username` field with filename (trim `/` from left and right)<br>        const username = slug.replace(/^\/|\/$/g, &#39;&#39;);<br>        createNodeField({<br>            node,<br>            name: &#39;username&#39;,<br>            value: username<br>        });<br>        users[username] = node;<br>    }<br>    // ...<br>    if (node.frontmatter &amp;&amp; node.frontmatter.author) {<br>        // for posts, add `author` field with the data<br>        createNodeField({<br>            node,<br>            name: &#39;author&#39;,<br>            value: users[node.frontmatter.author]<br>        });<br>    }<br>    // ...<br>};</pre><p>We can restart npm run develop process and take a look at /___graphql if the data is propagated correctly:</p><pre>query {<br>    authors: allMarkdownRemark(filter: {fields: {source: {eq: &quot;authors&quot;}}}) {<br>        edges {<br>            node {<br>                html<br>                fields {<br>                    username<br>                }<br>                frontmatter {<br>                    avatar<br>                    name<br>                }<br>            }<br>        }<br>    }<br>    post: markdownRemark(fields: {source: {eq: &quot;posts&quot;}}) {<br>        fields {<br>            author {<br>                frontmatter {<br>                    name<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>We see the expected result:</p><pre>{<br>    &quot;data&quot;: {<br>        &quot;authors&quot;: {<br>            &quot;edges&quot;: [<br>                {<br>                    &quot;node&quot;: {<br>                        &quot;html&quot;: &quot;&lt;p&gt;Something about Johnny&lt;/p&gt;&quot;,<br>                        &quot;fields&quot;: {<br>                            &quot;username&quot;: &quot;j.cash&quot;<br>                        },<br>                        &quot;frontmatter&quot;: {<br>                            &quot;avatar&quot;: &quot;https://johnny.com/avatar.png&quot;,<br>                            &quot;name&quot;: &quot;Johnny Cash&quot;<br>                        }<br>                    }<br>                },<br>                {<br>                    &quot;node&quot;: {<br>                        &quot;html&quot;: &quot;&lt;p&gt;Some things are meant to be&lt;/p&gt;...&quot;,<br>                        &quot;fields&quot;: {<br>                            &quot;username&quot;: &quot;e.presley&quot;<br>                        },<br>                        &quot;frontmatter&quot;: {<br>                            &quot;avatar&quot;: &quot;https://upload.wikimedia.org/...Jailhouse_Rock.jpg&quot;,<br>                            &quot;name&quot;: &quot;Elvis Presley&quot;<br>                        }<br>                    }<br>                }<br>            ]<br>        },<br>        &quot;post&quot;: {<br>            &quot;fields&quot;: {<br>                &quot;author&quot;: {<br>                    &quot;frontmatter&quot;: {<br>                        &quot;name&quot;: &quot;Elvis Presley&quot;<br>                    }<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>Unfortunately, adding author as a field does not populate html property – it&#39;s populated only for root elements when using markdownRemark and similar queries.</p><p>To get the description, we have to query all the authors in each post and filter them out manually by current context. In PostTemplate.js:</p><pre>export const postQuery = graphql`<br>    query PostBySlug($slug: String!) {<br>        post: ...<br>        authors: allMarkdownRemark(filter: {fields: {source: {eq: &quot;authors&quot;}}}) {<br>            edges {<br>                node {<br>                    html<br>                    frontmatter {<br>                        name<br>                        avatar<br>                    }<br>                    fields {<br>                        username<br>                    }<br>                }<br>            }<br>        }<br>    }<br>`;<br><br>const { data: { authors, post } } = props;<br>const authorNode = authors.edges.find(a =&gt; a.node.fields.username === post.frontmatter.author);<br>const author = authorNode ? authorNode.node : undefined;<br><br>// use author – pass to components where needed</pre><p>If we just need the author’s name, we don’t have to query it manually — it’s available inside post.fields.author.frontmatter.name.</p><p>What’s left is just to display the data inside the components where needed.</p><p>You can see all the needed changes for this feature in <a href="https://github.com/paysera/app-engineering-blog/commit/fd8ece6a408ec5050597cc4f388237cc3131e425">this commit</a>.</p><h4>Adding support for many tags for each post</h4><p>Originally, the starter only supported a single category for each post. We’ve added multiple tag support to each post to have a bit more dynamic approach.</p><p>Tag feature consists of the following parts:</p><ul><li>tags for each post are defined in the <em>frontmatter</em>;</li><li>tags are displayed with each post with a link to all posts with the same tag;</li><li>there’s a page with all available tags;</li><li>each tag has it’s own page with all posts tagged with it.</li></ul><p>When adding array elements in the <em>frontmatter</em>, you need to remember that it’s actually YAML in that place. So, you can define them in any of the following ways:</p><pre>---<br>tags: [&quot;something&quot;, &quot;something else&quot;]   # JSON-style<br>---</pre><pre>---<br>tags: [something, something else]       # inlined<br>---</pre><pre>---<br>tags:                                   # split into several lines<br>    - something<br>    - something else<br>---</pre><p>This, on the other hand, would not work:</p><pre>---<br>tags: something, something else<br>---</pre><p>It would be treated as a string &quot;something, something else&quot;.</p><p>Making tags displayed with the post was quite straightforward at this point — we extend GraphQL query to include new field inside <em>frontmatter</em> and pass it down to the components.</p><p>Adding a page (for list of tags) is done by creating .js file inside pages/ folder. It was based on previously available category page, otherwise you&#39;d need to write GraphQL query for extracting data and React component which receives that data as a property.</p><p>Adding specific pages dynamically (for each tag) is done in gatsby-node.js file (just like modifying our data for custom author support):</p><pre>exports.createPages = ({graphql, actions}) =&gt; {<br>    const {createPage} = actions;<br><br>    return new Promise((resolve, reject) =&gt; {<br>        const tagTemplate = path.resolve(&quot;./src/templates/TagTemplate.js&quot;);<br><br>        resolve(<br>            graphql(`<br>                {<br>                    allMarkdownRemark {<br>                        edges {<br>                            node {<br>                                frontmatter {<br>                                    tags<br>                                }<br>                            }<br>                        }<br>                    }<br>                }<br>            `).then(result =&gt; {<br>                const items = result.data.allMarkdownRemark.edges;<br><br>                // Needed as tags are repeated, but we should create page once<br>                const tagSet = new Set();<br>                items.forEach(edge =&gt; {<br>                    const {<br>                        node: {<br>                            frontmatter: { tags }<br>                        }<br>                    } = edge;<br><br>                    (tags || []).forEach(tag =&gt; tagSet.add(tag));<br>                });<br><br>                // Create tag pages<br>                tagSet.forEach(tag =&gt; {<br>                    createPage({<br>                        path: `/tag/${_.kebabCase(tag)}/`,<br>                        component: tagTemplate,<br>                        context: {<br>                            tag<br>                        }<br>                    });<br>                });<br>            })<br>        );<br>    });<br>};</pre><p>The page logic itself resides in TagTemplate.js, which is again a GraphQL query with a React component.</p><p>The context which is passed when creating page is available both as pageContext property and as parameters in GraphQL query:</p><pre>export const tagQuery = graphql`<br>    query PostsByTag($tag: String) {<br>        allMarkdownRemark(<br>            filter: { frontmatter: { tags: { eq: $tag } } }<br>        ) {<br>            edges {<br>                node {<br>                    fields {<br>                        slug<br>                    }<br>                    frontmatter {<br>                        title<br>                    }<br>                }<br>            }<br>        }<br>    }<br>`;</pre><p>As you can notice, we can use $tag parameter to filter our data – it&#39;s because we pass tag in the context when creating a page.</p><p>You can see all the needed changes for this feature in <a href="https://github.com/paysera/app-engineering-blog/commit/4ca375ca213022a172bd03b65ee6ee3349167995">this commit</a>.</p><h4>Cross-posting to Medium</h4><p>To cross-post to Medium we’ve integrated script from <a href="https://cmichel.io/how-to-crosspost-to-medium/">Christoph Michel blog post</a>.</p><p>Some modifications &amp; differences:</p><ul><li>we’ve created a Publication in Medium as we have different authors in our blog;</li><li>we don’t have slug or medium fields in <em>frontmatter</em> – we use tags and build a slug from the title;</li></ul><p>Originally published at <a href="https://paysera.engineering/customising-gatsby/">engineering.paysera.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8da155f0c872" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paysera-engineering/customizing-gatsby-8da155f0c872">Customizing Gatsby</a> was originally published in <a href="https://medium.com/paysera-engineering">Paysera Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[So, we’ve started to write a blog]]></title>
            <link>https://medium.com/paysera-engineering/so-weve-started-to-write-a-blog-83f54f078e76?source=rss-8af8950d32d------2</link>
            <guid isPermaLink="false">https://medium.com/p/83f54f078e76</guid>
            <dc:creator><![CDATA[Marius Balčytis]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 14:38:57 GMT</pubDate>
            <atom:updated>2019-03-18T14:51:26.033Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve had this idea to start a blog for quite some time now. Procrastination was our friend for a long period, but here we are!</p><p>With this intro post, I’ll provide some background info about future contents of this blog, but will also go deeper into the technical decisions we’ve made here.</p><p>Basically it could help you to get started with your own blog if you’d be up for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KNzu4NC0pd4yi59dYXrcg.png" /></figure><h4>So, what we’re up to?</h4><p>Paysera provides payment-related services — we offer multi-currency banking accounts to our clients for various transfers, we have a payment gateway, solutions for retailers, various API integrations, mobile applications.</p><p>When working on a product (especially long-term one with complex business logics) much effort is invested in infrastructure, reusable components, effective development processes, constant improvement in technical and personal spaces. It also requires custom or tailored solutions quite often.</p><p>That’s exactly why we think we can share some of our experience!</p><h4>Idea for the blog</h4><p>Before getting into technical things, we’ve set some basic needs for our case:</p><ul><li>we want to post (or cross-post) to <a href="https://medium.com/">Medium</a> as it’s getting de-facto place to read technical articles for many developers. The alternative would be LinkedIn articles or some other place in cloud services;</li><li>we also want to have all of our blog posts in a single place — this is for those who want to get to know us a little better for whatever reason. In the same place, we’d like to have our publicly shared view on the processes, conventions and other development-related things. For this type of information, blog posts are usually not the best idea.</li></ul><p>If you don’t have those needs, Medium or similar platform could be the best option — it’s ready to go whenever you are, you get exposure for free and don’t get obligated to write posts very frequently. It’s perfectly ok to just write a single post and then decide that it’s not for you at all. 😉</p><h4>Choosing a technical base for the blog</h4><p>Basically, there was a few options to consider:</p><ul><li>to go with the classical approach — WordPress;</li><li>to go with something similar to WordPress — with web UI and database;</li><li>to build something of our own. No, we don’t like to invent the bicycle, but let’s be honest — we, developers, always think this option through, even with the most standard decisions;</li><li>use static site generator 🎉</li></ul><p>The last option bought us in real quickly without even giving second thoughts:</p><ul><li>all of the content is in repository, with version control integration, reviews, clear understanding what goes where;</li><li>content editing is via markdown, not some online editor;</li><li>it allows to extend everything in a controllable manner — installing extensions, configuring etc. inside our IDE, not browser.</li></ul><p>In other words, this might not be the best option for everyone, but it seemed to be a perfect option for the developers.</p><h4>Choosing static site generator</h4><p>There were also a few alternatives to consider:</p><ul><li><a href="https://github.com/jekyll/jekyll">Jekyll</a> — made with Ruby, still the most popular (by ⭐), older than the others on this list;</li><li><a href="https://github.com/gohugoio/hugo">Hugo</a> — made with Go, really fast site generation;</li><li><a href="https://github.com/gatsbyjs/gatsby">Gatsby</a> — made with JavaScript to be used with React. Allows to use React components besides just the static content.</li></ul><p>As we use React internally and have the most experience with JavaScript, we went with Gatsby.</p><p>Otherwise, if you haven’t tried React, learning curve could be quite steep if you’d like to modify anything in your templates or site generation logic.</p><h4>Bootstrapping and customizing</h4><p>This blog was based on <a href="https://github.com/greglobinski/gatsby-starter-hero-blog">HeroBlog</a> Gatsby starter.</p><p>It provides nice design, quite a few features, including our needed features — a blog with several static pages in the menu.</p><p>We’ve also made some customization and added several small features on top of it — you can read more about it in the next blog post.</p><p>Originally published at <a href="https://paysera.engineering/so-weve-started-to-write-a-blog/">engineering.paysera.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83f54f078e76" width="1" height="1" alt=""><hr><p><a href="https://medium.com/paysera-engineering/so-weve-started-to-write-a-blog-83f54f078e76">So, we’ve started to write a blog</a> was originally published in <a href="https://medium.com/paysera-engineering">Paysera Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>