Skip to content

Commit

Permalink
Rework footer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jul 12, 2024
1 parent 8944b1f commit b5a0bc4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
Binary file added assets/wikipedia-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import * as path from 'path';
export const languages = {
ja: 'JA',
zh: 'ZH',
};
export const linkCharacter = '⧉';

export const ASSETS_FOLDER = './assets';
export const WIKIPEDIA_ICON_FILENAME = 'wikipedia-icon.png';
export const WIKIPEDIA_ICON_FILEPATH = path.join(
ASSETS_FOLDER,
WIKIPEDIA_ICON_FILENAME
);
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getVersion } from './util/getVersion';
import { downloadDumps } from './util/downloadDumps';
import { readArgs } from './util/readArgs';
import { readAndProcessLines } from './util/readAndProcessLines';
import { WIKIPEDIA_ICON_FILEPATH } from './constants';

const outputZipName = (lang: string, date: string, version: string) =>
`${lang} Wikipedia [${date}] (v${version}).zip`;
Expand All @@ -27,6 +28,8 @@ const OUT_DIRECTORY = './out';
fileName: outputZipName(lang, date, version),
});

dict.addFile(WIKIPEDIA_ICON_FILEPATH, WIKIPEDIA_ICON_FILEPATH);

const processedLines = await readAndProcessLines(filePath, dict, lang, dev);

console.log(`Processed ${processedLines} lines, exporting zip...`);
Expand Down
36 changes: 18 additions & 18 deletions src/yomitan/processLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
StructuredContent,
StructuredContentNode,
} from 'yomichan-dict-builder/dist/types/yomitan/termbank';
import { languages, linkCharacter } from '../constants';
import * as path from 'path';
import { WIKIPEDIA_ICON_FILEPATH } from '../constants';

/**
* Reads a line and adds that term entry to the dictionary
Expand Down Expand Up @@ -88,37 +89,36 @@ function createReadMoreNode(
lang: string
): StructuredContentNode {
const articleLink = `https://${lang.toLowerCase()}.wikipedia.org/wiki/${termSlug}`;
const readTheRest = getReadMoreText(lang);
return {
tag: 'ul',
tag: 'div',
content: [
{
tag: 'li',
tag: 'span',
content: [
{
tag: 'img',
path: WIKIPEDIA_ICON_FILEPATH,
collapsed: false,
collapsible: false,
height: 1,
width: 1,
sizeUnits: 'em',
verticalAlign: 'middle',
},
' ',
{
tag: 'a',
href: articleLink,
content: readTheRest,
content: `Wikipedia`,
},
],
},
],
data: {
wikipedia: 'continue-reading',
wikipedia: 'footer',
},
style: {
listStyleType: `"${linkCharacter}"`,
textAlign: 'end',
},
};
}

function getReadMoreText(lang: string): string {
switch (lang) {
case languages.ja:
return '続きを読む';
case languages.zh:
return '查看更多';
default:
return 'Read more';
}
}

0 comments on commit b5a0bc4

Please sign in to comment.