Skip to content

Commit

Permalink
get rid of posted on date and generate it dynamically via git
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhupesh-V committed Jan 18, 2025
1 parent 50ac25c commit 46eaebe
Show file tree
Hide file tree
Showing 145 changed files with 266 additions and 143 deletions.
74 changes: 73 additions & 1 deletion .vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
import { defineConfig } from 'vitepress'
import { sidebar } from './sidebar.js'
import { execSync } from 'child_process'
import path from 'path'
import fs from 'fs'

function getGitCreationDate(filePath) {
try {
// Extract file name from path
const fileName = path.basename(filePath);

// Use case-insensitive search for the file name
const cmd = `git log --diff-filter=A --format=%at -- "*${fileName}"`
const timestamp = execSync(cmd, { encoding: 'utf-8' }).trim();

// Convert git timestamp to Date
return new Date(parseInt(timestamp) * 1000);
} catch (e) {
console.error(`Failed to get git creation date for ${filePath}:`, e);
return null;
}
}

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand Down Expand Up @@ -61,7 +81,59 @@ export default defineConfig({
}
},
},

lastUpdated: {
text: 'Laste updated',
formatOptions: {
dateStyle: 'medium',
}
}
},
cleanUrls: true,
lastUpdated: true
lastUpdated: true,
markdown: {
config(md) {
// Add a hook to process the markdown content
const render = md.render
md.render = (...args) => {
const html = render.call(md, ...args)
return `<PostDate />\n${html}`
}
},
},
transformPageData(pageData) {
const relativePath = pageData.relativePath

if (!relativePath) {
console.log('No relative path found for page')
return
}

// Get absolute path
const filePath = path.resolve(process.cwd(), relativePath)

if (!fs.existsSync(filePath)) {
console.log('File not found:', filePath)
return
}

try {
const createdAt = getGitCreationDate(filePath)
// Ensure frontmatter exists
pageData.frontmatter = pageData.frontmatter || {}

// Add both timestamp and formatted date
pageData.frontmatter.createdAt = createdAt
pageData.frontmatter.createdAtFormatted = createdAt.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
})

// Debug log
// console.log('Updated frontmatter:', pageData.frontmatter)
} catch (error) {
console.error('Error processing', relativePath, ':', error)
}
}
})
50 changes: 50 additions & 0 deletions .vitepress/theme/components/PostDate.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div class="post-metadata" v-if="createdDate">
<div class="created-date">
Posted on: {{ createdDate }}
</div>
</div>
</template>

<script setup>
import { useData } from 'vitepress'
import { computed } from 'vue'
const { frontmatter } = useData()
const formatDate = (date) => {
if (!date) return null
const dateObj = date instanceof Date ? date : new Date(date)
if (isNaN(dateObj.getTime())) return null
try {
return dateObj.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
})
} catch (e) {
console.warn('Error formatting date:', e)
return null
}
}
const createdDate = computed(() => {
return frontmatter.value?.createdAtFormatted ||
(frontmatter.value?.createdAt ? formatDate(frontmatter.value.createdAt) : null)
})
</script>
<style scoped>
.post-metadata {
font-size: 0.9em;
color: var(--vp-c-text-2);
margin: 1em 0;
}
.created-date {
white-space: nowrap;
}
</style>
2 changes: 2 additions & 0 deletions .vitepress/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { h } from 'vue'
import DefaultTheme from 'vitepress/theme'
import './style.css'
import HighlightedLink from './components/HighlightedLink.vue';
import PostDate from './components/PostDate.vue';

/** @type {import('vitepress').Theme} */
export default {
Expand All @@ -14,5 +15,6 @@ export default {
},
enhanceApp({ app, router, siteData }) {
app.component('HighlightedLink', HighlightedLink)
app.component('PostDate', PostDate)
}
}
2 changes: 1 addition & 1 deletion android/running-headless-android-emulator.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Running headless Android Emulator
**_Posted on 09 Feb, 2022_**



1. Create an AVD
Expand Down
2 changes: 1 addition & 1 deletion artificial-intelligence/fundamentals-of-llms.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fundamentals of LLMs

**_Posted on 04 Apr, 2023_**


A bunch of resources to refer for understanding LLMs

Expand Down
2 changes: 1 addition & 1 deletion career/beating-burnout-resources-thoughts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Beating Burnout: Some Thoughts & Resources
**_Posted on 14 Aug, 2022_**


## Understanding Burnout

Expand Down
2 changes: 1 addition & 1 deletion career/developing-decision-making-skills.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Invest in decision-making skills early in career
**_Posted on 02 Jan, 2022_**


## Current Situation

Expand Down
2 changes: 1 addition & 1 deletion career/exploring-large-codebases-tips.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Exploring Large Codebases
**_Posted on 25 May, 2021_**


> Since more than 50% of the time developers spent reading & modifying existing source code rather then writing new one, reading code is an essential skill for a developer that's why I am maintaining a log of resources, tips etc. to explore unknown Codebases
Expand Down
2 changes: 1 addition & 1 deletion career/full-employment-theorem.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Full employment theorem
**_Posted on 10 March, 2024_**


No matter how good someone is at their job, there will always be more work for them because there's no way to make everything perfect. So, people in fields where the **full-employment theorem can be proved** will always have something to do because there's always something that can be made better or improved upon.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Leveling up from Software Engineer to Senior Software Engineer

**_Posted on 06 Sep, 2023_**


I recently had a 1-1 conversation with my manager about my career growth and what I need to do to level up from Software Engineer to Senior Software Engineer. I am sharing my notes from the conversation here.

Expand Down
2 changes: 1 addition & 1 deletion career/mentoring.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mentoring

**_Posted on 31 Mar, 2024_**


Collected in-progress thoughts on mentoring (both sides).

Expand Down
2 changes: 1 addition & 1 deletion career/pros-and-cons-of-working-professionally.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pros & Cons of working professionally
**_Posted on 10 Feb, 2022_**


> Thoughts on this page are entirely personal, might not match with your opiniions.
Expand Down
2 changes: 1 addition & 1 deletion career/question-to-ask-interview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Questions to ask in an interview
**_Posted on 22 Jan, 2022_**


1. What’s the biggest priority for the team right now?
2. Why is this role open?
Expand Down
2 changes: 1 addition & 1 deletion career/writing-cover-letter-tips.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Writing Cover letter - Tips
**_Posted on Dec 8, 2020_**


I am not a hiring expert but I think these tips can help someone stand ahead of the crowd.
This might also help when you are cold-emailing a recruiter.
Expand Down
2 changes: 1 addition & 1 deletion coding-practices/cleancode-naming.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Naming Variables & Functions

**_Posted on 24 Jun, 2019_**


1. The name of a variable, function, or class should answer all the big questions.
It should tell you why it exists, what it does, and how it is used.
Expand Down
2 changes: 1 addition & 1 deletion coding-practices/cleancode-writing-functions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Writing Functions
**_Posted on 24 Jun, 2019_**


Got to learn some new points regarding functions() in CleanCode.

Expand Down
2 changes: 1 addition & 1 deletion coding-practices/everything-about-functions-procedures.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Routines: Functions & Procedures
**_Posted on 27 Jan, 2021_**

_________ Routines ________
| |
Functions Procedures
Expand Down
2 changes: 1 addition & 1 deletion coding-practices/solid.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SOLID: Design Principles
**_Posted on 05 Feb, 2021_**


1. **S**ingle Responsibility Principle
- An object should do exactly one thing, and should be the only object in the codebase that does that one thing.
Expand Down
2 changes: 1 addition & 1 deletion coding-practices/write-clean-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Writing Comments
**_Posted on 24 Jun, 2019_**



1. The proper use of comments is to compensate for our _failure to express
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to motivate and encourage volunteers

**_Posted on 11 Apr, 2023_**


> Jotting down tips on "how to help volunteers, so that they help the community".
Expand Down
2 changes: 1 addition & 1 deletion community-building/questions-for-women-in-tech.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Questions for Women in Tech

**_Posted on 25 Apr, 2024_**


> Collecting some questions & thoughts to figure out how to make the tech community more inclusive.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Questions to ask every Community Builder

**_Posted on 18 Apr, 2023_**


- How do you keep up the motivation to perfom mgmt activities, have you ever been burned out?
- How do you motivate others to join the cause, specially in tech when we work with FOSS?
Expand Down
2 changes: 1 addition & 1 deletion community-building/questions-to-ask-every-volunteer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Questions to ask every community volunteer

**_Posted on 25 Apr, 2023_**


- What are some things that you don't like about the community?
- Do you have any ideas to fix them? How?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What does a Community Lead (or Organiser) do?

**_Posted on 28 Mar, 2024_**


Thoughts on what a community lead/organiser/moderator does (or supposed to). This is a list of things I have found myself doing or have thought about doing.

Expand Down
2 changes: 1 addition & 1 deletion compilers/reference-counting-and-garbage-collection.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Reference Counting v/s Garbage Collection
**_Posted on 30 Jul, 2022_**


## Reference Counting (or ARC - Automatic Garbage Collection)

Expand Down
2 changes: 1 addition & 1 deletion data-warehouse/why-reverse-ctl.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Why Reverse ETL
**_Posted on 30 March, 2023_**


- Using Reverse ETL to build a data pipeline from your OLAP solutions like Snowflake back to your transactional databases like Postgres can help you make your data actionable thus operationalize data throughout the organisation.
- In reverse ETL strategy the data warehouse becomes the source, rather than the target. Pushing insights learned from this collected data from the warehouse to the right team inside your organisation be it Sales, Support etc who can be most benefited from it can reduce the friction and increase the business growth.
Expand Down
2 changes: 1 addition & 1 deletion databases/check-constraint-vs-exclusion-constraint.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CHECK constraint v/s EXCLUSION constraint
**_Posted on 22 Jul, 2022_**


## `CHECK` constraint

Expand Down
2 changes: 1 addition & 1 deletion databases/clustered-non-clustered-indexes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Clustered & Non-clustered Indexes
**_Posted on 25 Sep, 2022_**


## Clustered
- Organises data "physically" on disk.
Expand Down
2 changes: 1 addition & 1 deletion databases/explain-postgresql-query.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# EXPLAIN queries in PostgreSQL
**_Posted on 20 Dec, 2021_**


PostgreSQL devises multiple "query plans" for executing a query in the most optimized & best possible way. You can use `EXPLAIN` command to see what query plan a planner creates

Expand Down
2 changes: 1 addition & 1 deletion databases/getting-json-data-in-postgresql.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting JSON data from PostgreSQL

**_Posted on 04 Sep, 2021_**


To extract data in json from a table without specifying column names

Expand Down
2 changes: 1 addition & 1 deletion databases/inserting-null-everywhere.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Inserting NULL wherever possible on Postgres

**_Posted on 11 Apr, 2023_**


### UUID

Expand Down
2 changes: 1 addition & 1 deletion databases/list-all-values-for-custom-enum-postgres.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# List all values of a custom enum in Postgres

**_Posted on 23 May, 2023_**


```sql
select enum_range(null::my_enum)
Expand Down
2 changes: 1 addition & 1 deletion databases/postgres-internals-data-organisation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Postgres 14 Internals: Data Organisation

**_Posted on 5 June, 2023_**


- A single PostgreSQL instance can serve several databases at a time; together they are called a database cluster.
- The directory that contains all the files related to the cluster is usually called `PGDATA`.
Expand Down
2 changes: 1 addition & 1 deletion databases/postgres-tips-megalist.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Postgres Tips & Tricks
**_Posted on 05 Jan, 2025_**


## List all table indexes

Expand Down
2 changes: 1 addition & 1 deletion databases/slowly-changing-dimensions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Slowly Changing Dimensions (SCD)

**_Posted on 26 March, 2024_**


Slowly Changing Dimensions (SCD) are dimensions that change slowly over time, rather than changing on a regular schedule.

Expand Down
2 changes: 1 addition & 1 deletion databases/sqlite-space-optimization-with-rowd-id.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SQLite db optimization with ROWID
**_Posted on 04 Jul, 2022_**


SQLite lets you improve your database performance by using a phrase "WITHOUT ROWID" in create table command

Expand Down
Loading

0 comments on commit 46eaebe

Please sign in to comment.