Skip to content

Commit

Permalink
feat: add generating millions of PDFs blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-karan committed Feb 14, 2024
1 parent 30ee5a0 commit 1c76ad4
Show file tree
Hide file tree
Showing 12 changed files with 675 additions and 278 deletions.
263 changes: 263 additions & 0 deletions content/blog/1-5-million-pdfs-in-25-minutes.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions data/authors/sarat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Sarat Chandra",
"title": "Software Engineer",
"homepage": "https://sarat.dev/",
"github": "https://github.com/iamd3vil",
"avatar": "https://avatars.githubusercontent.com/u/10434498?v=4",
"twitter": "https://twitter.com/iamd3vil"
}
54 changes: 27 additions & 27 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{{ partial "header.html" . }}

{{ if eq .Params.banner "yes" }}
<div class="banner">
<img src="{{ .Params.image }}">
</div>
{{ end }}

<div class="content-wrap wrap">
{{ if isset .Params "author" }}
{{ partial "author.html" . }}

{{ if eq .Params.banner "yes" }}
<div class="banner">
<img src="{{ .Params.image }}">
</div>
{{ end }}

<div class="content-wrap wrap">
{{ if isset .Params "authors" }}
{{ partial "author.html" . }}
{{ end }}
<div class="content">
{{ .Content }}

<div class="tags">
{{ if ne .Type "page" }}
{{ if gt .Params.tags 0 }}
<ul class="flat">
{{ range .Params.tags }}
<li><a href="{{ " /tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
{{ end }}
<div class="content">
{{ .Content }}

<div class="tags">
{{ if ne .Type "page" }}
{{ if gt .Params.tags 0 }}
<ul class="flat">
{{ range .Params.tags }}
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ end }}
</div>
</div>
</div>
</ul>
{{ end }}
{{ end }}
</div>
</div>
{{ partial "footer.html" . }}
</div>
</div>
</div>
{{ partial "footer.html" . }}
29 changes: 16 additions & 13 deletions layouts/partials/author-tiny.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<div class="author-tiny">
{{ if .Params.author }}
{{ $author := .Params.author }}
{{ with index .Site.Data.authors $author }}


<img src="{{ .avatar }}" class="avatar" alt="{{ .name }}" />


<a href="{{ $.Site.BaseURL }}/authors/{{ $author }}" class="name">{{ .name }}</a>
<span class="desig">{{ .title }}</span>

{{ end }}
{{ if .Params.authors }} <!-- Use the new authors array -->
{{ range .Params.authors }} <!-- Iterate over each author in the array -->
{{ $author := . }} <!-- Assign the current author to a variable -->
{{ with index $.Site.Data.authors $author }} <!-- Access author details from the data directory -->
<div class="author-tiny-individual">
<span class="avatar"><img src="{{ .avatar }}" alt="{{ .name }}" /></span>
<div class="author-tiny-meta">
<div class="author-tiny-details">
<a href="{{ $.Site.BaseURL }}/authors/{{ $author }}" class="name">{{ .name }}</a>
<div class="desig">{{ .title }}</div>
</div>
</div>
</div>
{{ end }}
</div>
{{ end }}
{{ end }}
</div>
64 changes: 38 additions & 26 deletions layouts/partials/author.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
<div class="author">
{{ if .Params.author }}
{{ $author := .Params.author }}
{{ with index .Site.Data.authors $author }}
<span class="avatar"><img src="{{ .avatar }}" alt="{{ .name }}" /></span>
<div class="meta">
<div>
<a href="{{ $.Site.BaseURL }}/authors/{{ $author }}" class="name">{{ .name }}</a>
<div class="desig">{{ .title }}</div>
</div>

<div class="urls">
{{ if .homepage }}
<a href="{{ .homepage }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" x2="22" y1="12" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>
</svg>
</a>{{ end }}
{{ if .github }}
<a href="{{ .github }}">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/>
</svg>
</a>
{{ end }}
</div>
{{ if .Params.authors }} <!-- Use the new authors array -->
{{ range .Params.authors }} <!-- Iterate over each author in the array -->
{{ $author := . }} <!-- Assign the current author to a variable -->
{{ with index $.Site.Data.authors $author }} <!-- Access author details from the data directory -->
<div class="author-individual">
<span class="avatar"><img src="{{ .avatar }}" alt="{{ .name }}" /></span>
<div class="meta">
<div class="author-details">
<a href="{{ $.Site.BaseURL }}/authors/{{ $author }}" class="name">{{ .name }}</a>
<div class="desig">{{ .title }}</div>
</div>
{{ end }}
<div class="urls">
{{ if .homepage }}
<a href="{{ .homepage }}" class="social-link">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" />
<line x1="2" x2="22" y1="12" y2="12" />
<path
d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
</svg>
</a>
{{ end }}
{{ if .github }}
<a href="{{ .github }}" class="social-link">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path
d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4" />
<path d="M9 18c-4.51 2-5-2-7-2" />
</svg>
</a>
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
</div>
</div>
84 changes: 45 additions & 39 deletions layouts/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html>

<head>
{{- $title := ( .Title ) -}}
{{- $siteTitle := ( .Site.Title ) -}}
Expand All @@ -15,40 +16,43 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Open Graph -->
{{- if .IsHome -}}
<meta property="og:title" content="{{ $siteTitle }} {{ if .Site.Params.subtitle }}- {{ .Site.Params.Subtitle }}{{ end }}" />
<meta property="og:title"
content="{{ $siteTitle }} {{ if .Site.Params.subtitle }}- {{ .Site.Params.Subtitle }}{{ end }}" />
{{- else -}}
<meta property="og:title" content="{{ $title }} - {{ $siteTitle }}" />
{{- end -}}

<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.subtitle }}{{ end }}" />
<meta property="og:description"
content="{{ with .Description }}{{ . }}{{ else }}{{ .Site.Params.subtitle }}{{ end }}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ .Permalink }}" />

<link rel="shortcut icon" href="{{ .Site.BaseURL }}/static/images/favicon.png" />

{{ with .OutputFormats.Get "rss" -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ printf `
<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
{{ end -}}

{{ with .Params.image }}
<meta property="og:image" content="{{ if in . "http" }}{{ . }}{{ else }}{{ $.Site.BaseURL }}{{ . }}{{ end }}" />
<meta property="og:image" content="{{ if in . " http" }}{{ . }}{{ else }}{{ $.Site.BaseURL }}{{ . }}{{ end }}" />
{{ else }}
<meta property="og:image" content="https://zerodha.com/static/images/landing.png">
<meta property="og:image" content="https://zerodha.com/static/images/landing.png">
{{ end }}

<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//m.zerodha.com/";
_paq.push(['setTrackerUrl', u+'js/']);
_paq.push(['setSiteId', '16']);
_paq.push(['setAPIUrl', u]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'js/'; s.parentNode.insertBefore(g,s);
})();
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "//m.zerodha.com/";
_paq.push(['setTrackerUrl', u + 'js/']);
_paq.push(['setSiteId', '16']);
_paq.push(['setAPIUrl', u]);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.async = true; g.src = u + 'js/'; s.parentNode.insertBefore(g, s);
})();
</script>

<script type="application/ld+json">
Expand Down Expand Up @@ -76,16 +80,18 @@

<link href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="screen" href="{{ .Site.BaseURL }}/static/style.css" />

<!-- <link rel="stylesheet" type="text/css" media="(prefers-color-scheme: dark)" href="{{ .Site.BaseURL }}/static/dark.css" /> -->
</head>

<body>
{{ .Site.Params.paginate }}
<section class="page-hero">
<div class="container wrap">
<div class="header">
<div class="logo">
<a href="{{ .Site.BaseURL }}/"><img alt="Zerodha technology blog" src="{{ .Site.BaseURL }}/static/images/logo.svg" /></a>
<a href="{{ .Site.BaseURL }}/"><img alt="Zerodha technology blog"
src="{{ .Site.BaseURL }}/static/images/logo.svg" /></a>
</div>
<nav class="nav">
{{ $cur := . }}
Expand All @@ -95,10 +101,11 @@
{{ end }}

<a href="{{ .Site.BaseURL }}/index.xml" class="feed" title="Subscribe to feed">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 11a9 9 0 0 1 9 9"/>
<path d="M4 4a16 16 0 0 1 16 16"/>
<circle cx="5" cy="19" r="1"/>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M4 11a9 9 0 0 1 9 9" />
<path d="M4 4a16 16 0 0 1 16 16" />
<circle cx="5" cy="19" r="1" />
</svg>
</a>
</nav>
Expand All @@ -109,28 +116,27 @@
<div class="post-header">
<h1 class="title">{{ .Title }}</h1>
{{ if ne .Type "page" }}
<p class="date">
{{ dateFormat "02 Jan 2006" .Date }}
</p>
<p class="date">
{{ dateFormat "02 Jan 2006" .Date }}
</p>
{{ else }}
{{ .Params.description }}
{{ .Params.description }}
{{ end }}
</div>
</div>
{{ else if .IsHome }}
<h1 class="intro">
We build <span class="bold">technology at
<h1 class="intro">
We build <span class="bold">technology at
Zerodha, </span> <span class="highlight">India's largest stock broker</span>.
</h1>
</h1>

{{ else if isset .Data "Term" }}
<h1 class="post-header">
{{ if eq (index .Data "Singular") "author" }}@{{ end }}{{ .Data.Term }}
</h1>
<h1 class="post-header">
{{ if eq (index .Data "Singular") "author" }}@{{ end }}{{ .Data.Term }}
</h1>
{{ else }}
<h1 class="post-header">{{ .Name }}</h1>
<h1 class="post-header">{{ .Name }}</h1>
{{ end }}

</div>
</section>

</section>
Binary file added static/static/images/cnotes_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/static/images/cnotes_wf_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/static/images/cnotes_wf_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/static/images/cnotes_wf_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/static/images/cnotes_wf_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1c76ad4

Please sign in to comment.