Skip to content

Commit

Permalink
feat: Improve sitemap system, update package and remove markdown from…
Browse files Browse the repository at this point in the history
… excerpt (#19)
  • Loading branch information
rezafikkri authored Jul 11, 2024
2 parents 1a86ad4 + 0c815e3 commit 4ad76e2
Show file tree
Hide file tree
Showing 10 changed files with 1,144 additions and 4,747 deletions.
14 changes: 1 addition & 13 deletions public/sitemap.xml → app/blogs/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://rezafikkri.github.io/about</loc>
<lastmod>2023-03-09</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/projects</loc>
<lastmod>2023-03-09</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/blogs</loc>
<lastmod>2023-03-09</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/blogs/pdo-php-data-objects-ekstensi-php-untuk-mengakses-database</loc>
<lastmod>2023-03-13</lastmod>
Expand Down
19 changes: 19 additions & 0 deletions app/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://rezafikkri.github.io</loc>
<lastmod>2024-07-11</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/about</loc>
<lastmod>2024-07-11</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/projects</loc>
<lastmod>2024-06-09</lastmod>
</url>
<url>
<loc>https://rezafikkri.github.io/blogs</loc>
<lastmod>2024-07-12</lastmod>
</url>
</urlset>
4 changes: 2 additions & 2 deletions components/about/skill.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export default function Skill() {
<p className="mt-1 text-lg">HTML - CSS - JavaScript - PHP - Git - Bootstrap</p>

<h3 className="text-gray-500 mt-5">Menengah</h3>
<p className="mt-1 text-lg">CodeIgniter - Laravel - Tailwind CSS - MariaDB - PostgreSQL - Github - NodeJS - React - Next.js</p>
<p className="mt-1 text-lg">CodeIgniter - Tailwind CSS - MariaDB - PostgreSQL - GitHub - React - Next.js</p>

<h3 className="text-gray-500 mt-5">Dasar</h3>
<p className="mt-1 text-lg">Lua - Electron - Linux - MongoDB - Redis - RabbitMQ - Webpack - GIMP - Inkscape - Kdenlive - Python</p>
<p className="mt-1 text-lg">Lua - Electron - Linux - Vite - GIMP - Inkscape - Kdenliven - GitHub Actions - Laravel - NodeJS</p>

<Link href="/CV Reza SF.pdf" download target="_blank" className="mt-9 inline-block no-underline bg-white hover:bg-gray-100 border border-gray-200 px-4 py-2 rounded-lg">
<span className="mr-1.5">Unduh CV</span>
Expand Down
4 changes: 2 additions & 2 deletions components/about/summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Link from "next/link";
export default function Summary() {
return (
<section className="text-xl mt-8 leading-relaxed text-gray-800">
<p className="mb-6">Nama saya Reza Sariful Fikri, seorang Backend Web Developer. Coding adalah hobi saya. Saya suka membuat aplikasi yang bermanfaat bagi diri sendiri dan orang lain, serta juga suka menulis artikel atau tutorial terkait pengembangan web ataupun teknologi pada umumnya, kamu bisa membacanya pada menu <Link href="/blogs">blog</Link>. Selain itu saya juga punya hobi lain seperti bercocok tanam secara organik, hal yang paling saya sukai adalah kita bisa bebas ber-eksperimen, seperti membuat kompos sendiri maupun pupuk sendiri, dan lain-lain.</p>
<p>Selain hobi tersebut saya juga menyempatkan diri untuk membuat projek open-source seperti aplikasi, template, dan hal-hal lain, selain untuk latihan, hal tersebut juga bisa jadi portofolio dan juga tentunya saya gunakan sendiri untuk membantu pekerjaan saya. Kamu bisa melihatnya pada menu <Link href="/projects">projek</Link>.</p>
<p className="mb-6">Nama saya Reza Sariful Fikri, seorang Backend Web Developer. Saat ini bahasa utama yang saya gunakan adalah PHP dan JavaScript, PHP digunakan untuk backend dan JavaScript digunakan ketika butuh untuk membuat frontend.</p>
<p className="mb-6">Di waktu senggang saya menyempatkan diri untuk menulis blog terkait pengembangan web, kamu bisa membacanya pada menu <Link href="/blogs">blog</Link>. Selain itu juga membuat beberapa projek open-source seperti aplikasi, template, dan sebagainya, selain untuk latihan, hal tersebut juga bisa jadi portofolio dan juga tentunya saya gunakan sendiri untuk membantu pekerjaan saya. Kamu bisa melihatnya pada menu <Link href="/projects">projek</Link>.</p>
</section>
);
}
4 changes: 2 additions & 2 deletions lib/generate-post.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { randomUUID } from 'crypto';
const dataDirectory = path.join(process.cwd(), 'data');

async function generateSiteMap(slug, lastmod) {
const fullPath = path.join(process.cwd(), 'public/sitemap.xml');
const fullPath = path.join(process.cwd(), 'app/blogs/sitemap.xml');
const sitemap = readFileSync(fullPath, 'utf8');
const sitemapParsed = await parseStringPromise(sitemap);

Expand All @@ -23,7 +23,7 @@ async function generateSiteMap(slug, lastmod) {
});

// parse back sitemapParsed to xml and write file to sitemap.xml
const builder = new Builder();
const builder = new Builder({ xmldec: { 'version': '1.0', 'encoding': 'UTF-8'} });
writeFileSync(fullPath, builder.buildObject(sitemapParsed));
}

Expand Down
8 changes: 7 additions & 1 deletion lib/posts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { readFileSync, readdirSync } from 'fs';
import path from 'path';
import matter from 'gray-matter';
import { unified } from 'unified';
import remarkStringify from 'remark-stringify';
import remarkParse from 'remark-parse';
import remarkGfm from 'remark-gfm';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import rehypeRaw from 'rehype-raw';
import rehypeAttrs from 'rehype-attr';
import strip from 'strip-markdown';
import { remarkDefinitionList, defListHastHandlers } from 'remark-definition-list';

const dataDirectory = path.join(process.cwd(), 'data');
Expand Down Expand Up @@ -36,7 +38,11 @@ export function getTopicId(topicName) {
// options for generate excerpt
function generateExcerpt(file) {
const splittedContent = file.content.split('<!-- excerpt -->');
file.excerpt = splittedContent[1];
const excerpt = unified()
.use(remarkParse)
.use(remarkStringify)
.use(strip);
file.excerpt = String(excerpt.processSync(splittedContent[1]));
// clean content
file.content = splittedContent.join('');
}
Expand Down
31 changes: 15 additions & 16 deletions lib/update-sitemap.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import path from 'path';
import inquirer from 'inquirer';
import input from '@inquirer/input';
import { writeFileSync, readFileSync } from 'fs';
import { Builder, parseStringPromise } from "xml2js";
import slug from 'slug';
import dayjs from 'dayjs';

async function updateSitemap() {
const { title, newTitle } = await inquirer.prompt([
{
type: 'input',
name: 'title',
message: 'Judul:',
},
{
type: 'input',
name: 'newTitle',
default: (answers) => answers.title,
message: 'Judul Baru:',
},
]);
const fullPath = path.join(process.cwd(), 'public/sitemap.xml');
const title = await input({
type: 'input',
name: 'title',
message: 'Judul:',
});
const newTitle = await input({
type: 'input',
name: 'newTitle',
default: title,
message: 'Judul Baru:',
});

const fullPath = path.join(process.cwd(), 'app/blogs/sitemap.xml');
const sitemap = readFileSync(fullPath, 'utf8');
const sitemapParsed = await parseStringPromise(sitemap);
const baseLoc = 'https://rezafikkri.github.io/blogs/';
Expand All @@ -41,7 +40,7 @@ async function updateSitemap() {
});

// parse back new sitemap to xml and write to file
const builder = new Builder();
const builder = new Builder({ xmldec: { 'version': '1.0', 'encoding': 'UTF-8'} });
writeFileSync(fullPath, builder.buildObject(newSitemap));
}

Expand Down
Loading

0 comments on commit 4ad76e2

Please sign in to comment.