Skip to content

Commit

Permalink
update topic
Browse files Browse the repository at this point in the history
  • Loading branch information
seadfeng committed Oct 24, 2024
1 parent a8b3207 commit fe4655f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/components/frontend/page/topic/fonts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Copy from "@/components/shared/copy";
import { Button } from "@/components/ui/button";
import { appConfig } from "@/config";
import { AlternatingFontKey, alternatingFonts } from "@/fonts";
import { FontKey, fonts, transforms } from "@/transforms";
import { HTMLAttributes } from "react";

Expand All @@ -17,11 +18,14 @@ export const Fonts = ({
content: string;
}) => {

const FontItem = ({ fontKey }: { fontKey: FontKey }) => {
const chars = transforms[fontKey] as TransformMap;
const FontItem = ({ fontKey }: { fontKey: FontKey }) => {

const transformAndAdjust = (text: string) => {
return Array.from(text).map(char => {
return Array.from(text).map((char,idx) => {
const alternatingIdx = idx % 2; // index 0 or 1
const alternatings = alternatingFonts;
const chars = fontKey.includes("alternating") ? transforms[(alternatings[fontKey as AlternatingFontKey][alternatingIdx]) as FontKey] as TransformMap : transforms[fontKey] as TransformMap;

let newChar = chars[char] || char;
return newChar;
}).join('');
Expand Down
24 changes: 21 additions & 3 deletions src/slugs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ export const topicFonts: Record<TopicKey, FontKey[]> = {
"sansBoldItalic",
"serifBold",
"serifItalic",
"serifBoldItalic"
"serifBoldItalic",
"alternatingSerifBold",
"alternatingSansBold",
"alternatingBoldScript",
"alternatingBoldFraktur",
"alternatingSansBoldItalic",
"alternatingSerifBoldItalic"
],
twitter: [
"fraktur",
Expand All @@ -129,7 +135,13 @@ export const topicFonts: Record<TopicKey, FontKey[]> = {
"sansBoldItalic",
"serifBold",
"serifItalic",
"serifBoldItalic"
"serifBoldItalic",
"alternatingSerifBold",
"alternatingSansBold",
"alternatingBoldScript",
"alternatingBoldFraktur",
"alternatingSansBoldItalic",
"alternatingSerifBoldItalic"
],
whatsapp: [
"fraktur",
Expand All @@ -140,6 +152,12 @@ export const topicFonts: Record<TopicKey, FontKey[]> = {
"sansBoldItalic",
"serifBold",
"serifItalic",
"serifBoldItalic"
"serifBoldItalic",
"alternatingSerifBold",
"alternatingSansBold",
"alternatingBoldScript",
"alternatingBoldFraktur",
"alternatingSansBoldItalic",
"alternatingSerifBoldItalic"
]
}

0 comments on commit fe4655f

Please sign in to comment.