fix: footnote language
Signed-off-by: Filipe Medeiros <hello@filipesm.eu>
This commit is contained in:
parent
76c6fc84e3
commit
5d2c44d838
|
@ -2,18 +2,13 @@
|
|||
import type { PortableTextBlock } from '@portabletext/types';
|
||||
import { PortableText } from 'astro-portabletext';
|
||||
import InlineLink from './portableText/components/InlineLink.astro';
|
||||
import langToFootnoteString from '../lib/langToFootnoteString';
|
||||
|
||||
export interface Props {
|
||||
blogPostContent: PortableTextBlock[];
|
||||
}
|
||||
|
||||
let footnoteString: string;
|
||||
if (Astro.url.pathname.includes('/blogue/')) footnoteString = 'rodape';
|
||||
else if (Astro.url.pathname.includes('/blog/')) footnoteString = 'footnot';
|
||||
else
|
||||
throw new Error(
|
||||
'Please add the new language to the BlogPostFootnotes component',
|
||||
);
|
||||
const footnoteString = langToFootnoteString(Astro);
|
||||
|
||||
const { blogPostContent } = Astro.props;
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
---
|
||||
import type { PortableTextListItemBlock } from '@portabletext/types';
|
||||
import InlineLink from '../../InlineLink.astro';
|
||||
import langToFootnoteString from '../../../lib/langToFootnoteString';
|
||||
|
||||
export interface Props {
|
||||
node: PortableTextListItemBlock;
|
||||
}
|
||||
|
||||
const footnoteString = langToFootnoteString(Astro);
|
||||
|
||||
// This is an incredible hack!! Ahah
|
||||
// Not sure if safe, but seems to be
|
||||
declare global {
|
||||
|
@ -27,7 +30,7 @@ const footnoteCount = globalThis.footnoteCounts[Astro.params.slug!];
|
|||
|
||||
<slot /><InlineLink
|
||||
class="align-super ml-1 text-sm"
|
||||
href={`#footnote-${footnoteCount}`}
|
||||
href={`#${footnoteString}-${footnoteCount}`}
|
||||
>
|
||||
{footnoteCount}
|
||||
</InlineLink>
|
||||
|
|
13
frontend/src/lib/langToFootnoteString.ts
Normal file
13
frontend/src/lib/langToFootnoteString.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import type { AstroGlobal } from 'astro';
|
||||
|
||||
export default function langToFootnoteString(Astro: Readonly<AstroGlobal>) {
|
||||
let footnoteString: string;
|
||||
if (Astro.url.pathname.includes('/blogue/')) footnoteString = 'rodape';
|
||||
else if (Astro.url.pathname.includes('/blog/')) footnoteString = 'footnot';
|
||||
else
|
||||
throw new Error(
|
||||
'Please add the new language to the `langToFootnoteString` function',
|
||||
);
|
||||
|
||||
return footnoteString;
|
||||
}
|
Loading…
Reference in a new issue