Skip to content

Commit ada4a65

Browse files
authored
chore: Modularize and streamline linked data and Webpack configuration (#63)
- Moved structured data JSON-LD to a separate `linkedData.ejs` template for reusability and clarity in `index.ejs`. - Refactored Webpack configuration to dynamically load links from a JSON file, reducing redundancy and improving maintainability.
1 parent d165c1c commit ada4a65

File tree

4 files changed

+64
-52
lines changed

4 files changed

+64
-52
lines changed

src/data/links.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"links":
3+
[
4+
{
5+
"name": "LinkedIn",
6+
"url": "https://www.linkedin.com/in/-balazs-varga-/"
7+
},
8+
{
9+
"name": "Bluesky",
10+
"url": "https://bsky.app/profile/balzsvarga.bsky.social"
11+
},
12+
{
13+
"name": "GitHub",
14+
"url": "https://github.com/warnyul"
15+
},
16+
{
17+
"name": "The Apter Blog",
18+
"url": "https://blog.apter.tech/"
19+
}
20+
],
21+
"socialLinks":
22+
[
23+
{
24+
"icon": "linkedin",
25+
"name": "LinkedIn",
26+
"url": "https://www.linkedin.com/in/-balazs-varga-/"
27+
},
28+
{
29+
"icon": "bluesky",
30+
"name": "Bluesky",
31+
"url": "https://bsky.app/profile/balzsvarga.bsky.social"
32+
},
33+
{
34+
"icon": "github",
35+
"name": "GitHub",
36+
"url": "https://github.com/warnyul"
37+
}
38+
]
39+
}

src/views/index.ejs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,7 @@
2121
<link rel="preload" href="../assets/fonts/Poppins-Regular-latin-ext.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
2222
<link rel="preload" href="../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
2323
<link rel="preload" href="../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff2" as="font" type="font/woff2" crossorigin="anonymous" />
24-
<script type="application/ld+json">
25-
{
26-
"@context": "https://schema.org",
27-
"@type": "Person",
28-
"name": "Balázs Varga",
29-
"url": "<%- baseUrl %>",
30-
"sameAs": [
31-
"https://www.linkedin.com/in/-balazs-varga-/",
32-
"https://github.com/warnyul",
33-
"https://bsky.app/profile/balzsvarga.bsky.social"
34-
],
35-
"image": "<%- baseUrl + '/' + profilePictureUrlPath %>",
36-
"description": "Discover the professional profile of Balázs Varga. Links to LinkedIn, GitHub, Bluesky, and blog. Connect now!"
37-
}
38-
</script>
24+
<%- include('./linkedData.ejs', { baseUrl: baseUrl, profilePictureUrlPath: profilePictureUrlPath }); %>
3925
</head>
4026
<body>
4127
<div class="clazz-container">

src/views/linkedData.ejs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
<%
3+
const linkedData = {
4+
"@context": "https://schema.org",
5+
"@type": "Person",
6+
"name": "Balázs Varga",
7+
"url": baseUrl,
8+
"sameAs": [
9+
"https://www.linkedin.com/in/-balazs-varga-/",
10+
"https://github.com/warnyul",
11+
"https://bsky.app/profile/balzsvarga.bsky.social"
12+
],
13+
"image": `${baseUrl}/${profilePictureUrlPath}`,
14+
"description": "Discover the professional profile of Balázs Varga. Links to LinkedIn, GitHub, Bluesky, and blog. Connect now!",
15+
};
16+
%>
17+
<script type="application/ld+json"><%- JSON.stringify(linkedData) %></script>

webpack.config.js

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ const { interpolateName } = require('loader-utils');
1717
const fs = require('fs');
1818
const glob = require('glob');
1919
const path = require('path');
20-
const { sources } = require('webpack');
2120
const context = path.join(__dirname, 'src');
2221
const outputDir = path.join(__dirname, 'dist');
2322
const baseUrl = 'https://bvarga.dev';
2423

24+
const links = function() {
25+
const links = fs.readFileSync(`${context}/data/links.json`);
26+
return JSON.parse(links);
27+
}();
28+
2529
module.exports = {
2630
mode: "production",
2731
entry: {
@@ -114,42 +118,8 @@ module.exports = {
114118
content: pngContent,
115119
}
116120
);
117-
}(),
118-
links: [
119-
{
120-
name: 'LinkedIn',
121-
url: 'https://www.linkedin.com/in/-balazs-varga-/'
122-
},
123-
{
124-
name: 'Bluesky',
125-
url: 'https://bsky.app/profile/balzsvarga.bsky.social'
126-
},
127-
{
128-
name: 'GitHub',
129-
url: 'https://github.com/warnyul'
130-
},
131-
{
132-
name: 'The Apter Blog',
133-
url: 'https://blog.apter.tech/'
134-
},
135-
],
136-
socialLinks: [
137-
{
138-
icon: 'linkedin',
139-
name: 'LinkedIn',
140-
url: 'https://www.linkedin.com/in/-balazs-varga-/'
141-
},
142-
{
143-
icon: 'bluesky',
144-
name: 'Bluesky',
145-
url: 'https://bsky.app/profile/balzsvarga.bsky.social'
146-
},
147-
{
148-
icon: 'github',
149-
name: 'GitHub',
150-
url: 'https://github.com/warnyul'
151-
},
152-
],
121+
}(),
122+
...links,
153123
},
154124
}
155125
}),

0 commit comments

Comments
 (0)