Skip to content

Commit

Permalink
feat(match): new match template
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkz committed Jan 27, 2025
1 parent 01f2f0d commit e3a6599
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-coins-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'anki-templates': minor
---

feat(match): new match template
8 changes: 7 additions & 1 deletion build/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export const items: ConfigItem[] = [
{
key: 'entry',
len: 5,
variants: ['mcq', 'tf', 'basic', 'mcq_10'],
variants: [
'mcq',
'tf',
'basic',
'mcq_10',
'match',
] as const satisfies (keyof typeof entries)[],
},
{
key: 'locale',
Expand Down
26 changes: 26 additions & 0 deletions build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,32 @@ const entries = {
},
],
}),
match: defineEntry({
fields: ['question', 'items', 'note', 'Tags'],
notes: [
{
config: {
field: 'native',
},
fields: {
question:
'This is the stem of the question. It supports various content formats in Anki, including bold, formulas, etc.',
items: '',
note: 'note',
},
},
{
config: {
field: 'markdown',
},
fields: {
question: mdQuestion,
items: '',
note: 'note',
},
},
],
}),
};

export { entries };
2 changes: 1 addition & 1 deletion src/entries/basic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CardShell } from '../components/card-shell';
import { CardShell } from '@/components/card-shell';
import { FIELD_ID } from '@/utils/const';
import { isFieldEmpty } from '@/utils/field';
import * as t from 'at/i18n';
Expand Down
23 changes: 23 additions & 0 deletions src/entries/match.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { CardShell } from '@/components/card-shell';
import { FIELD_ID } from '@/utils/const';
import { isFieldEmpty } from '@/utils/field';
import * as t from 'at/i18n';
import { AnkiField } from 'at/virtual/field';

export default () => {
const hasNote = !isFieldEmpty(FIELD_ID('note'));

return (
<CardShell
title={t.question}
answer={
hasNote ? (
<AnkiField
name="note"
className={'prose prose-sm dark:prose-invert'}
/>
) : null
}
/>
);
};

0 comments on commit e3a6599

Please sign in to comment.