Skip to content

Commit

Permalink
feat: lang document is now optional + consistent field namings
Browse files Browse the repository at this point in the history
/spend 2m
  • Loading branch information
nico-i committed Mar 31, 2024
1 parent cd310f2 commit b2702d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/entities/cert/cert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class Cert extends LocalizedEntity {
locale: Locale,
public readonly issuer: string,
received: string | Date,
public readonly infoMdStr: Markdown,
public readonly mdInfo: Markdown,
public readonly doc?: Doc,
public readonly url?: InstanceType<typeof URL>
) {
Expand Down
20 changes: 10 additions & 10 deletions src/entities/lang/repo/strapi/strapi-lang-repo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { InvalidLocalizedEntityError } from "@/entities/entity";
import { Lang } from "@/entities/lang";
import {
InvalidLangDocError,
InvalidLangIconError,
type LangRepo,
} from "@/entities/lang/repo/lang-repo";
Expand Down Expand Up @@ -35,16 +34,17 @@ export class StrapiLangRepo implements LangRepo {
}
langIcon = new Svg(new URL(icon.data.attributes.url));

let langDoc: Doc | undefined = undefined;
if (resLang.attributes.doc) {
if (!resLang.attributes.doc.data?.attributes?.url) {
throw new InvalidLangDocError("url not found in doc data attributes");
}
langDoc = new Doc(new URL(resLang.attributes.doc.data.attributes.url));
}

langs.push(
new Lang(resLang.id, new Locale(locale), name, langIcon, level, langDoc)
new Lang(
resLang.id,
new Locale(locale),
name,
langIcon,
level,
resLang.attributes.doc?.data?.attributes?.url
? new Doc(new URL(resLang.attributes.doc.data.attributes.url))
: undefined
)
);
}

Expand Down

0 comments on commit b2702d5

Please sign in to comment.