fix: Layout and theme

This commit is contained in:
SauravDhakal
2026-04-01 10:33:28 +05:45
parent 38baeb86e8
commit 0c4e6715de
6 changed files with 243 additions and 15 deletions

View File

@@ -34,10 +34,15 @@ MyPortfolio/
│ │ └── _index.md # Section config │ │ └── _index.md # Section config
│ └── search.md # Search page │ └── search.md # Search page
├── layouts/ ├── layouts/
│ ├── index.html # Custom home page (no recent posts)
│ ├── partials/ # Override theme partials │ ├── partials/ # Override theme partials
│ │ ── footer.html # Custom footer │ │ ── footer.html # Custom footer
│ └── notes/ # Section-specific layouts │ └── templates/
│ └── list.html # Custom notes list │ └── schema_json.html # Fixed JSON-LD schema
│ ├── posts/
│ │ └── list.html # Custom posts list (compact style)
│ └── notes/
│ └── list.html # Custom notes list (compact style)
├── static/ ├── static/
│ └── files/ # Static files (CV.pdf, images, etc.) │ └── files/ # Static files (CV.pdf, images, etc.)
├── themes/ ├── themes/
@@ -347,7 +352,11 @@ Your `layouts/partials/footer.html` already overrides the theme's footer.
Create `layouts/SECTION_NAME/list.html` for a custom list layout for that section. Create `layouts/SECTION_NAME/list.html` for a custom list layout for that section.
Example: `layouts/notes/list.html` - custom compact layout for notes. **Current custom layouts:**
- `layouts/index.html` - Home page with just intro + social icons (no recent posts)
- `layouts/posts/list.html` - Compact list: `# Title` + date + 2-line description
- `layouts/notes/list.html` - Compact list: `# Title` + date (no description)
--- ---

View File

@@ -271,6 +271,78 @@ main .post-entry:hover {
line-height: 1.5; line-height: 1.5;
} }
/* *
* POSTS SECTION - Same compact style as notes but with description
* */
.posts-list {
list-style: none;
padding: 0;
margin: 0;
}
.post-item {
padding: 12px 0;
border-bottom: 1px solid var(--tertiary);
}
.post-item:last-child {
border-bottom: none;
}
.post-item a {
position: relative;
display: flex;
justify-content: space-between;
align-items: baseline;
text-decoration: none !important;
gap: 16px;
padding: 8px 12px;
margin: 0 -12px;
color: inherit;
transition: color 0.3s ease;
z-index: 1;
}
.post-item a::before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 0;
background-color: var(--green);
z-index: -1;
transition: height 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}
.post-item a:hover::before {
height: 100%;
}
.post-item a:hover .post-title,
.post-item a:hover .post-date {
color: var(--theme) !important;
}
.post-title {
font-size: 1.1rem;
font-weight: 500;
color: var(--primary);
}
.post-date {
font-size: 0.85rem;
color: var(--secondary);
white-space: nowrap;
}
.post-summary {
margin: 4px 0 0 0;
font-size: 0.96rem;
color: var(--secondary);
line-height: 1.5;
}
/* * /* *
* POST CONTENT SPACINGS * POST CONTENT SPACINGS
* */ * */

19
layouts/index.html Normal file
View File

@@ -0,0 +1,19 @@
{{- define "main" }}
{{- if .Site.Params.homeInfoParams }}
<article class="first-entry home-info">
<header class="entry-header">
<h1>{{ .Site.Params.homeInfoParams.Title | markdownify }}</h1>
</header>
<div class="entry-content">
{{ .Site.Params.homeInfoParams.Content | markdownify }}
</div>
<footer class="entry-footer">
{{- partial "social_icons.html" (dict "align" site.Params.homeInfoParams.AlignSocialIconsTo) }}
</footer>
</article>
{{- end }}
{{- /* No recent posts/notes - clean home page */ -}}
{{- end }}{{/* end main */}}

View File

@@ -7,22 +7,13 @@
{{- end }} {{- end }}
</header> </header>
{{- $pages := .Pages }}
{{- if .Site.Params.fuseOpts }}
<div id="searchResults" class="post-list"></div>
{{- end }}
<ul class="notes-list"> <ul class="notes-list">
{{- range $pages }} {{- range .Pages }}
<li class="note-item"> <li class="note-item">
<a href="{{ .Permalink }}"> <a href="{{ .Permalink }}">
<span class="note-title">{{ .Title }}</span> <span class="note-title"># {{ .Title }}</span>
<span class="note-date">{{ .Date.Format "Jan 2, 2006" }}</span> <span class="note-date">{{ .Date.Format "Jan 2, 2006" }}</span>
</a> </a>
{{- if .Summary }}
<p class="note-summary">{{ .Summary | plainify | truncate 100 }}</p>
{{- end }}
</li> </li>
{{- end }} {{- end }}
</ul> </ul>

View File

@@ -0,0 +1,113 @@
{{ if .IsHome }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}",
"name": {{ site.Title | jsonify }},
"url": {{ site.Home.Permalink | jsonify }},
"description": {{ site.Params.description | plainify | truncate 180 | jsonify }},
{{- if (eq site.Params.schema.publisherType "Person") }}
"image": {{ site.Params.assets.favicon | default "favicon.ico" | absURL | jsonify }},
{{- else }}
"logo": {{ site.Params.assets.favicon | default "favicon.ico" | absURL | jsonify }},
{{- end }}
"sameAs": [
{{- if site.Params.schema.sameAs }}
{{ range $i, $e := site.Params.schema.sameAs }}{{ if $i }}, {{ end }}{{ trim $e " " | jsonify }}{{ end }}
{{- else}}
{{ range $i, $e := site.Params.SocialIcons }}{{ if $i }}, {{ end }}{{ trim $e.url " " | jsonify }}{{ end }}
{{- end}}
]
}
</script>
{{- else if (or .IsPage .IsSection) }}
{{/* BreadcrumbList */}}
{{- $url := replace .Parent.Permalink ( printf "%s" site.Home.Permalink) "" }}
{{- $lang_url := strings.TrimPrefix ( printf "%s/" .Lang) $url }}
{{- $bc_list := (split $lang_url "/")}}
{{- $scratch := newScratch }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{{- range $index, $element := $bc_list }}
{{- $scratch.Add "path" (printf "%s/" $element ) | safeJS }}
{{- $bc_pg := site.GetPage ($scratch.Get "path") -}}
{{- if (and ($bc_pg) (gt (len . ) 0))}}
{{- if $index }}, {{end }}
{
"@type": "ListItem",
"position": {{ add 1 $index }},
"name": {{ $bc_pg.Name | jsonify }},
"item": {{ $bc_pg.Permalink | jsonify }}
}
{{- end }}
{{- end }}
{{- /* self-page addition */ -}}
, {
"@type": "ListItem",
"position": {{ add (len $bc_list) 1 }},
"name": {{ .Name | jsonify }},
"item": {{ .Permalink | jsonify }}
}
]
}
</script>
{{- if .IsPage }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": {{ .Title | plainify | jsonify }},
"name": {{ .Title | plainify | jsonify }},
"description": {{ with .Description | plainify }}{{ . | jsonify }}{{ else }}{{ .Summary | plainify | truncate 150 | jsonify }}{{ end }},
"keywords": [
{{- if .Params.keywords }}
{{ range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e | jsonify }}{{ end }}
{{- else }}
{{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e | jsonify }}{{ end }}
{{- end }}
],
"wordCount": {{ .WordCount }},
"inLanguage": {{ .Language.Lang | default "en-us" | jsonify }},
"datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05Z07:00" | jsonify }},
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | jsonify }},
{{- with (.Params.author | default site.Params.author) }}
"author":
{{- if (or (eq (printf "%T" .) "[]string") (eq (printf "%T" .) "[]interface {}")) -}}
[{{- range $i, $v := . -}}
{{- if $i }}, {{end -}}
{
"@type": "Person",
"name": {{ $v | jsonify }}
}
{{- end }}],
{{- else -}}
{
"@type": "Person",
"name": {{ . | jsonify }}
},
{{- end -}}
{{- end }}
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ .Permalink | jsonify }}
},
"publisher": {
"@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}",
"name": {{ site.Title | jsonify }},
"logo": {
"@type": "ImageObject",
"url": {{ site.Params.assets.favicon | default "favicon.ico" | absURL | jsonify }}
}
}
}
</script>
{{- end }}{{/* .IsPage end */}}
{{- end -}}

24
layouts/posts/list.html Normal file
View File

@@ -0,0 +1,24 @@
{{- define "main" }}
<header class="page-header">
<h1>{{ .Title }}</h1>
{{- if .Description }}
<div class="post-description">{{ .Description }}</div>
{{- end }}
</header>
<ul class="posts-list">
{{- range .Pages }}
<li class="post-item">
<a href="{{ .Permalink }}">
<span class="post-title"># {{ .Title }}</span>
<span class="post-date">{{ .Date.Format "Jan 2, 2006" }}</span>
</a>
{{- if .Summary }}
<p class="post-summary">{{ .Summary | plainify | truncate 150 }}</p>
{{- end }}
</li>
{{- end }}
</ul>
{{- end }}{{/* end main */}}