{"id":30850441,"url":"https://github.com/andful/netlify-cms-widget-create-select","last_synced_at":"2025-09-07T06:03:26.280Z","repository":{"id":57310314,"uuid":"364343914","full_name":"Andful/netlify-cms-widget-create-select","owner":"Andful","description":"A simple create select widget for netlify-cms which allows creating entries. The create select widget's entries are up to date to the last website build. The create select can be populated by plain text file, json file, RSS feed or HTML page.","archived":false,"fork":false,"pushed_at":"2025-07-31T15:06:06.000Z","size":10004,"stargazers_count":8,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-07T06:02:05.520Z","etag":null,"topics":["html-page","hugo","netlify","netlify-cms","netlify-cms-widget","netlify-cms-widgets","rss-feed","select-widgets"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Andful.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-05-04T18:04:30.000Z","updated_at":"2025-07-31T15:06:11.000Z","dependencies_parsed_at":"2025-09-07T06:01:51.758Z","dependency_job_id":null,"html_url":"https://github.com/Andful/netlify-cms-widget-create-select","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Andful/netlify-cms-widget-create-select","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andful%2Fnetlify-cms-widget-create-select","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andful%2Fnetlify-cms-widget-create-select/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andful%2Fnetlify-cms-widget-create-select/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andful%2Fnetlify-cms-widget-create-select/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andful","download_url":"https://codeload.github.com/Andful/netlify-cms-widget-create-select/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andful%2Fnetlify-cms-widget-create-select/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274001213,"owners_count":25205211,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["html-page","hugo","netlify","netlify-cms","netlify-cms-widget","netlify-cms-widgets","rss-feed","select-widgets"],"created_at":"2025-09-07T06:01:34.831Z","updated_at":"2025-09-07T06:03:26.236Z","avatar_url":"https://github.com/Andful.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# netlify-cms-widget-create-select\n\n[Check out a demo!](https://andful.github.io/netlify-cms-widget-create-select/#/collections/test/entries/test)\n\nA simple create select widget for netlify-cms which allows creating entries. The create select widget's entries are up to date to the last website build. The create select can be populated by plain text file, json file, RSS feed or HTML page. \n\n## Install\n\nAs an npm package:\n\n```shell\nnpm install --save netlify-cms-widget-create-select\n```\n\n```js\nimport { CreatableSelectControl, CreatableSelectPreview } from 'netlify-cms-widget-create-select'\n\nCMS.registerWidget('create-select', CreatableSelectControl, CreatableSelectPreview);\n```\n\nVia `script` tag:\n\n```html\n\u003cscript src=\"https://unpkg.com/netlify-cms-widget-create-select@^1.1.0\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n  CMS.registerWidget('create-select', window.CreatableSelectControl, window.CreatableSelectPreview)\n\u003c/script\u003e\n```\n## How to use\n### Integrate with HTML page\n\nIf the built page has all the options you want in a specific html page you can scrape the options from that page.  \nFor example let's say `https://www.example.com/tags/` contains the following html page.\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\u003c/head\u003e\n\u003cbody\u003e\n    \u003col id=\"tag-list\"\u003e\n        \u003cli class=\"tag\" data-tag=\"tag-1\"\u003eTag 1\u003c/li\u003e\n        \u003cli class=\"tag\" data-tag=\"tag-2\"\u003eTag 2\u003c/li\u003e\n        \u003cli class=\"tag\" data-tag=\"tag-3\"\u003eTag 3\u003c/li\u003e\n    \u003c/ol\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\nYou can query the options `tag-1`, `tag-2`, `tag-3` with the following configuration\n```yaml\nfields:\n  - name: 'tags'\n    label: 'Tags'\n    widget: 'create-select'\n    mode: 'html'\n    url: 'https://www.example.com/tags/'\n    query: '#tag-list \u003e .tag'\n    attribute: 'data-tag'\n    multiple: true\n```\n### Integrating with `sitemap.xml`\nYou can deduce the tags using the `sitemap.xml` file. For example if you want to match the string `https://www.example.com/tags/\u003ctag-value\u003e/` you can do it the following way.\n```yaml\n- name: 'sitemap'\n    label: 'Sitemap Example'\n    widget: 'create-select'\n    mode: 'xml'\n    url: 'sitemap.xml'\n    query: 'loc'\n    capture: '(?\u003c=https:\\/\\/www\\.example\\.com\\/tags\\/).+(?=\\/\\b)'\n    multiple: true\n```\n\n### Integrate with HUGO RSS feed\n\nMany HUGO website have `/tags/index.xml` page with the RSS feed of the tags. An example of the structure of such files is:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?\u003e\n\u003crss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\"\u003e\n  \u003cchannel\u003e\n    \u003ctitle\u003eTags on Hugo Themes\u003c/title\u003e\n    \u003clink\u003ehttps://www.example.com/tags/\u003c/link\u003e\n    \u003cdescription\u003eRecent content in Tags on Hugo Themes\u003c/description\u003e\n    \u003cgenerator\u003eHugo -- gohugo.io\u003c/generator\u003e\n    \u003catom:link href=\"https://www.example.com/tags/index.xml\" rel=\"self\" type=\"application/rss+xml\" /\u003e\n    \u003citem\u003e\n      \u003ctitle\u003etag1\u003c/title\u003e\n      \u003clink\u003ehttps://www.example.com/tags/tag-1/\u003c/link\u003e\n      \u003cpubDate\u003eMon, 11 Mar 2019 00:00:00 +0000\u003c/pubDate\u003e\n      \n      \u003cguid\u003ehttps://www.example.com/tags/tag-1/\u003c/guid\u003e\n      \u003cdescription\u003e\u003c/description\u003e\n    \u003c/item\u003e\n    \n    \u003citem\u003e\n      \u003ctitle\u003etag2\u003c/title\u003e\n      \u003clink\u003ehttps://www.example.com/tags/tag-2/\u003c/link\u003e\n      \u003cpubDate\u003eMon, 11 Mar 2019 00:00:00 +0000\u003c/pubDate\u003e\n      \n      \u003cguid\u003ehttps://www.example.com/tags/tag-2/\u003c/guid\u003e\n      \u003cdescription\u003e\u003c/description\u003e\n    \u003c/item\u003e\n  \u003c/channel\u003e\n\u003c/rss\u003e\n```\nThe RSS feed of the preview page can be used to populate the select widget.\nThis can be done the following way.\n```yaml\nfields:\n  - name: 'tags'\n    label: 'Tags'\n    widget: 'create-select'\n    mode: 'xml'\n    url: 'https://www.example.com/tags/index.xml'\n    query: 'item \u003e title'\n    multiple: true\n```\n### Integrate with HUGO using custom output.\nAlternativelly you can make a custom output on the page to populate the select widget.  \n* Make a custom output adding the following lines in the hugo `config.yaml` file\n  ```yaml\n  outputFormats:\n    Ingredients:\n        baseName: ingredients\n        isPlainText: true\n        mediaType: text/plain\n  ```\n* add a `layouts/_default/single.ingredients.txt` template file to generate the select options.\n  ```\n  {{- $scratch := .Scratch -}}\n  {{- with .Site.GetPage \"/recipes\" -}}\n    {{- range .Pages -}}\n      {{- range .Params.ingredients -}}\n        {{- $scratch.Set . true -}}\n      {{- end -}}\n    {{- end -}}\n  {{- end -}}\n  {{- range $key, $value := $scratch.Values -}}\n  {{- $key -}}{{- \"\\n\" -}}\n  {{- end -}}\n  ```\n* add a markdown file with the followind front-matter. For example `content/ingredients.md`\n  ```yaml\n  ---\n  _build:\n    list: false #prevent file to be listed in sitemap.xml\n  outputs: [ingredients]\n  ---\n  ```\n* Now when you compile the page with the command `hugo` there should be a file generated called `public/ingredients.txt`. The content of the file should be similar to the following:\n  ```\n  olive oil\n  salt\n  sugar\n  ```\n* You can add the followind confin in the netlify `config.yml` to have a select widget query from the `ingredients.txt` file:\n  ```yaml\n  fields:\n    - name: 'ingredients'\n      label: 'Ingredients'\n      widget: 'create-select'\n      url: 'https://www.example.com/ingredients.txt'\n      mode: 'plain'\n      multiple: true\n  ```\n## Configuration\n\nCreate-select widgets may have the following properties in addition to the defaults used by netlity.\n\n---\n\n`mode` - string - **required**\n\nEndpoint file type possible values being `\"html\"`, `\"xml\"`, `\"json\"`, `\"plain\"`.\n\n---\n\n`url` - string - **required**\n\nThe URI of the endpoint which to request the file to populate the select options.\n\n---\n\n`query` - string - **optional**\n\nQuery to obtain the data points.  \n* With `xml` or `html` modes the query is a css selector e.g. `query: \"div.chapter \u003e .title\"`. This field is **required**.\n* With `json` mode query is a dot separated chain of attributes e.g. `query: \"data.config.users\"`. If not specified the root object will be used. Note that the query should give an array type.\n* With `plain` mode this field will be ignored.\n---\n\n`attribute` - string - **optional** \n\nAttribute to use as value for each data points.\n* With `xml` or `html` modes this is an attribute of the element e.g. `class`, `id`, `data-attr`. If not sepcified the `textContent` will be used instead.\n* With `mode: json` query is a dot separated chain of attributes e.g. `attribute: \"name.firstName\"`. If not specified the root object will be used. Note that if the attribute does not give a string type the `JSON.stringify` of the json will be used.\n* With `plain` mode this field will be ignored.\n---\n\n`filter` - string - **optional** \n\nRegex for whitch the matching data point's value will be used otherwise the data point is filtered out. The filtering happens before the string is captured.\n\n---\n\n`capture` - string - **optional** \n\nRegex for whitch the matching content will be used by the widget. E.g. `capture: \"(?\u003c=https:\\\\/\\\\/www\\\\.example\\\\.com\\\\/tags\\\\/).+(?=\\\\/)\"` to capture `tag1` from the value `https://www.example.com/tags/tag1/`.  \nIf there is no match the data point will be removed.\n\n---\n\n`multiple` - boolean - **optional**\nAllow multiple entries.\n\n---\n\n`min` - number - **optional**\nMinimum number of entries.\n\n---\n\n`max` - number - **optional**\nMaximum number of entries.\n\n---\n\n\n\n## Support\n\nFor help with this widget, open an [issue](https://github.com/Andful/netlify-cms-widget-create-select).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandful%2Fnetlify-cms-widget-create-select","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandful%2Fnetlify-cms-widget-create-select","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandful%2Fnetlify-cms-widget-create-select/lists"}