Skip to content

Commit

Permalink
fix: Update annotation config spacing and iterations (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker authored Dec 13, 2024
1 parent adc02db commit 7610525
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/components/PageHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const { title, date, description, annotation = "circle" } = Astro.props;
<script>
import { annotate } from "rough-notation";
import type { RoughAnnotationType } from "rough-notation/lib/model";
import { annotationConfig } from "~/helpers/helpers";

const header: HTMLElement | null = document.querySelector(".page-head h1");

Expand All @@ -40,9 +41,7 @@ const { title, date, description, annotation = "circle" } = Astro.props;

const highlight = annotate(header, {
type: annotation,
iterations: annotation === "highlight" ? 1 : 2,
padding: 10,
multiline: true,
...annotationConfig[annotation],
});
highlight.show();
}
Expand Down
46 changes: 46 additions & 0 deletions src/helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { marked } from "marked";
import type {
RoughAnnotationConfig,
RoughAnnotationType,
} from "rough-notation/lib/model";

export const smartquotes = (str: string) => {
return str
Expand All @@ -19,3 +23,45 @@ export const fetchPolicy = async (slug: string) => {
const content = marked.parse(markdownWithoutH1);
return content;
};

export const annotationConfig: Record<
RoughAnnotationType,
Omit<RoughAnnotationConfig, "type">
> = {
highlight: {
multiline: true,
iterations: 1,
padding: 0,
},
underline: {
multiline: true,
iterations: 3,
padding: 0,
},
box: {
multiline: false,
iterations: 3,
padding: [0, 8, 0, 8],
},
bracket: {
multiline: false,
iterations: 1,
padding: [0, 4, 0, 4],
brackets: ["left", "right"],
},
circle: {
multiline: false,
iterations: 2,
padding: [0, 16, 0, 16],
},
"strike-through": {
multiline: true,
iterations: 3,
padding: 0,
},
"crossed-off": {
multiline: false,
iterations: 4,
padding: 0,
},
};
1 change: 1 addition & 0 deletions src/pages/abuse.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const content = await fetchPolicy("abuse");
title="Use Restrictions Policy"
description="It is not okay to use Namesake for these restricted purposes."
color="brown"
annotation="crossed-off"
>
<article set:html={content} />
</ProseLayout>
1 change: 1 addition & 0 deletions src/pages/terms.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const content = await fetchPolicy("terms");
title="Terms of Service"
description="All the terms that you agree to when you sign up for Namesake."
color="brown"
annotation="box"
>
<article set:html={content} />
</ProseLayout>

0 comments on commit 7610525

Please sign in to comment.