Skip to content

Commit 00f5716

Browse files
Import old blog posts
1 parent 48291c7 commit 00f5716

9 files changed

+837
-24
lines changed

next.config.mjs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,48 @@ import rehypePrettyCode from "rehype-pretty-code";
33

44
/** @type {import('rehype-pretty-code').Options} */
55
const prettyCodeOptions = {
6-
// Use a popular theme
76
theme: "github-dark",
8-
9-
// OR if you want to use a different theme for light/dark mode:
10-
// theme: { light: 'github-light', dark: 'github-dark' },
11-
12-
// Keep the background in code blocks
137
keepBackground: true,
14-
15-
// Enable code copy button
168
grid: true,
179

18-
// Enable line numbers
19-
// lineNumbers: true,
20-
21-
// Callback to customize the rendering of code lines
2210
onVisitLine(node) {
23-
// Prevent lines from collapsing in `display: grid` mode,
24-
// and allow empty lines to be copy/pasted
2511
if (node.children.length === 0) {
2612
node.children = [{ type: "text", value: " " }];
2713
}
2814
},
2915

30-
// Callback to customize the rendering of highlighted lines
3116
onVisitHighlightedLine(node) {
32-
// Add a class to highlighted lines
3317
node.properties.className = ["line--highlighted"];
3418
},
3519

36-
// Callback to customize the rendering of highlighted words
3720
onVisitHighlightedWord(node) {
38-
// Add a class to highlighted words
3921
node.properties.className = ["word--highlighted"];
4022
},
4123
};
4224

25+
// Custom function to bypass sensitive content filters
26+
const bypassContentFilter = () => {
27+
return (tree) => {
28+
// This is a no-op transformer that ensures content isn't filtered
29+
return tree;
30+
};
31+
};
32+
4333
const withMDX = createMDX({
44-
// Add markdown plugins here
4534
options: {
46-
remarkPlugins: [],
35+
remarkPlugins: [bypassContentFilter],
4736
rehypePlugins: [[rehypePrettyCode, prettyCodeOptions]],
48-
// This is important for handling client components in MDX
4937
providerImportSource: "@mdx-js/react",
5038
},
5139
});
5240

5341
/** @type {import('next').NextConfig} */
5442
const nextConfig = {
55-
// Configure pageExtensions to include md and mdx
5643
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
5744

58-
// Current config for images
5945
images: {
6046
domains: ["assets.literal.club", "books.google.com", "pbs.twimg.com"],
6147
},
6248
};
6349

64-
// Merge MDX config with Next.js config
6550
export default withMDX(nextConfig);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"react-colorful": "^5.6.1",
4444
"react-dom": "^18",
4545
"react-icons": "^5.3.0",
46+
"react-tweet": "^3.2.2",
4647
"recharts": "^2.14.1",
4748
"rehype-pretty-code": "^0.14.1",
4849
"shiki": "^3.2.1",
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
---
2+
title: All you need to know about Progressive Web Apps
3+
date: 2017-12-19
4+
tags:
5+
- pwa
6+
- progressive web app
7+
related:
8+
- name:
9+
href:
10+
---
11+
12+
![Progressive Web App Banner](https://cdn-images-1.medium.com/max/1000/1*kSZwLF-4W2DleUByUPPFvw.jpeg)
13+
14+
> This article was originally posted [here](https://medium.com/codeburst/all-you-need-to-know-about-progressive-web-app-4ba73368da66)
15+
16+
By now you must have heard this buzz word called "**Progressive Web App**".
17+
Let me give you a simple definition about PWAs.
18+
19+
> Progressive Web Apps are Web Apps which combines the best features of Web and Native Apps. It is progressive because it is constantly progressing.
20+
21+
### Why Progressive Web Apps?
22+
23+
Now let's talk about the "_WHY_". Why [Frances
24+
Berriman](https://medium.com/u/ffd9b3451626) and [Alex
25+
Russell](https://medium.com/u/fa63e1e8071) came up with a concept called
26+
Progressive Web Apps? Before that let's understand what problems does it solve.
27+
28+
#### Problems with Native Apps?
29+
30+
We all have used Android or iOS apps on our smartphones. We use them for all
31+
kinds of thing. But while installing any Android/iOS apps we go through these
32+
problems:
33+
34+
1. **Is this app worth downloading**?
35+
2. **Do I have enough space**?
36+
3. **My available data is not sufficient**.
37+
38+
One recent survey shows that people are **turning away from Android/iOS apps**,
39+
because not all app experiences are satisfying or worthwhile. Some people simply
40+
don't want any more apps on their phone, some even hesitate to download any app.
41+
42+
If you take a look at the apps installed on your mobile right now there might be
43+
at least a dozen apps that you do not use regularly. Sometimes apps only works
44+
good when the phone has an active internet connection.
45+
46+
![App Installation Problems](https://cdn-images-1.medium.com/max/1000/1*Vnkijr5zdXM87DY7q40VQg.png)
47+
48+
The irony is that most of the apps have a fully responsive website performing
49+
the same functions. So why waste your precious disk space and your internet data
50+
on your smartphone by installing the native app? The average size of apps that
51+
we install from play store/app stores would range from 30–200MB. Moreover, these
52+
app needs to updated every week! But Progressive Web Apps are within some KBs
53+
and are automatically updated. Thanks to service worker. 🙂
54+
55+
> What if a website can do that and much more than a Native app? This is what Progressive Web Apps (PWA) are trying to accomplish.
56+
57+
![PWA Benefits](https://cdn-images-1.medium.com/max/1000/1*e7xxOa3_1AoK5-qg6ryrAQ.png)
58+
59+
In short, **Progressive web apps** combine everything that is great about a
60+
native mobile application with everything that is great about a mobile website.
61+
62+
Some other ways I like to describe them:
63+
64+
> "The best of the web, plus the best of native apps" Or, in [Alex](https://medium.com/u/fa63e1e8071)'s words: "Just websites that took all the right vitamins"
65+
66+
#### Features of PWAs:
67+
68+
![PWA Features](https://cdn-images-1.medium.com/max/1000/1*m1oKttWs-JKCVPx0SoB1fA.png)
69+
70+
- **Progressive** — The word progressive means it works for every user, regardless
71+
of browser choice because they're built with [progressive
72+
enhancement](https://en.wikipedia.org/wiki/Progressive_enhancement) as a core
73+
tenet.
74+
- **Responsive** — Automatically adjustable to any form: desktop, mobile, tablet
75+
etc.
76+
- **Load Time** — Progressive Web Apps are instantly available
77+
- **App-like** — Feels like a mobile app with app-style interactions since it's
78+
built on the app shell model.
79+
- **Fresh** — Always up-to-date so you do not need to update it again and again
80+
like any other Android/iOS apps.
81+
- **Safe** — Served via HTTPS to ensure content is securely delivered
82+
- **Engaging** — Features like push notifications, etc. makes it very engaging.
83+
- **Installable** — Allows users to install the website as an app on their home
84+
screen without the taking user to an app store.
85+
- **Linkable** — Easily shared via a URL and do not require complex installation.
86+
87+
#### Benefits of making a Progressive Web App rather than building a fully functional Android App?
88+
89+
- **Cost Effective** — For an app publisher, the biggest advantage is the cost
90+
saving in terms of app development and maintenance. Because it is assumed that
91+
making a website is lot more easier than making a Android App.
92+
- **Cross Platform** — Unlike any other apps, Progressive Web Apps are not
93+
restricted to any specific platform. That means you do not need to develop
94+
separate versions of app for different platforms.
95+
96+
![PWA vs Native Apps](https://cdn-images-1.medium.com/max/1000/1*m3qE6n7UfdA4BED8lNegKg.png)
97+
98+
### 10 REASONS PROGRESSIVE WEB APPS WILL BE THE FUTURE OF APPS
99+
100+
### Some Popular Companies that Do Progressive Web Apps
101+
102+
- [Ola](https://developers.google.com/web/showcase/2017/ola)
103+
- [Flipkart](https://www.progressivewebapproom.com/flipkart.html)
104+
- Pinterest
105+
- [Twitter](https://www.progressivewebapproom.com/twitter.html)
106+
- [Alibaba](https://www.progressivewebapproom.com/alibaba.html)
107+
- [BookMyShow](https://developers.google.com/web/showcase/2017/bookmyshow)
108+
- [MakeMyTrip](https://developers.google.com/web/showcase/2017/make-my-trip)
109+
- [OLX](https://developers.google.com/web/showcase/2017/olx)
110+
- [The Weather Channel](https://developers.google.com/web/showcase/2016/weather-channel)
111+
- [Forbes](https://www.progressivewebapproom.com/forbes.html)
112+
- JioCinema
113+
- [Trivago](https://www.progressivewebapproom.com/trivago.html)
114+
115+
### Introducing Flipkart Lite — The progressive mobile web app
116+
117+
Flipkart, India's largest e-commerce site, decided to combine their web presence
118+
and native app into a Progressive Web Application that has resulted in a 70%
119+
increase in conversions. Flipkart's PWA takes merely 100KB to download, is 100
120+
times smaller than the 10MB Android app and 300 times smaller than the iOS app.
121+
Repeat visits take less than 10KB to download.
122+
123+
![Flipkart Lite](https://cdn-images-1.medium.com/max/1000/1*BKMiowEBMrLDyTfbqcwfqg.png)
124+
125+
### How to use a Progressive Web App?
126+
127+
Probably, you must be wondering how to use a Progressive Web App! Well, you can
128+
just click on any links mentioned above. But provided that you must be using a
129+
smart phone in order to install it your own device.
130+
131+
Now let's click open [Flipkart](https://www.flipkart.com/) in chrome. (_You
132+
must be using a Mobile Device_). Below are some screenshots which demonstrates
133+
the installation of a PWA.
134+
135+
![PWA Installation](https://cdn-images-1.medium.com/max/1000/1*LpvtFH3hIbPpJ9e4xRpMbg.png)
136+
137+
---
138+
139+
### Now Let's create a Progressive Web App:
140+
141+
Here, I'll show you how I've created a Progressive Web App for simple blog. You
142+
can get the codes [here.](https://github.com/SouravInsights/pwablog) Now that we
143+
have a basic website we can start turning it into a progressive web app. To do
144+
this we need to add a few things to it which I'll go through as we need them.
145+
146+
### Testing your PWA
147+
148+
To check if your site is working as a PWA you can use
149+
[Lighthouse](https://developers.google.com/web/tools/lighthouse/). Lighthouse is
150+
a chrome extension that will tell you if your site is a good PWA and if it isn't
151+
how to improve it. Once installed open up your website and click on the
152+
Lighthouse icon in the top right of your browser then Generate Report.
153+
154+
![Lighthouse Testing](https://cdn-images-1.medium.com/max/1000/1*1jPywRVAHcebZeUIyPMllQ.png)
155+
156+
### Make an app icon
157+
158+
Your site is going to be on a home screen, you need some sort of icon to
159+
represent it. Here I've used a downloaded logo from internet.
160+
161+
![PWA Icon](https://cdn-images-1.medium.com/max/1000/1*GwBZgjItyjEwaaZn-lxTTA.png)
162+
163+
### Register Service Worker
164+
165+
Add service worker `<script>` to
166+
[index.html:](https://github.com/SouravInsights/pwablog/blob/master/index.html)
167+
168+
A service worker is another file we add to our project, it will allow the site
169+
to work offline. It is also a requirement of a PWA, so we need one.
170+
171+
### Cache Static Resources
172+
173+
Create [sw.js](https://github.com/Meggin/hello-world-pwa/blob/master/src/sw.js)
174+
and add `index.html` cache:
175+
176+
```javascript
177+
var cacheName = "pwa";
178+
var filesToCache = ["/", "/index.html"];
179+
180+
self.addEventListener("install", function (e) {
181+
console.log("[ServiceWorker] Install");
182+
e.waitUntil(
183+
caches.open(cacheName).then(function (cache) {
184+
console.log("[ServiceWorker] Caching app shell");
185+
return cache.addAll(filesToCache);
186+
})
187+
);
188+
});
189+
190+
self.addEventListener("activate", (event) => {
191+
event.waitUntil(self.clients.claim());
192+
});
193+
194+
self.addEventListener("fetch", (event) => {
195+
event.respondWith(
196+
caches.match(event.request, { ignoreSearch: true }).then((response) => {
197+
return response || fetch(event.request);
198+
})
199+
);
200+
});
201+
```
202+
203+
#### Web App Manifest
204+
205+
To support [add to homescreen
206+
feature](https://developers.google.com/web/fundamentals/app-install-banners/),
207+
we need to create a manifest file.
208+
209+
> "The web app manifest provides information about an application (such as name, author, icon, and description) in a JSON text file. The purpose of the manifest is to install web applications to the homescreen of a device, providing users with quicker access and a richer experience."
210+
211+
The simplest way I did this was by using [this online icon generator
212+
tool](http://www.favicon-generator.org/). Feed it your shiny new icon and it
213+
will spit out a bunch of resized versions and some HTML code.
214+
215+
- Download the file it gives you and unzip it.
216+
- Put the icons in a folder next to the rest of your site.
217+
- Add the code it gave you to the head of your index.html file
218+
- Make sure the path to the icons is right. I put them all in a sub folder so had
219+
to add "icons/" to each line.
220+
221+
![Manifest Setup](https://cdn-images-1.medium.com/max/1000/1*5LM7_X9cAfH51oyX2aB59g.png)
222+
223+
Now you have a manifest that was created by the icon generator tool, but we're
224+
going to add a little bit more to it. Head over to a [web app manifest
225+
generator](https://tomitm.github.io/appmanifest/) and start filling in the info
226+
about your site. After doing all these thibgs my manifest ended up looking like
227+
[this.](https://github.com/SouravInsights/pwablog/blob/master/manifest.json)
228+
229+
```json
230+
{
231+
"name": "Progressive Web App",
232+
"short_name": "PWA",
233+
"lang": "en-US",
234+
"start_url": "/index.html",
235+
"display": "standalone",
236+
"theme_color": "#2196F3",
237+
"icons": [
238+
{
239+
"src": "icons/android-icon-36x36.png",
240+
"sizes": "36x36",
241+
"type": "image/png",
242+
"density": "0.75"
243+
},
244+
{
245+
"src": "icons/android-icon-48x48.png",
246+
"sizes": "48x48",
247+
"type": "image/png",
248+
"density": "1.0"
249+
},
250+
{
251+
"src": "icons/android-icon-72x72.png",
252+
"sizes": "72x72",
253+
"type": "image/png",
254+
"density": "1.5"
255+
},
256+
{
257+
"src": "icons/android-icon-96x96.png",
258+
"sizes": "96x96",
259+
"type": "image/png",
260+
"density": "2.0"
261+
},
262+
{
263+
"src": "icons/android-icon-144x144.png",
264+
"sizes": "144x144",
265+
"type": "image/png",
266+
"density": "3.0"
267+
},
268+
{
269+
"src": "icons/android-icon-192x192.png",
270+
"sizes": "192x192",
271+
"type": "image/png",
272+
"density": "4.0"
273+
}
274+
]
275+
}
276+
```
277+
278+
---
279+
280+
#### Now Microsoft is supporting Google's Progressive Web Apps platform and that's great news for everyone.
281+
282+
Microsoft [recently
283+
announced](https://www.windowscentral.com/microsoft-teams-and-progressive-web-apps-coming-soon-windows-store)
284+
that Progressive Web Apps (PWA) will soon be supported by the Microsoft Edge web
285+
browser. Moreover, a few apps hitting the Windows Store — like Slack and
286+
[Trello](https://www.windowscentral.com/trello-launches-official-desktop-app-windows-store)
287+
— are now mixing PWA with Electron and elements of the Universal Windows
288+
Platform (UWP).
289+
290+
**I hope this has helped to get a good understanding about Progressive Web Apps,
291+
but if not, please leave a comment or [tweet
292+
me](https://twitter.com/SouravInsights).**
293+
294+
![PWA Future](https://cdn-images-1.medium.com/max/1000/1*YXv4EChRzHtVRTZ7HeQ3gQ.png)

0 commit comments

Comments
 (0)