Skip to content

Commit be79f44

Browse files
committed
refactor: adjust margin for improved layout consistency and remove unused header components
1 parent 77cc36f commit be79f44

File tree

11 files changed

+61
-288
lines changed

11 files changed

+61
-288
lines changed

src/lib/assets/mdlayouts/article.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
color: rgba(0, 0, 0, 1);
9797
padding: 0;
9898
margin: auto;
99-
margin-left: 10%;
99+
margin-left: 20%;
100100
text-align: left;
101101
vertical-align: middle;
102102
transform: skewX(50deg);

src/lib/components/HeaderTitle.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
padding: 0;
6666
font-size: 1.8rem;
6767
margin: auto;
68-
margin-left: 10%;
68+
margin-left: 20%;
6969
text-align: left;
7070
vertical-align: middle;
7171
transform: skewX(50deg);
Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
21
import { h } from 'hastscript';
32
import { toString } from 'hast-util-to-string';
43
/**
5-
* Custom Rehype plugin to wrap sections and replace H2 with a <Header> component.
6-
* @returns {import('unified').Transformer}
7-
*/
4+
* Custom Rehype plugin to wrap sections and replace H2 with a <Header> component.
5+
* @returns {import('unified').Transformer}
6+
*/
87

98

109
export default function rehypeSectionWrapper() {
1110
/**
12-
* @param {import('hast').Root} tree
13-
*/
11+
* @param {import('hast').Root} tree
12+
*/
1413
return (tree) => {
1514
const newChildren = [];
1615
let currentWrapper = null;
@@ -20,44 +19,53 @@ export default function rehypeSectionWrapper() {
2019
newChildren.push(wrapper);
2120
return wrapper;
2221
};
23-
22+
2423
for (const node of tree.children) {
2524
// Check if the node is an H1 element
2625
if (node.type === 'element' && node.tagName === 'h1') {
27-
// 1. Extract the text content of the H2.
26+
// 1. Extract the text content of the H1.
2827
const headerText = toString(node);
29-
28+
3029
// 2. Create a new <Header> component element with a 'title' prop.
31-
const headerComponent = h('div.outer-wrapper', [h('div.middle-wrapper',
30+
const headerComponent = h('div.outer-wrapper', [h('div.middle-wrapper',
3231
[h('h1.h1-wrapper', headerText), h('div.inter-wrapper', [])])]);
3332

3433
// 3. Add the new <Header> component to the wrapper.
34+
if (currentWrapper) {
35+
if (currentWrapper.children.length === 1) {
36+
// If the current wrapper is empty, remove it
37+
newChildren.pop();
38+
}
39+
}
3540
newChildren.push(h('br', [])); // Add a horizontal rule before the header
3641
newChildren.push(headerComponent);
3742
newChildren.push(h('br', []));
38-
currentWrapper = createNewWrapper();
43+
currentWrapper = null;
3944
continue;
4045
}
4146

4247
if (node.type === 'element' && node.tagName === 'h2') {
4348
// 1. Extract the text content of the H2.
4449
const headerText = toString(node);
45-
50+
4651
// 2. Create a new <Header> component element with a 'title' prop.
47-
const headerComponent = h('div.outer-wrapper', [h('div.middle-wrapper',
52+
const headerComponent = h('div.outer-wrapper', [h('div.middle-wrapper',
4853
[h('div.inter-wrapper', [h('h2.h2-wrapper', headerText)])])])
4954

55+
if (currentWrapper) {
56+
if (currentWrapper.children.length === 1) {
57+
// If the current wrapper is empty, remove it
58+
newChildren.pop();
59+
}
60+
}
5061
// 3. Add the new <Header> component to the wrapper.
5162
newChildren.push(h('br', [])); // Add a horizontal rule before the header
5263
newChildren.push(headerComponent);
5364
newChildren.push(h('br', []));
54-
currentWrapper = createNewWrapper();
65+
currentWrapper = null;
5566
continue;
5667
}
5768
if (node.type === 'element' && node.tagName === 'hr') {
58-
59-
60-
// 4. Add the new <Header> component to the wrapper.
6169
newChildren.push(h('br', [])); // Add a horizontal rule before the header
6270
currentWrapper = null;
6371
continue;
@@ -66,11 +74,13 @@ export default function rehypeSectionWrapper() {
6674
if (!currentWrapper) {
6775
currentWrapper = createNewWrapper();
6876
}
69-
70-
// Add any other node to the current section.
77+
7178
currentWrapper.children.push(node);
79+
80+
7281
}
7382

83+
7484
tree.children = newChildren;
7585
};
7686
}

src/routes/curriculum_vitae/+page.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import Interests from "./Interests.svelte";
2+
// import Interests from "./Interests.svelte";
33
import Certificates from "./Certificates.svelte";
44
import Education from "./Education.svelte";
55
import Experience from "./Experience.svelte";
@@ -30,10 +30,12 @@
3030
<CvHeader>Certificates</CvHeader>
3131
<Certificates />
3232
</section>
33-
<section id="Interests">
33+
<!-- <section id="Interests">
3434
<CvHeader>Pursuits</CvHeader>
3535
<Interests />
36-
</section>
36+
</section> -->
37+
<br />
38+
<br />
3739
</div>
3840

3941
<style>

src/routes/posts/ErlangDBG/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import CustomHandlerMessageSignals from './CustomHandlerSignals.md?svelte';
1010
import RegisteredProcessesTracking from './RegisteredProcessesTracking.md?svelte';
1111
import Cleanup from './Cleanup.md?svelte';
12-
import HeaderShort from '../HeaderShort.svelte';
13-
import Header from '../Header.svelte';
12+
import HeaderShort from '$lib/components/HeaderShort.svelte';
13+
import Header from '$lib/components/Header.svelte';
1414
import BasicScenario from './BasicScenario.md?svelte';
1515
import Conclusion from './Conclusion.md?svelte';
1616
</script>

src/routes/posts/Header.svelte

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/routes/posts/HeaderShort.svelte

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/routes/posts/HeaderTitle.svelte

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/routes/posts/mdarticles/[slug]/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script lang="ts">
22
// import type { PageData } from './[slug]/$types';
33
4-
import HeaderShort from '../../HeaderShort.svelte';
4+
import HeaderShort from '$lib/components/HeaderShort.svelte';
55
import type { PageData } from './$types';
6-
import HeaderTitle from '../../HeaderTitle.svelte';
6+
import HeaderTitle from '$lib/components/HeaderTitle.svelte';
77
// The 'data' prop is automatically populated by SvelteKit
88
// with the result from the `load` function in `+page.ts`.
99
export let data: PageData;
@@ -25,7 +25,7 @@
2525
<br />
2626
<HeaderShort> Date: {formatDate(data.metadata.date) || 'No date'}</HeaderShort>
2727
<HeaderTitle>{data.metadata.title || data.slug}</HeaderTitle>
28-
<HeaderShort>Tags: {data.metadata.tags?.join(', ') || 'No tags '}&nbsp; &nbsp;</HeaderShort>
28+
<!-- <HeaderShort>Tags: {data.metadata.tags?.join(', ') || 'No tags '}&nbsp; &nbsp;</HeaderShort> -->
2929
<article class="prose lg:prose-xl dark:prose-invert max-w-none">
3030
<svelte:component this={data.PostContent} />
3131
</article>

0 commit comments

Comments
 (0)