Skip to content

Commit

Permalink
Implement PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
cau777 committed Sep 23, 2022
1 parent 0603f09 commit 04b9d23
Show file tree
Hide file tree
Showing 18 changed files with 9,642 additions and 4,432 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.idea/
client/public/sw.js
client/public/sw.js.map
client/public/worker-*.js
client/public/worker-*.js.map
2 changes: 1 addition & 1 deletion client/components/home/SnippetsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {useTranslation} from "next-i18next";
import BlockError from "../basic/BlockError";
import {completeSnippetData} from "../../src/post";

const PageSize = 15;
const PageSize = 6;

export type Snippet = {
id: number;
Expand Down
32 changes: 31 additions & 1 deletion client/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const {i18n} = require("./next-i18next.config");

const withPWA = require("next-pwa")

/** @type {import("next").NextConfig} */
const nextConfig = {
var nextConfig = {
i18n,
reactStrictMode: true,
swcMinify: true,
Expand All @@ -27,4 +29,32 @@ const nextConfig = {
}
}

nextConfig = withPWA({
dest: "public",
disable: process.env.NODE_ENV === "development",
runtimeCaching: [
{
handler: "CacheFirst",
urlPattern: "/api/extract_keywords",
options: {
cacheName: "extract-keywords-api-cache",
expiration: {
maxEntries: 25
}
}
},
{
handler: "CacheFirst",
urlPattern: "/_next/image",
options: {
cacheName: "next-images-cache",
expiration: {
maxEntries: 50,
maxAgeSeconds: 30
}
}
}
]
})(nextConfig);

module.exports = nextConfig
Loading

0 comments on commit 04b9d23

Please sign in to comment.