0.0.2 • Published 3 years ago

genealogy-book v0.0.2

Weekly downloads
2
License
MIT
Repository
-
Last release
3 years ago

家譜預覽 genealogy-book

DEMO

用法 usage

預覽 Preview in React

import { GenealogyBook } from "./lib/index";

export default function Demo1() {
  return (
    <GenealogyBook
      title="青果巷周有光"
      tanghao="堂号"
      rootKey="231469165"
      data={data}
    />
  );
}

生成 PDF Generate html string for pdf

import { generateTotalHtml } from "./lib/index";
// 獲得家譜的html字符串 generate html string
const htmlStr = await generateTotalHFtml(
  "青果巷周有光",
  "堂号",
  "231469165",
  data
);
// 將html字符串生成html文件 generate html files from html strings
// 然後使用html轉pdf插件將html轉換為pdf  Then use html to pdf plugin to convert html to pdf.

在 Node.js 端,可以使用html-pdf
On the Node.js, you can use html-pdf.

參數 Props

NameDescribeRequired
title家譜名 Genealogy Nametrue
tanghao堂號 tanghaotrue
rootKey根節點 Key Root Node Idtrue
data家譜節點數據,結構見下方 genealogy node data, see below for data structuretrue
type世系圖或者世系表或者世系圖+世系表 Descent Chart or Descent Table or Descent Chart + Descent Table:sxt或者sxb或者 sxt, sxbfalse

data 數據結構

為了方便,使用 TypeScript 的方式來描述 use the TypeScript to describe the data structure

data: NodeMap;
interface NodeMap {
  [_key: string]: Node;
}
interface Node {
  i: string; // 節點key,Node id unique
  n: string; // 名 name
  x: 0 | 1; // 性別。0:男;1:女  sex. 0: male; 1: female
  f: string; // 父親key father id
  m: string; // 母親key mother id
  c: string[]; // 子女key children ids
  s: string[]; // 配偶key spouse ids
  vzi?: string; //字 zi
  vhao?: string; // 號 hao
  vmh?: string; // 名諱 Name tag
  vxm?: string; // 小名 Nickname
  vn?: string; // 傳記 Biography
  vb?: string; //出生時間 Time of Birth
  vd?: string; // 去世時間 Time of Death
  vsn?: string; // 享年 Age
  vzy?: string; //葬於地 Burialplace
  vcsd?: string; //出生地 Birthplace
  vjzd?: string; // 居住地 Residency
  vxy?: string; // 學歷 Education Background
  vhy?: string; // 行業 Industries
  vyj?: string; //原籍 Origin
  vqcz?: string; //遷出至 Move out to
  vbz?: string; // 備註 remarks
}

示例數據 Sample Data

rootKey = "231469165";

const data = {
  231085832: {
    i: "231085832",
    n: "周有光",
    x: 0,
    f: "231085849",
    m: "231085855",
    c: ["231099628", "231101857"],
    s: ["231086395"],
  },
  231085849: {
    i: "231085849",
    n: "周保贻",
    x: 0,
    f: "231085861",
    m: "231085867",
    c: [
      "231531189",
      "231531460",
      "231531025",
      "231530909",
      "231530700",
      "231540330",
      "231085832",
      "231605974",
      "231728162",
      "231728641",
      "231729307",
      "231729382",
    ],
    s: ["231085855", "231537784"],
  },
  231085855: {
    i: "231085855",
    n: "母亲",
    x: 1,
    postType: 1,
    f: "231085873",
    m: "231085879",

    c: [
      "231531189",
      "231531460",
      "231531025",
      "231530909",
      "231530700",
      "231540330",
      "231085832",
      "231605974",
    ],
    s: ["231085849"],
  },
  231085861: {
    i: "231085861",
    n: "逢吉公",
    x: 0,

    f: "231469165",
    m: "",

    c: [
      "231475172",
      "231475037",
      "231474740",
      "231474403",
      "231085849",
      "231475471",
    ],
    s: ["231085867"],
  },
  231085867: {
    i: "231085867",
    n: "左氏",
    x: 1,
    postType: 1,
    f: "",
    m: "",

    c: [
      "231475172",
      "231475037",
      "231474740",
      "231474403",
      "231085849",
      "231475471",
    ],
    s: ["231085861"],
  },
  231085873: {
    i: "231085873",
    n: "外公",
    x: 0,

    f: "",
    m: "",

    c: ["231085855", "231529785", "231529928"],
    s: ["231085879"],
  },
  231085879: {
    i: "231085879",
    n: "外婆",
    x: 1,
    postType: 1,
    f: "",
    m: "",

    c: ["231085855", "231529785", "231529928"],
    s: ["231085873"],
  },
  231086395: {
    i: "231086395",
    n: "张充和",
    x: 1,
    postType: 1,
    f: "231086666",
    m: "",

    c: ["231099628", "231101857"],
    s: ["231085832"],
  },
  231086666: {
    i: "231086666",
    n: "张武龄",
    x: 0,

    f: "231216830",
    m: "",

    c: ["231088356", "231086395", "231086692", "231091476"],
    s: [],
  },
  231086692: {
    i: "231086692",
    n: "张兆和",
    x: 1,
    postType: 1,
    f: "231086666",
    m: "",

    c: [],
    s: ["231087408"],
  },
  231087408: {
    i: "231087408",
    n: "沈从文",
    x: 0,

    f: "",
    m: "",

    c: [],
    s: ["231086692"],
  },
  231088356: {
    i: "231088356",
    n: "张元和",
    x: 1,
    postType: 1,
    f: "231086666",
    m: "",

    c: [],
    s: ["231089552"],
  },
  231089552: {
    i: "231089552",
    n: "顾传玠",
    x: 0,

    f: "231090035",
    m: "",

    c: [],
    s: ["231088356"],
  },
  231090035: {
    i: "231090035",
    n: "顾瑞卿",
    x: 0,

    f: "",
    m: "",

    c: ["231090624", "231089552"],
    s: [],
  },
  231090624: {
    i: "231090624",
    n: "顾传琳",
    x: 0,

    f: "231090035",
    m: "",

    c: [],
    s: [],
  },
  231091476: {
    i: "231091476",
    n: "张充和",
    x: 1,
    postType: 1,
    f: "231086666",
    m: "",

    c: ["231094497", "231092975"],
    s: ["231091889"],
  },
  231091889: {
    i: "231091889",
    n: "傅汉思",
    x: 0,

    f: "",
    m: "",

    c: ["231094497", "231092975"],
    s: ["231091476"],
  },
  231092975: {
    i: "231092975",
    n: "Ian H H Frankel",
    x: 0,

    f: "231091889",
    m: "231091476",

    c: [],
    s: [],
  },
  231094497: {
    i: "231094497",
    n: "Emma Frankel",
    x: 1,
    postType: 1,
    f: "231091889",
    m: "231091476",

    c: [],
    s: [],
  },
  231099628: {
    i: "231099628",
    n: "小禾",
    x: 1,
    postType: 1,
    f: "231085832",
    m: "231086395",

    c: [],
    s: [],
  },
  231101857: {
    i: "231101857",
    n: "周晓平",
    x: 0,

    f: "231085832",
    m: "231086395",

    c: ["231467217"],
    s: [],
  },
  231216830: {
    i: "231216830",
    n: "张树声",
    x: 0,

    f: "",
    m: "",

    c: ["231086666"],
    s: [],
  },
  231467217: {
    i: "231467217",
    n: "周和庆",
    x: 1,
    postType: 1,
    f: "231101857",
    m: "",

    c: [],
    s: [],
  },
  231469165: {
    i: "231469165",
    n: "周赞襄(润之公)",
    x: 0,

    f: "",
    m: "",

    c: ["231085861"],
    s: [],
  },
  231474403: {
    i: "231474403",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085861",
    m: "231085867",

    c: [],
    s: [],
  },
  231474740: {
    i: "231474740",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085861",
    m: "231085867",

    c: ["231502793", "231503158", "231503556"],
    s: [],
  },
  231475037: {
    i: "231475037",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085861",
    m: "231085867",

    c: ["231502202", "231502344"],
    s: ["231476303"],
  },
  231475172: {
    i: "231475172",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085861",
    m: "231085867",

    c: ["231501495", "231475631"],
    s: [],
  },
  231475471: {
    i: "231475471",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085861",
    m: "231085867",

    c: [],
    s: [],
  },
  231475631: {
    i: "231475631",
    n: "左起庆",
    x: 0,

    f: "",
    m: "231475172",

    c: [],
    s: [],
  },
  231476303: {
    i: "231476303",
    n: "高先生",
    x: 0,

    f: "",
    m: "",

    c: ["231502202", "231502344"],
    s: ["231475037"],
  },
  231501495: {
    i: "231501495",
    n: "佚名",
    x: 0,

    f: "",
    m: "231475172",

    c: [],
    s: [],
  },
  231502202: {
    i: "231502202",
    n: "佚名",
    x: 0,

    f: "231476303",
    m: "231475037",

    c: [],
    s: [],
  },
  231502344: {
    i: "231502344",
    n: "佚名",
    x: 0,

    f: "231476303",
    m: "231475037",

    c: [],
    s: [],
  },
  231502793: {
    i: "231502793",
    n: "佚名",
    x: 0,

    f: "",
    m: "231474740",

    c: [],
    s: [],
  },
  231503158: {
    i: "231503158",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "",
    m: "231474740",

    c: [],
    s: [],
  },
  231503556: {
    i: "231503556",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "",
    m: "231474740",

    c: [],
    s: [],
  },
  231529785: {
    i: "231529785",
    n: "佚名",
    x: 0,

    f: "231085873",
    m: "231085879",

    c: [],
    s: [],
  },
  231529928: {
    i: "231529928",
    n: "八妹",
    x: 1,
    postType: 1,
    f: "231085873",
    m: "231085879",

    c: [],
    s: [],
  },
  231530700: {
    i: "231530700",
    n: "周心闲",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: ["231726234", "231726322", "231726381"],
    s: [],
  },
  231530909: {
    i: "231530909",
    n: "周慧言",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: [],
    s: [],
  },
  231531025: {
    i: "231531025",
    n: "周慧兼",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: ["231733034", "231733953", "231734877", "231735223"],
    s: ["231567642"],
  },
  231531189: {
    i: "231531189",
    n: "佚名(早夭)",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: [],
    s: [],
  },
  231531460: {
    i: "231531460",
    n: "佚名(早夭)",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: [],
    s: [],
  },
  231537784: {
    i: "231537784",
    n: "姨太太",
    x: 1,
    postType: 1,
    f: "231728457",
    m: "",

    c: ["231728162", "231728641", "231729307", "231729382"],
    s: ["231085849"],
  },
  231540330: {
    i: "231540330",
    n: "福官(早夭)",
    x: 0,

    f: "231085849",
    m: "231085855",

    c: [],
    s: [],
  },
  231567642: {
    i: "231567642",
    n: "屠伯范",
    x: 0,

    f: "231568951",
    m: "231570352",

    c: ["231733034", "231733953", "231734877", "231735223"],
    s: ["231531025"],
  },
  231568951: {
    i: "231568951",
    n: "屠元博",
    x: 0,

    f: "",
    m: "",

    c: ["231567642"],
    s: ["231570352", "231570721"],
  },
  231570352: {
    i: "231570352",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "",
    m: "",

    c: ["231567642"],
    s: ["231568951"],
  },
  231570721: {
    i: "231570721",
    n: "朱氏",
    x: 1,
    postType: 1,
    f: "",
    m: "",

    c: [],
    s: ["231568951"],
  },
  231605974: {
    i: "231605974",
    n: "周俊人(九妹)",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231085855",

    c: [
      "231736957",
      "231737074",
      "231737706",
      "231738227",
      "231738418",
      "231738732",
      "231738940",
    ],
    s: ["231736795"],
  },
  231726234: {
    i: "231726234",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "",
    m: "231530700",

    c: [],
    s: [],
  },
  231726322: {
    i: "231726322",
    n: "佚名",
    x: 0,

    f: "",
    m: "231530700",

    c: [],
    s: [],
  },
  231726381: {
    i: "231726381",
    n: "佚名",
    x: 0,

    f: "",
    m: "231530700",

    c: [],
    s: [],
  },
  231728162: {
    i: "231728162",
    n: "佚名",
    x: 0,

    f: "231085849",
    m: "231537784",

    c: [],
    s: [],
  },
  231728457: {
    i: "231728457",
    n: "佚名",
    x: 0,

    f: "",
    m: "",

    c: ["231537784"],
    s: [],
  },
  231728641: {
    i: "231728641",
    n: "佚名",
    x: 0,

    f: "231085849",
    m: "231537784",

    c: ["411354718"],
    s: [],
  },
  231729307: {
    i: "231729307",
    n: "周埭",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231537784",

    c: ["231730917", "231731187", "231731391"],
    s: ["231730688"],
  },
  231729382: {
    i: "231729382",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231085849",
    m: "231537784",

    c: [],
    s: [],
  },
  231730688: {
    i: "231730688",
    n: "陈先生",
    x: 0,

    f: "",
    m: "",

    c: ["231730917", "231731187", "231731391"],
    s: ["231729307"],
  },
  231730917: {
    i: "231730917",
    n: "佚名",
    x: 0,

    f: "231730688",
    m: "231729307",

    c: [],
    s: [],
  },
  231731187: {
    i: "231731187",
    n: "陈大曼",
    x: 1,
    postType: 1,
    f: "231730688",
    m: "231729307",

    c: [],
    s: [],
  },
  231731391: {
    i: "231731391",
    n: "陈小曼",
    x: 1,
    postType: 1,
    f: "231730688",
    m: "231729307",

    c: ["231732251", "231732705"],
    s: ["231731551", "231731883"],
  },
  231731551: {
    i: "231731551",
    n: "佚名",
    x: 0,

    f: "",
    m: "",

    c: ["231732251", "231732705"],
    s: ["231731391"],
  },
  231731883: {
    i: "231731883",
    n: "任弥高",
    x: 0,

    f: "",
    m: "",

    c: [],
    s: ["231731391"],
  },
  231732251: {
    i: "231732251",
    n: "唐红",
    x: 1,
    postType: 1,
    f: "231731551",
    m: "231731391",

    c: [],
    s: [],
  },
  231732705: {
    i: "231732705",
    n: "佚名",
    x: 0,

    f: "231731551",
    m: "231731391",

    c: [],
    s: [],
  },
  231733034: {
    i: "231733034",
    n: "屠乐平",
    x: 0,

    f: "231567642",
    m: "231531025",

    c: [],
    s: [],
  },
  231733953: {
    i: "231733953",
    n: "佚名",
    x: 0,

    f: "231567642",
    m: "231531025",

    c: ["231734279", "231734409"],
    s: [],
  },
  231734279: {
    i: "231734279",
    n: "佚名",
    x: 0,

    f: "231733953",
    m: "",

    c: [],
    s: [],
  },
  231734409: {
    i: "231734409",
    n: "佚名",
    x: 1,
    postType: 1,
    f: "231733953",
    m: "",

    c: [],
    s: [],
  },
  231734877: {
    i: "231734877",
    n: "屠乐勤",
    x: 1,
    postType: 1,
    f: "231567642",
    m: "231531025",

    c: [],
    s: [],
  },
  231735223: {
    i: "231735223",
    n: "屠式枚",
    x: 1,
    postType: 1,
    f: "231567642",
    m: "231531025",

    c: [],
    s: [],
  },
  231736795: {
    i: "231736795",
    n: "毛先生",
    x: 0,

    f: "",
    m: "",

    c: [
      "231736957",
      "231737074",
      "231737706",
      "231738227",
      "231738418",
      "231738732",
      "231738940",
    ],
    s: ["231605974"],
  },
  231736957: {
    i: "231736957",
    n: "毛子迈",
    x: 0,

    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231737074: {
    i: "231737074",
    n: "毛子迅",
    x: 0,

    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231737706: {
    i: "231737706",
    n: "毛子远",
    x: 0,

    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231738227: {
    i: "231738227",
    n: "毛子逸",
    x: 0,

    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231738418: {
    i: "231738418",
    n: "毛晓帆",
    x: 1,
    postType: 1,
    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231738732: {
    i: "231738732",
    n: "毛晓园",
    x: 1,
    postType: 1,
    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  231738940: {
    i: "231738940",
    n: "毛晓舫",
    x: 1,
    postType: 1,
    f: "231736795",
    m: "231605974",

    c: [],
    s: [],
  },
  411354718: {
    i: "411354718",
    n: "",
    x: 0,

    f: "231728641",
    m: "",

    c: [],
    s: [],
  },
};
0.0.2

3 years ago

0.0.1

3 years ago