Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

Reference · Flag source and framing metadata

FlagRecordtype

Where one flag's drawing comes from, under what licence, and why that drawing was chosen.

Import it

import type { FlagRecord } from "@johnmorrisdotca/hata/manifest";

Definition

interface FlagRecord {
    code: string;
    source: FlagSource;
    file: string;
    page: string;
    version: string | null;
    wikidata: string;
    licence: {
        kind: LicenceKind;
        name: string;
        url: string | null;
    };
    author: string | null;
    credit: string | null;
    attributionRequired: boolean;
    restrictions: string[];
    templates: string[];
    uploaded: string | null;
    fetched: string;
    reference: {
        file: string;
        page: string;
        licence: string;
    } | null;
    why: string;
    sameAs: string | null;
    width: number;
    height: number;
    bytes: number;
    gzip: number;
    notes: string[];
    disputed: boolean;
    defaultVariant: string | null;
    variants: Variant[];
    framings: Record<"4:3" | "1:1" | "round", Framing>;
}

Members

NameTypeDescription
codestring

The code, as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX".

sourceFlagSource

Where the drawing comes from: commons, flag-icons or country-flag-icons.

filestring

The file: its name on Commons without "File:", or its path in the flag set ("3x2/YE.svg").

pagestring

Where to see it: the file's page on Commons, with its licence and history, or the set's file on jsDelivr at its version.

versionstring | null

The flag set's version the drawing is from; null for Commons.

wikidatastring

The Wikidata item whose flag image (P41) names the file: "Q17".

licence{ kind: LicenceKind; name: string; url: string | null; }

The licence: its kind, its name ("Public domain", "CC BY 4.0", "MIT") and its address where it has one.

authorstring | null

The author: as Commons' Artist field gives it, in plain text, or the set's copyright line; null where none is named.

creditstring | null

The credit line Commons gives, in plain text; null where there is none.

attributionRequiredboolean

True where the licence asks for credit (Commons says so, or the set's MIT notice must travel with it).

restrictionsstring[]

Restrictions Commons notes on the flag apart from copyright, as it spells them: "insignia", "trademarked".

templatesstring[]

The licence and restriction templates on the Commons file's page, without "Template:"; empty for a set's drawing.

uploadedstring | null

The day the Commons file's current version was uploaded, YYYY-MM-DD; null for a set's drawing.

fetchedstring

The day Wikidata and Commons were read for this package, YYYY-MM-DD.

reference{ file: string; page: string; licence: string; } | null

Where the drawing is a set's: the Commons file Wikidata names, which it was compared with, and that file's licence. Null for Commons.

whystring

Why this drawing was chosen over the others, in a sentence or two.

sameAsstring | null

The code whose picture this is, where two places fly one flag (Bouvet Island flies Norway's); null otherwise.

widthnumber

The viewBox's width: the flag's aspect ratio is width / height.

heightnumber

The viewBox's height.

bytesnumber

The size of the optimised SVG, in bytes.

gzipnumber

Its size gzipped at level 9, in bytes.

notesstring[]

Things worth knowing about the picture: text drawn with a font, an embedded raster picture.

disputedboolean

True where more than one authority or community claims the place's flag at the same time (Afghanistan, Northern Ireland); this package takes no side, and says why each default was chosen (README).

defaultVariantstring | null

The id of the variant flag(code) gives; null where the place has one flag (variants is then empty) or none of its own by default.

variantsVariant[]

Every flag of the place in real use, the default's included, each with its status and reason; empty where the place has one flag. See Variant.

framingsRecord<"4:3" | "1:1" | "round", Framing>

How the flag is framed at 4:3, square and round by flag(code, { shape }), and by frame(); see Framing.

Examples

import { manifest, type FlagRecord } from "@johnmorrisdotca/hata/manifest";

const tokyo: FlagRecord | null = manifest("JP-13");
if (tokyo !== null) console.log(tokyo.page, tokyo.licence.name, tokyo.width / tokyo.height);
https://commons.wikimedia.org/wiki/File:Flag_of_Tokyo_Metropolis.svg Public domain 1.5

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.6.0.