{"id":20128184,"url":"https://github.com/thenewdynamic/hugo-module-tnd-imgix","last_synced_at":"2025-03-02T21:23:51.059Z","repository":{"id":75047715,"uuid":"232644755","full_name":"theNewDynamic/hugo-module-tnd-imgix","owner":"theNewDynamic","description":"A imgix Hugo Module","archived":false,"fork":false,"pushed_at":"2021-05-10T20:06:34.000Z","size":34,"stargazers_count":8,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-13T08:28:22.440Z","etag":null,"topics":["hugo-module"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/theNewDynamic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2020-01-08T19:44:50.000Z","updated_at":"2023-05-01T07:02:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"84a11777-9321-433c-9dc5-7c1cca2291c0","html_url":"https://github.com/theNewDynamic/hugo-module-tnd-imgix","commit_stats":null,"previous_names":["thenewdynamic/hugo-module-imgix"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theNewDynamic%2Fhugo-module-tnd-imgix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theNewDynamic%2Fhugo-module-tnd-imgix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theNewDynamic%2Fhugo-module-tnd-imgix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theNewDynamic%2Fhugo-module-tnd-imgix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theNewDynamic","download_url":"https://codeload.github.com/theNewDynamic/hugo-module-tnd-imgix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241572354,"owners_count":19984258,"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":["hugo-module"],"created_at":"2024-11-13T20:26:04.023Z","updated_at":"2025-03-02T21:23:51.011Z","avatar_url":"https://github.com/theNewDynamic.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Imigx Hugo Module\n\nThe component should be used on any project using [imgix](https://www.imgix.com/) as an image transforming API.\n\n## Requirements\n\nRequirements:\n- Go 1.14\n- Hugo 0.61.0\n\n\n## Installation\n\nIf not already, [init](https://gohugo.io/hugo-modules/use-modules/#initialize-a-new-module) your project as Hugo Module:\n\n```\n$: hugo mod init {repo_url}\n```\n\nConfigure your project's module to import this module:\n\n```yaml\n# config.yaml\nmodule:\n  imports:\n  - path: github.com/theNewDynamic/hugo-module-tnd-imgix\n```\n\n## Usage\n\n### GetSRC\n\nThe only available public returning partial is `GetSRC`.\n\nIt returns, as a string, the Imigx URL of the passed image SRC with the optional passed transformation on top of the defaults transformations if any.\n\nThis takes two types of arguments.\n- A file path | String (.)\n  With the above, the function returns the file path prefixed with the imgix domain, with global defaults transformation if any.\n- A map | Map (.)\n  src: A file path | String\n  ...any other key will match a transformation from the imgix API and its value the property to be passed.\n  With the above, the function returns the file's imgix URI including the transformation query.\n\n#### Examples\n```\n{{ $src := \"/uploads/an-image.jpg\" }}\n{{ with partial \"tnd-imgix/GetSRC\" $src }}\n  {{ $src = . }}\n{{ end }}\n```\n\nWill produce: `https://imgix.project.net/uploads/an-image.jpg`\n\nNote: [Default set transformations](#defaults) will be appended.\n\n```\n{{ $args := dict \"src\" \"/uploads/an-image.jpg\" \"width\" 1024 \"height\" 100 }}\n{{ with partial \"tnd-imgix/GetSRC\" $args }}\n  {{ $src = . }}\n{{ end }}\n```\nWill produce: `https://imgix.project.net/uploads/an-image.jpg?w=1024\u0026h=100`\n\n### Settings\n\nSettings are added to the project's parameter under the `tnd_imgix` map as show below.\nKeys are detailed below\n\n```yaml\n# config.yaml\nparams:\n  tnd_imgix:\n    domain: imgix.project.net\n    mapping:\n      pixel: 'dpr'\n    defaults:\n      auto: format\n      ch: Width,DPR\n      q: 95\n    allowed_extensions:\n    - jpg\n    - png\n```\n\n#### Domain (required)\n\nThis is the imgix domain of your project.\n\n#### IMGIX API mapping.\n\nTo abstract the imgix terminology, the module interprets commonly used transformation keys. \nUser can therefor use `width` and expect the function to find the proper Imgix key (`w`).\n\nKey absent from mapping settings will be passed as is.\n\nDefault mapping is:\n```yaml\n  width: 'w'\n  height: 'h'\n  quality: 'q'\n  text: 'txt'\n```\n\nUser can overwrite the above mapping with adding their own mapping keys to the imgix parameters.\n\n```yaml\nparams:\n  tnd_imgix:\n    mapping:\n      pixel: 'dpr'\n```\n\n\nGiven the example above, passing the following arguments to `tnd-imgix/GetSRC`\n```\n{{ $src := \"/uploads/an-image.jpg\" }}\n{{ $args := dict \"src\" $src \"width\" 1024 \"pixel\" 2 \"ch\" \"Width,DPR\" }}\n```\n\nWill produce: `https://imgix.domain.com/image.jpg?w=1024\u0026dpr=2\u0026ch=Width,DPR`\n\n#### Defaults\n\nUser can add some sensible default transformations to the module. It will use them whenever the `GetSRC` function is called. \nIf one of the default keys is passed, its value will overwrite the default's.\n\n```yaml\nparams:\n  tnd_imgix:\n    defaults:\n      auto: format\n      ch: Width,DPR\n      q: 95\n```\n\nDefaults can be passed using the mapped keys discussed above (`width`, `quality` etc...)\n\n#### Allowed Extensions\n\nThe `allowed_extensions` key lets you define a list of extensions for which the module will apply transformations.\nThis is to make sure no transformation is applied to a PDF for example.\n\nDefaults are as followed:\n```yaml\nparams:\n  tnd_imgix:\n    allowed_extensions:\n    - jpg\n    - jp2\n    - jpeg\n    - png\n    - gif\n    - webp\n    - tif\n```\nThe settings does not extends aforementioned defaults with user's own. In order to complement the defaults, you should copy/paste the above to your settings and append with new extensions.\n\n## Markup\n\nWith a tiny bit of work you can have imgix applied to images rendered through Markdown.\n\n```markdown\n![Picture of a guitar](/uploads/guitar.jpg \"I love my guitar!\")\n```\n\nThis will make the above rendered as:\n\n```html\n\u003cimg src=\"https://my-domain.imgix.net/uploads/guitar.jpg?auto=format\u0026ch=Width,DPR\u0026q=95\u0026w=700\" alt=\"Picture of a guitar\" title=\"I love my guitar!\"\u003e\n```\n\nYou'll need to:\n\n1. Make sure your project is indeed using [Goldmark](https://gohugo.io/getting-started/configuration-markup#goldmark) as Markdown renderer (by default it should).\n2. Create at the root of your project a `layouts/_default/render-image.html`\n3. Populate given file with your own HTML and a touch of GetSRC.  \nThe module sports its own unused [template file](https://github.com/theNewDynamic/hugo-module-tnd-imgix/blob/master/markup/render-image.html) which you can use for reference.\n\n## theNewDynamic\n\nThis project is maintained and love by [thenewDynamic](https://www.thenewdynamic.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenewdynamic%2Fhugo-module-tnd-imgix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenewdynamic%2Fhugo-module-tnd-imgix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenewdynamic%2Fhugo-module-tnd-imgix/lists"}