aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-06 14:10:07 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2024-04-06 14:11:32 +0200
commit807d331d1c7234e7f19075be790493dd1641feb1 (patch)
tree551b1f16a610502ce31aa5fd04b5ee4f909fe1dc
parentAdd view source link (diff)
downloadblog-807d331d1c7234e7f19075be790493dd1641feb1.tar.gz
blog-807d331d1c7234e7f19075be790493dd1641feb1.tar.zst
blog-807d331d1c7234e7f19075be790493dd1641feb1.zip
Add favicon
-rw-r--r--src/components/ActiveSectionProvider.tsx2
-rw-r--r--src/css/custom.css1
-rw-r--r--src/plugins/responsiveLoaderPlugin.ts73
-rw-r--r--src/theme/BlogPostItem/Header/Author.tsx10
-rw-r--r--src/theme/BlogPostItem/Header/Title.tsx8
-rw-r--r--src/theme/Root.tsx6
-rw-r--r--src/theme/apple-touch-icon.pngbin0 -> 6389 bytes
-rw-r--r--src/theme/favicon.svg1
-rw-r--r--src/theme/favicon.ts7
-rw-r--r--src/theme/favicon_source.svg73
-rw-r--r--static/favicon.icobin0 -> 2238 bytes
11 files changed, 143 insertions, 38 deletions
diff --git a/src/components/ActiveSectionProvider.tsx b/src/components/ActiveSectionProvider.tsx
index bc6d111..fedeaef 100644
--- a/src/components/ActiveSectionProvider.tsx
+++ b/src/components/ActiveSectionProvider.tsx
@@ -30,7 +30,7 @@ export function useActiveSection(): ActiveSection {
30 return { 30 return {
31 hash: undefined, 31 hash: undefined,
32 setHash: () => {}, 32 setHash: () => {},
33 } 33 };
34 } 34 }
35 return value; 35 return value;
36} 36}
diff --git a/src/css/custom.css b/src/css/custom.css
index b84aec3..e97111e 100644
--- a/src/css/custom.css
+++ b/src/css/custom.css
@@ -105,7 +105,6 @@ h3 {
105 letter-spacing: var(--marussy-heading-tracking); 105 letter-spacing: var(--marussy-heading-tracking);
106} 106}
107 107
108
109.button--lg { 108.button--lg {
110 letter-spacing: var(--marussy-button-tracking); 109 letter-spacing: var(--marussy-button-tracking);
111} 110}
diff --git a/src/plugins/responsiveLoaderPlugin.ts b/src/plugins/responsiveLoaderPlugin.ts
index 6334c4c..6975124 100644
--- a/src/plugins/responsiveLoaderPlugin.ts
+++ b/src/plugins/responsiveLoaderPlugin.ts
@@ -12,34 +12,51 @@ import sharp from 'responsive-loader/sharp';
12export default function responsiveLoaderPlugin(): Plugin { 12export default function responsiveLoaderPlugin(): Plugin {
13 return { 13 return {
14 name: 'marussy-responsive-loader-plugin', 14 name: 'marussy-responsive-loader-plugin',
15 configureWebpack: (_config, isServer) => ({ 15 configureWebpack: (config, isServer) => {
16 mergeStrategy: { 16 const rules = config.module?.rules ?? [];
17 'module.rules': 'prepend', 17 rules.forEach((rule) => {
18 }, 18 if (
19 // Configuration based on 19 typeof rule === 'object' &&
20 // https://github.com/dazuaz/responsive-loader/blob/ef2c806fcd36f06f6be8a0b97e09f40c3d86d3ac/README.md 20 'test' in rule &&
21 module: { 21 rule.test instanceof RegExp &&
22 rules: [ 22 rule.test.test('.svg') &&
23 { 23 typeof rule.oneOf?.[0] === 'object' &&
24 test: /\.(png|jpe?g)$/, 24 'use' in rule.oneOf[0]
25 resourceQuery: /[?&]rl$/, 25 ) {
26 use: [ 26 // Skip SVGR when importing SVG files with ?url.
27 { 27 rule.oneOf[0].resourceQuery = { not: /[?&]url$/ };
28 loader: 'responsive-loader', 28 }
29 options: { 29 });
30 adapter: sharp, 30 return {
31 format: 'webp', 31 mergeStrategy: {
32 // See 32 'module.rules': 'replace',
33 // https://github.com/facebook/docusaurus/blob/c745021b01a8b88d34e1d772278d7171ad8acdf5/packages/docusaurus-plugin-ideal-image/src/index.ts#L62-L66 33 },
34 emitFile: !isServer, 34 // Configuration based on
35 name: 'assets/images/[name].[hash:hex:7].[width].[ext]', 35 // https://github.com/dazuaz/responsive-loader/blob/ef2c806fcd36f06f6be8a0b97e09f40c3d86d3ac/README.md
36 module: {
37 rules: [
38 {
39 test: /\.(png|jpe?g)$/,
40 resourceQuery: /[?&]rl$/,
41 use: [
42 {
43 loader: 'responsive-loader',
44 options: {
45 adapter: sharp,
46 format: 'webp',
47 // See
48 // https://github.com/facebook/docusaurus/blob/c745021b01a8b88d34e1d772278d7171ad8acdf5/packages/docusaurus-plugin-ideal-image/src/index.ts#L62-L66
49 emitFile: !isServer,
50 name: 'assets/images/[name].[hash:hex:7].[width].[ext]',
51 },
36 }, 52 },
37 }, 53 ],
38 ], 54 type: 'javascript/auto',
39 type: 'javascript/auto', 55 },
40 }, 56 ...rules,
41 ], 57 ],
42 }, 58 },
43 }), 59 };
60 },
44 }; 61 };
45} 62}
diff --git a/src/theme/BlogPostItem/Header/Author.tsx b/src/theme/BlogPostItem/Header/Author.tsx
index 226caee..7710a98 100644
--- a/src/theme/BlogPostItem/Header/Author.tsx
+++ b/src/theme/BlogPostItem/Header/Author.tsx
@@ -6,14 +6,16 @@
6 6
7import Author from '@theme-original/BlogPostItem/Header/Author'; 7import Author from '@theme-original/BlogPostItem/Header/Author';
8import type AuthorType from '@theme/BlogPostItem/Header/Author'; 8import type AuthorType from '@theme/BlogPostItem/Header/Author';
9import type {WrapperProps} from '@docusaurus/types'; 9import type { WrapperProps } from '@docusaurus/types';
10import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; 10import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11 11
12type Props = WrapperProps<typeof AuthorType>; 12type Props = WrapperProps<typeof AuthorType>;
13 13
14export default function AuthorWrapper(props: Props): JSX.Element { 14export default function AuthorWrapper(props: Props): JSX.Element {
15 const { siteConfig: { url } } = useDocusaurusContext(); 15 const {
16 const newProps = {...props}; 16 siteConfig: { url },
17 } = useDocusaurusContext();
18 const newProps = { ...props };
17 const { author } = props; 19 const { author } = props;
18 if (author.url !== undefined && author.url.startsWith(url)) { 20 if (author.url !== undefined && author.url.startsWith(url)) {
19 const newURL = author.url.substring(url.length); 21 const newURL = author.url.substring(url.length);
@@ -23,5 +25,5 @@ export default function AuthorWrapper(props: Props): JSX.Element {
23 const newImageURL = author.imageURL.substring(url.length); 25 const newImageURL = author.imageURL.substring(url.length);
24 newProps.author.imageURL = newImageURL.replace(/\.jpg$/, '.webp'); 26 newProps.author.imageURL = newImageURL.replace(/\.jpg$/, '.webp');
25 } 27 }
26 return <Author {...newProps} /> 28 return <Author {...newProps} />;
27} 29}
diff --git a/src/theme/BlogPostItem/Header/Title.tsx b/src/theme/BlogPostItem/Header/Title.tsx
index ced0916..9e19ec9 100644
--- a/src/theme/BlogPostItem/Header/Title.tsx
+++ b/src/theme/BlogPostItem/Header/Title.tsx
@@ -13,16 +13,16 @@
13 13
14import clsx from 'clsx'; 14import clsx from 'clsx';
15import Link from '@docusaurus/Link'; 15import Link from '@docusaurus/Link';
16import {useBlogPost} from '@docusaurus/theme-common/internal'; 16import { useBlogPost } from '@docusaurus/theme-common/internal';
17import type {Props} from '@theme/BlogPostItem/Header/Title'; 17import type { Props } from '@theme/BlogPostItem/Header/Title';
18 18
19import styles from './Title.module.css'; 19import styles from './Title.module.css';
20 20
21export default function BlogPostItemHeaderTitle({ 21export default function BlogPostItemHeaderTitle({
22 className, 22 className,
23}: Props): JSX.Element { 23}: Props): JSX.Element {
24 const {metadata, isBlogPostPage} = useBlogPost(); 24 const { metadata, isBlogPostPage } = useBlogPost();
25 const {permalink, title} = metadata; 25 const { permalink, title } = metadata;
26 const TitleHeading = isBlogPostPage ? 'h1' : 'h2'; 26 const TitleHeading = isBlogPostPage ? 'h1' : 'h2';
27 return ( 27 return (
28 <TitleHeading className={clsx(styles.title, className)}> 28 <TitleHeading className={clsx(styles.title, className)}>
diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx
index 32462bb..cb66420 100644
--- a/src/theme/Root.tsx
+++ b/src/theme/Root.tsx
@@ -11,6 +11,9 @@ import Root from '@theme-original/Root';
11import ActiveSectionProvider from '@site/src/components/ActiveSectionProvider'; 11import ActiveSectionProvider from '@site/src/components/ActiveSectionProvider';
12import fontURL from '@site/src/fonts/recursive-latin.woff2?url'; 12import fontURL from '@site/src/fonts/recursive-latin.woff2?url';
13 13
14import faviconSVG from './favicon.svg?url';
15import appleTouchIcon from './apple-touch-icon.png?url';
16
14export default function RootWrapper(props: Props) { 17export default function RootWrapper(props: Props) {
15 return ( 18 return (
16 <ActiveSectionProvider> 19 <ActiveSectionProvider>
@@ -22,6 +25,9 @@ export default function RootWrapper(props: Props) {
22 type="font/woff2" 25 type="font/woff2"
23 crossOrigin="anonymous" 26 crossOrigin="anonymous"
24 /> 27 />
28 <link rel="icon" href="/favicon.ico" sizes="32x32" />
29 <link rel="icon" href={faviconSVG} type="image/svg+xml" />
30 <link rel="apple-touch-icon" href={appleTouchIcon} />
25 </Head> 31 </Head>
26 <Root {...props} /> 32 <Root {...props} />
27 </ActiveSectionProvider> 33 </ActiveSectionProvider>
diff --git a/src/theme/apple-touch-icon.png b/src/theme/apple-touch-icon.png
new file mode 100644
index 0000000..c108543
--- /dev/null
+++ b/src/theme/apple-touch-icon.png
Binary files differ
diff --git a/src/theme/favicon.svg b/src/theme/favicon.svg
new file mode 100644
index 0000000..fe02946
--- /dev/null
+++ b/src/theme/favicon.svg
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><style>@media(prefers-color-scheme:dark){rect{fill:#4285f4}path{fill:#1b1b1d}}</style><rect width="16" height="16" fill="#1e6be6" rx="3" ry="3"/><path fill="#fff" d="M4.915 12.916q-.084.042-.334.056Q4.33 13 4.177 13q-.279 0-.515-.098-.237-.083-.39-.278-.14-.21-.14-.572 0-1.323.07-2.507.083-1.183.181-2.186.111-1.017.195-1.81.097-.809.111-1.38.028-.376 0-.612-.014-.237-.07-.46.14-.042.28-.056.139-.014.32-.027Q4.414 3 4.679 3q.598 0 .96.097.376.098.557.293t.237.529q.084.543.209 1.142.125.585.279 1.198.167.599.348 1.183.18.572.376 1.115.209.543.418 1.016l-.516-.376h.836l-.571.362q.237-.5.46-1.086.222-.599.417-1.253.21-.669.376-1.365.181-.697.32-1.393t.251-1.365q.112-.042.223-.056.126-.014.279-.028.167-.014.404-.014.613 0 .933.112t.46.376.194.71q.084.627.14 1.212.055.571.097 1.114.056.53.098 1.059.042.515.07 1.016l.055.99q.028.487.042.988.028.64.056 1.086.041.432.083.725l.098.515q-.126.042-.349.07-.208.028-.46.028-.43 0-.682-.098t-.348-.306q-.097-.223-.097-.613v-.376q.014-.237.014-.502.014-.278.014-.529 0-.292-.014-.64t-.042-.739q-.028-.404-.056-.85t-.07-.919q-.041-.487-.097-1.002T10.57 5.38l.292.446h-.724l.487-.46q-.111.64-.306 1.337T9.9 8.083q-.209.682-.46 1.295-.236.6-.473 1.073-.223.473-.418.738-.111.042-.265.07t-.306.027q-.209 0-.348-.041-.14-.042-.265-.14-.195-.209-.418-.585-.222-.39-.473-.933Q6.238 9.044 6 8.39q-.222-.668-.431-1.42-.195-.752-.363-1.56l.488.376h-.738l.278-.404q-.055.585-.111 1.128-.056.53-.098 1.03-.041.488-.083.948l-.056.891q-.028.431-.042.836t-.014.808q0 .529.014.988.028.446.07.906z"/></svg>
diff --git a/src/theme/favicon.ts b/src/theme/favicon.ts
new file mode 100644
index 0000000..1846748
--- /dev/null
+++ b/src/theme/favicon.ts
@@ -0,0 +1,7 @@
1/*
2 * SPDX-FileCopyrightText: 2023 Kristóf Marussy
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7export { default as default } from './favicon.svg?url';
diff --git a/src/theme/favicon_source.svg b/src/theme/favicon_source.svg
new file mode 100644
index 0000000..9a519b6
--- /dev/null
+++ b/src/theme/favicon_source.svg
@@ -0,0 +1,73 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
4<svg
5 width="16"
6 height="16"
7 viewBox="0 0 16 16"
8 version="1.1"
9 id="svg1"
10 inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
11 sodipodi:docname="favicon_source.svg"
12 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
13 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
14 xmlns="http://www.w3.org/2000/svg"
15 xmlns:svg="http://www.w3.org/2000/svg">
16 <sodipodi:namedview
17 id="namedview1"
18 pagecolor="#ffffff"
19 bordercolor="#666666"
20 borderopacity="1.0"
21 inkscape:showpageshadow="2"
22 inkscape:pageopacity="0.0"
23 inkscape:pagecheckerboard="0"
24 inkscape:deskcolor="#d1d1d1"
25 inkscape:document-units="mm"
26 showgrid="true"
27 inkscape:zoom="32"
28 inkscape:cx="9.671875"
29 inkscape:cy="2.546875"
30 inkscape:window-width="2560"
31 inkscape:window-height="1415"
32 inkscape:window-x="0"
33 inkscape:window-y="0"
34 inkscape:window-maximized="0"
35 inkscape:current-layer="layer1">
36 <inkscape:grid
37 id="grid1"
38 units="px"
39 originx="0"
40 originy="0"
41 spacingx="1"
42 spacingy="1"
43 empcolor="#3f3fff"
44 empopacity="0.25098039"
45 color="#3f3fff"
46 opacity="0.1254902"
47 empspacing="4"
48 dotted="false"
49 gridanglex="30"
50 gridanglez="30"
51 visible="true" />
52 </sodipodi:namedview>
53 <defs
54 id="defs1" />
55 <g
56 inkscape:label="Layer 1"
57 inkscape:groupmode="layer"
58 id="layer1">
59 <rect
60 style="fill:#1e6be6;fill-opacity:1;stroke:#1a1a1a;stroke-width:0;stroke-miterlimit:1.45;paint-order:stroke fill markers"
61 id="rect1"
62 width="16"
63 height="16"
64 x="0"
65 y="0"
66 rx="3" />
67 <path
68 d="m 4.9150366,12.916442 q -0.083566,0.04178 -0.3342624,0.05571 -0.2506968,0.02785 -0.4039004,0.02785 -0.278552,0 -0.5153212,-0.09749 -0.2367692,-0.08357 -0.3899728,-0.278552 -0.139276,-0.208914 -0.139276,-0.571032 0,-1.323122 0.069638,-2.5069678 Q 3.2855074,8.3621172 3.3830006,7.35933 3.4944214,6.3426152 3.577987,5.548742 3.6754802,4.7409412 3.6894078,4.1699096 q 0.027855,-0.3760452 0,-0.6128144 -0.013928,-0.2367692 -0.069638,-0.4596108 0.139276,-0.041783 0.278552,-0.05571 0.139276,-0.013928 0.3203348,-0.027855 0.1949864,-0.013928 0.4596108,-0.013928 0.5988868,0 0.9610044,0.097493 0.3760452,0.097493 0.557104,0.2924796 0.1810588,0.1949864 0.2367692,0.5292488 0.083566,0.5431764 0.208914,1.1420632 0.1253484,0.5849592 0.278552,1.1977736 0.1671312,0.5988868 0.34819,1.183846 0.1810588,0.5710316 0.3760452,1.114208 0.208914,0.5431764 0.417828,1.0167148 L 7.547353,9.1977732 H 8.383009 L 7.8119774,9.5598908 Q 8.0487466,9.0584972 8.2715882,8.473538 8.4944298,7.8746512 8.6894162,7.220054 8.8983302,6.5515292 9.0654614,5.8551492 q 0.1810588,-0.69638 0.3203348,-1.39276 0.139276,-0.69638 0.2506968,-1.3649048 0.1114208,-0.041783 0.2228416,-0.05571 0.1253484,-0.013928 0.2785524,-0.027855 0.167131,-0.013928 0.4039,-0.013928 0.612814,0 0.933149,0.1114208 0.320335,0.1114208 0.459611,0.3760452 0.139276,0.2646244 0.194986,0.7103076 0.08357,0.626742 0.139276,1.2117012 0.05571,0.5710316 0.09749,1.114208 0.05571,0.5292488 0.09749,1.0584976 0.04178,0.5153212 0.06964,1.0167148 0.02786,0.487466 0.05571,0.9888596 0.02786,0.487466 0.04178,0.98886 0.02786,0.640669 0.05571,1.086352 0.04178,0.431756 0.08357,0.724236 0.05571,0.292479 0.09749,0.515321 -0.125348,0.04178 -0.34819,0.06964 -0.208914,0.02785 -0.459611,0.02785 -0.431755,0 -0.682452,-0.09749 -0.250697,-0.09749 -0.34819,-0.306407 -0.09749,-0.222842 -0.09749,-0.612815 0,-0.139276 0,-0.376045 0.01393,-0.236769 0.01393,-0.501394 0.01393,-0.278552 0.01393,-0.529248 0,-0.29248 -0.01393,-0.64067 -0.01393,-0.34819 -0.04178,-0.7381628 -0.02786,-0.4039004 -0.05571,-0.8495836 -0.02785,-0.4456832 -0.06964,-0.9192216 -0.04178,-0.487466 -0.09749,-1.0027872 -0.05571,-0.5153212 -0.111421,-1.04457 l 0.29248,0.4456832 h -0.724235 l 0.487466,-0.4596108 q -0.111421,0.6406696 -0.306408,1.3370496 -0.194986,0.69638 -0.4178276,1.3788324 -0.208914,0.6824524 -0.4596108,1.2952668 -0.2367692,0.5988868 -0.4735384,1.072425 -0.2228416,0.473539 -0.417828,0.738163 -0.1114208,0.04178 -0.2646244,0.06964 -0.1532036,0.02786 -0.3064072,0.02786 -0.208914,0 -0.34819,-0.04178 Q 7.4916426,11.203348 7.3662942,11.105854 7.1713078,10.89694 6.9484662,10.520895 6.7256246,10.130922 6.4749278,9.587746 6.2381586,9.0445696 6.0013894,8.3899724 5.7785478,7.7214476 5.5696338,6.9693572 5.3746474,6.2172668 5.2075162,5.409466 l 0.487466,0.3760452 H 4.9568194 L 5.2353714,5.3816108 Q 5.179661,5.96657 5.1239506,6.5097464 q -0.05571,0.5292488 -0.097493,1.0306424 -0.041783,0.487466 -0.083566,0.9470768 -0.027855,0.4596108 -0.05571,0.8913664 -0.027855,0.4317556 -0.041783,0.835656 -0.013928,0.4039 -0.013928,0.807801 0,0.529249 0.013928,0.988859 0.027855,0.445684 0.069638,0.905294 z"
69 id="text1"
70 style="-inkscape-font-specification:'Recursive, @CASL=1.00,wght=600';stroke-width:0.999993;fill:#ffffff"
71 aria-label="M" />
72 </g>
73</svg>
diff --git a/static/favicon.ico b/static/favicon.ico
new file mode 100644
index 0000000..a3ece81
--- /dev/null
+++ b/static/favicon.ico
Binary files differ