Skip to content

Commit

Permalink
feat(css): center pages (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
comfysage authored Jan 21, 2025
1 parent 2590346 commit fbfcb29
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/data/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Post {
let mut opts = ComrakOptions::default();
opts.extension.strikethrough = true;
opts.extension.table = true;
opts.extension.header_ids = Some("#".to_string());
opts.extension.header_ids = Some(String::new());
opts.extension.underline = true;
opts.extension.alerts = true;

Expand Down Expand Up @@ -306,7 +306,7 @@ mod tests {
assert_eq!(post.tags, vec!["test", "post"]);
assert_eq!(
post.content,
"<h1><a href=\"#hello-world\" aria-hidden=\"true\" class=\"anchor\" id=\"#hello-world\"></a>Hello, World!</h1>\n<p>This is a test post.</p>\n"
"<h1><a href=\"#hello-world\" aria-hidden=\"true\" class=\"anchor\" id=\"hello-world\"></a>Hello, World!</h1>\n<p>This is a test post.</p>\n"
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/donos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct Donor {
}

pub fn get() -> io::Result<Vec<Donor>> {
let file_str = std::env::var("DONOS_FILE").unwrap_or_else(|_| "donors.json".to_string());
let file_str = std::env::var("DONOS_FILE").unwrap_or_else(|_| "donos.json".to_string());
let file = File::open(file_str)?;
let reader = BufReader::new(file);

Expand Down
11 changes: 11 additions & 0 deletions styles/layouts/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ body {
.main-page {
flex: 1;
container: main-page / inline-size;

width: 80vw;
margin: auto;

margin-top: 2rem;
}

@container main-page (width < 768px) {
.main-page {
width: 100vw;
}
}

a {
Expand Down
1 change: 1 addition & 0 deletions styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

// reusable styles
@use 'partials/alerts.scss';
@use 'partials/anchors.scss';
@use 'partials/donations.scss';
@use 'partials/blog-preview.scss';
@use 'partials/project.scss';
Expand Down
19 changes: 19 additions & 0 deletions styles/partials/anchors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
html {
scroll-behavior: smooth;
}

.anchor {
position: relative;

&::before {
content: "#";
position: absolute;
color: var(--fg);
display: inline-block;
vertical-align: middle;
width: 2rem;
height: 2rem;
left: -2rem;
top: 3px;
}
}
3 changes: 2 additions & 1 deletion styles/text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@
border: var(--border, var(--default-border));
line-height: 1.25rem;
text-wrap: wrap;

}

// inline code
p > code {
background: var(--bg-lighter);
color: var(--fg-lighter);
padding-inline: .3rem;
padding-block: .15rem;
}
}

Expand Down
16 changes: 8 additions & 8 deletions templates/pages/post.tera
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
{% block title %}{% set title = post.title %}{% endblock %}
{% block description %}{% set description = post.description %}{% endblock %}

{% block additionalfoot %}
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
<script src="https://unpkg.com/@highlightjs/[email protected]/languages/nix.min.js"></script>
<script>
hljs.highlightAll();
</script>
{% endblock %}

{% block main %}
<div class="reusable-header post-header">
<div class="left">
Expand Down Expand Up @@ -97,6 +89,14 @@
</section>

<div id="comments"></div>
{% endblock %}

{% block additionalfoot %}
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
<script src="https://unpkg.com/@highlightjs/[email protected]/languages/nix.min.js"></script>
<script>
hljs.highlightAll();
</script>

<script>
const codeblocks = document.querySelectorAll('div.codeblock');
Expand Down

0 comments on commit fbfcb29

Please sign in to comment.