{"id":19967270,"url":"https://github.com/ladicle/tcardgen","last_synced_at":"2025-04-12T17:45:45.542Z","repository":{"id":48412875,"uuid":"273729493","full_name":"Ladicle/tcardgen","owner":"Ladicle","description":"Generate a TwitterCard(OGP) image for your Hugo posts.","archived":false,"fork":false,"pushed_at":"2025-03-18T00:24:17.000Z","size":3084,"stargazers_count":185,"open_issues_count":5,"forks_count":47,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T21:11:50.064Z","etag":null,"topics":["go","hacktoberfest","hugo","image-processing","ogp","twitter-card"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ladicle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Ladicle"]}},"created_at":"2020-06-20T15:01:00.000Z","updated_at":"2025-03-25T11:27:16.000Z","dependencies_parsed_at":"2024-01-22T09:03:53.348Z","dependency_job_id":"a705f63b-15b7-4f78-b17c-4d9fa3ce19c4","html_url":"https://github.com/Ladicle/tcardgen","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ladicle%2Ftcardgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ladicle%2Ftcardgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ladicle%2Ftcardgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ladicle%2Ftcardgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ladicle","download_url":"https://codeload.github.com/Ladicle/tcardgen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609564,"owners_count":21132916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","hacktoberfest","hugo","image-processing","ogp","twitter-card"],"created_at":"2024-11-13T02:40:49.066Z","updated_at":"2025-04-12T17:45:45.521Z","avatar_url":"https://github.com/Ladicle.png","language":"Go","funding_links":["https://github.com/sponsors/Ladicle"],"categories":[],"sub_categories":[],"readme":"# Twitter Card Image Generator\n\nGenerate Twitter card (OGP) images for your blog posts.\nSupported front-matters are title, author, categories, tags, and date.\nAlso, both toml and yaml formats are supported.\n\n![sample](./example/blog-post2.png)\n\n## Installation\n\n### Homebrew\n\n```bash\nbrew install Ladicle/tap/tcardgen\n```\n\n### Go version \u003c 1.16\n\n```bash\ngo get github.com/Ladicle/tcardgen@latest\n```\n\n### Go 1.16+\n\n```bash\ngo install github.com/Ladicle/tcardgen@latest\n```\n\n## Getting Started\n\n1. Install `tcardgen` command\n2. Download your favorite TrueType fonts (the above sample use [KintoSans](https://github.com/ookamiinc/kinto))\n3. Create template image (The easyest way is to replace the author image of the template in the [example](./example) directory.)\n4. Run the following command\n\n\u003e **NOTE**: `tcardgen` parses a font style from the file name,\n\u003e so the font file must follow the naming rule (`\u003cname\u003e-\u003cstyle\u003e.ttf`), and arrange font files as follows:\n\n```bash\n$ tree font/\nfont/\n├── KintoSans-Bold.ttf\n├── KintoSans-Medium.ttf\n└── KintoSans-Regular.ttf\n\n0 directories, 3 files\n\n$ tcardgen -f path/to/fontDir \\\n           -o path/to/hugo/static/imgDir \\\n           -t path/to/templateFile \\\n           path/to/hugo/content/posts/*.md\n```\n\nAfter successfully executing the command, a PNG image with the same name as the specified content name is generated in the output directory.\n\n## Advanced Generation\n\nIf you want to change the color, style, or position of text, you can pass a configuration file with the `--config(-c)` option.\nRefer to the [example/template3.config.yaml](example/template3.config.yaml) to see how to configure it.\n\n```bash\n$ tcardgen -c example/template3.config.yaml example/blog-post2.md\nLoad fonts from \"font\" directory\nLoad template from \"example/template3.png\"\nSuccess to generate twitter card into out/blog-post2.png\n```\n\n### Result\n\u003cimg src=\"./example/template3-config-output.png\" width=\"300\"\u003e\n\n## OGP setting for Hugo Theme\n\nOn my blog, I place the generated images in the `static/tcard` directory. In order to load this image, I set the following OGP information for my blog theme.\nIf the thumbnail is defined in the post, it is used first. Otherwise, the generated Twitter Card is used. If the page is not blog post, to set the default image.\n\n```html\n\u003c!-- General --\u003e\n\u003cmeta property=\"og:url\" content=\"{{ .Permalink }}\" /\u003e\n\u003cmeta property=\"og:type\" content=\"{{ if .IsHome }}website{{ else }}article{{ end }}\" /\u003e\n\u003cmeta property=\"og:site_name\" content=\"{{ .Site.Title }}\" /\u003e\n\u003cmeta property=\"og:title\" content=\"{{ .Title }}\" /\u003e\n\u003cmeta property=\"og:description\" content=\"{{ with .Description -}}{{ . }}{{ else -}}{{ if .IsPage }}{{ substr .Summary 0 300 }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}\" /\u003e\n\u003cmeta property=\"og:image\" content=\"{{ if .Params.thumbnail -}}{{ .Params.thumbnail|absURL }}{{ else if hasPrefix .File.Path \"post\" -}}{{ path.Join \"tcard\" (print .File.BaseFileName \".png\") | absURL }}{{ else -}}{{ \"img/default.png\" | absURL }}{{ end -}}\" /\u003e\n\u003c!-- Twitter --\u003e\n\u003cmeta name=\"twitter:card\" content=\"summary_large_image\" /\u003e\n\u003cmeta name=\"twitter:site\" content=\"@{{ .Site.Params.twitterName }}\" /\u003e\n```\n\n### Generate images of updated articles\n\nYou can generate only the image of the updated article by using `git diff` and `tcardgen`.\n\n```bash\n$ git diff --name-only HEAD content/post |\\\n    xargs tcardgen -o static/tcard -f assets/fonts/kinto-sans -t assets/template.png\n```\n\n\n## Usage\n\n```bash\n$ tcardgen -h\nGenerate TwitterCard(OGP) images for your Hugo posts.\nSupported front-matters are title, author, categories, tags, and date.\n\nUsage:\n  tcardgen [-f \u003cFONTDIR\u003e] [-o \u003cOUTPUT\u003e] [-t \u003cTEMPLATE\u003e] [-c \u003cCONFIG\u003e] \u003cFILE\u003e...\n\nExamples:\n# Generate a image and output to the example directory.\ntcardgen --fontDir=font --output=example --template=example/template.png example/blog-post.md\n\n# Generate a image and output to the example directory as \"featured.png\".\ntcardgen --fontDir=font --output=example/featured.png --template=example/template.png example/blog-post.md\n\n# Generate multiple images.\ntcardgen --template=example/template.png example/*.md\n\n# Genrate an image based on the drawing configuration.\ntcardgen --config=config.yaml example/*.md\n\nFlags:\n  -c, --config string     Set a drawing configuration file.\n  -f, --fontDir string    Set a font directory. (default \"font\")\n  -h, --help              help for tcardgen\n      --outDir string     (DEPRECATED) Set an output directory.\n  -o, --output string     Set an output directory or filename (only png format). (default \"out\")\n  -t, --template string   Set a template image file. (default example/template.png)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladicle%2Ftcardgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladicle%2Ftcardgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladicle%2Ftcardgen/lists"}