{"id":18552381,"url":"https://github.com/traviswimer/gatsby-plugin-scheduled-publishing","last_synced_at":"2025-05-15T11:12:43.405Z","repository":{"id":56855785,"uuid":"526008390","full_name":"traviswimer/gatsby-plugin-scheduled-publishing","owner":"traviswimer","description":"Auto-publish content to a Gatsby app by committing publish dates to your repo.","archived":false,"fork":false,"pushed_at":"2023-02-04T15:46:18.000Z","size":1792,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-26T11:39:08.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/traviswimer.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}},"created_at":"2022-08-18T01:12:40.000Z","updated_at":"2022-08-18T01:16:48.000Z","dependencies_parsed_at":"2023-02-18T17:30:37.784Z","dependency_job_id":null,"html_url":"https://github.com/traviswimer/gatsby-plugin-scheduled-publishing","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traviswimer%2Fgatsby-plugin-scheduled-publishing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traviswimer%2Fgatsby-plugin-scheduled-publishing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traviswimer%2Fgatsby-plugin-scheduled-publishing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traviswimer%2Fgatsby-plugin-scheduled-publishing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/traviswimer","download_url":"https://codeload.github.com/traviswimer/gatsby-plugin-scheduled-publishing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328389,"owners_count":22052633,"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":[],"created_at":"2024-11-06T21:14:03.345Z","updated_at":"2025-05-15T11:12:38.392Z","avatar_url":"https://github.com/traviswimer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"gatsby-plugin-scheduled-publishing\" src=\"https://raw.githubusercontent.com/traviswimer/gatsby-plugin-scheduled-publishing/main/gatsby-plugin-scheduled-publishing-logo.png\" width=\"400\" /\u003e\n\u003c/p\u003e\n\n\u003e `gatsby-plugin-scheduled-publishing` helps you auto-publish content without requiring a \"data source\".\n\n- [Learn about the problems this plugin solves.](#problem-explanation)\n- [Getting Started](#getting-started)\n- [Read Blog Post tutorial on using this plugin to automatically publish content](https://traviswimer.com/blog/auto-publish-gatsby-blog-using-github-actions)\n- [API reference](#api)\n- [Advanced Examples](#examples)\n\n\u003ch2 id=\"problem-explanation\"\u003eWhat problems does this solve?\u003c/h2\u003e\n\nSometimes you want to add new content to your Gatsby site, but only want it to be published after a certain date.\n\nNormally, this would mean using a [data source](https://support.gatsbyjs.com/hc/en-us/articles/1500000907821-Hosting-and-Data-Source-Integrations) such as a CMS.\n\nThis plugin allows you to simply commit the scheduled date to your repo instead.\n\n**Triggering the build**\n\nThis plugin only affects what is included in a build. How you generate a new build will depend on your setup.\n\nTo get a better idea, you can read this blog post: [How To Auto-publish Gatsby Blog using Github Actions](https://traviswimer.com/blog/auto-publish-gatsby-blog-using-github-actions).\n\n\u003ch2 id=\"getting-started\"\u003eGetting Started\u003c/h2\u003e\n\n### Install\n\n**Yarn:**\n\n```shell\nyarn add gatsby-plugin-scheduled-publishing\n```\n\n**NPM:**\n\n```shell\nnpm install gatsby-plugin-scheduled-publishing\n```\n\n## General Usage\n\n```javascript\n// gatsby-config.js\n\nconst config = {\n\tplugins: [\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tpublishDate: (node) =\u003e node.frontmatter?.myPublishDate, // Required\n\n\t\t\t\tgroup: \"BlogPosts\", // Optional\n\t\t\t\ttimezone: \"America/New_York\", // Optional\n\t\t\t\tdelayInMinutes: 60 * 6, // Optional\n\t\t\t\tdateFormat: \"yyyy-MM-dd\", // Optional\n\t\t\t},\n\t\t},\n\t],\n};\n```\n\nThis example will look for any Gatsby Data Node (object returned by Gatsby GraphQL queries) that includes the property `frontmatter.myPublishDate`. It will then evaluate the value of this property as a date and compare it to the the current date to determine if it has been published.\n\nThen you can query the data like this:\n\n```javascript\n// src/pages/MyPage.js\n\nexport default function MyPage({ data }) {\n\tconst { title, myPublishDate } = data.blogPosts;\n\treturn (\n\t\t\u003cmain\u003e\n\t\t\t\u003ch1\u003e{title}\u003c/h1\u003e\n\t\t\t\u003ch2\u003ePublished on: {myPublishDate}\u003c/h2\u003e\n\t\t\u003c/main\u003e\n\t);\n}\n\nexport const query = graphql`\n\tquery published {\n\t\tblogPosts: allPublished {\n\t\t\tfrontmatter {\n\t\t\t\tmyPublishDate\n\t\t\t\ttitle\n\t\t\t}\n\t\t}\n\t}\n`;\n```\n\nThis plugin creates `published` and `unpublished` node types. This means you can run GraphQL queries on `allPublished` and `allUnpublished`.\n\nIf you include the `group` name option, you can filter results like this:\n\n```javascript\nexport const query = graphql`\n\tquery published {\n\t\tblogPosts: allPublished(filter: { publishGroup: { eq: \"BlogPosts\" } }) {\n\t\t\tpublishGroup\n\t\t\tfrontmatter {\n\t\t\t\tmyPublishDate\n\t\t\t\ttitle\n\t\t\t}\n\t\t}\n\t}\n`;\n```\n\n\u003ch2 id=\"api\"\u003ePlugin Options API\u003c/h2\u003e\n\n`publishDate`: _Function_\n\nThis function will run for every Gatsby GraphQL Node that is created in your app. It receives one parameter, which is the current `Node`.\n\nIf you want the `Node` to be included for scheduled publishing, return a string representing a date. If you return `undefined` or an invalid date string, the `Node` will not be included.\n\nIf that date is later than or equal to the current date, it will be considered **published**. If it is earlier than the current date, it will be considered **unpublished**.\n\nIn both cases, a boolean \"`isPublished`\" `field` will be added to the `Node` (`node.fields.isPublished`). The `Node` will also be included in either the `published()` \u0026 `allPublished()` GraphQL queries or the `unpublished()` \u0026 `allUnpublished()` GraphQL queries.\n\n**Simple example**\n\n```javascript\nconst config = {\n\tplugins: [\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tpublishDate: (node) =\u003e node.frontmatter?.myPublishDate,\n\t\t\t},\n\t\t},\n\t],\n};\n```\n\nIn this example, it will search all nodes that contain a `frontmatter` object, which has a `myPublishDate`.\n\n**Complex data example**\n\n```javascript\nconst config = {\n\tplugins: [\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tpublishDate: ({ frontmatter = {} }) =\u003e {\n\t\t\t\t\tconst { year, month, day } = frontmatter;\n\t\t\t\t\tif ((year, month, day)) {\n\t\t\t\t\t\treturn `${frontmatter.year}-${frontmatter.month}-${frontmatter.day}`;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t],\n};\n```\n\nIn this example, the year, month, and day are all separate properties on the `Node`, so the function returns a string that combines them all together. If any of them are not defined, it will return `undefined`, and the `Node` will not be included.\n\n`dateFormat`: _string_ - _optional_\n\nThis is the date format that will be expected when a date is found with `publishDate`.\n\nIf this options is not provided, it will expect dates to be in [ISO format](https://www.w3.org/QA/Tips/iso-date) (e.g. `yyyy-MM-dd`).\n\nThis plugin uses a library called [Luxon](https://moment.github.io/luxon/#/) to work with dates. You can find all supported date format options in [Luxon's date format documentation](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).\n\nExample:\n\n```javascript\nconst config = {\n\tplugins: [\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tpublishDate: (node) =\u003e node.frontmatter?.date;\n\t\t\t\tdateFormat: \"yyyy-dd-MM\"\n\t\t\t},\n\t\t},\n\t],\n};\n```\n\n`timezone`: _string_ - _optional_ (Default: `\"UTC\"`)\n\nThis is the timezone you want to use for the publish date. To see all supported timezone strings refer to the [IANA Timezone List](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#list).\n\n`delayInMinutes`: _number_ - _optional_ (Default: `0`)\n\nAllows you to specify the time of day to publish. It is passed in using the number of minutes.\n\nFor example, to set it for 5:45am you would pass `60 * 5 + 45`. For 2:30pm, you would pass `60 * 14 + 30`.\n\n\u003ch2 id=\"examples\"\u003eExamples\u003c/h2\u003e\n\n**Multiple instances example**\n\n```javascript\nconst config = {\n\tplugins: [\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tgroup: \"BlogPosts\",\n\t\t\t\tpublishDate: (node) =\u003e {\n\t\t\t\t\tif(node.isBlogPost){\n\t\t\t\t\t\treturn node.frontmatter?.myPublishDate\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tresolve: `gatsby-plugin-scheduled-publishing`,\n\t\t\toptions: {\n\t\t\t\tgroup: \"OtherContent\",\n\t\t\t\tpublishDate: (node) =\u003e {\n\t\t\t\t\treturn node.startDate,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport const query = graphql`\n\tquery published {\n\t\tblogPosts: allPublished(filter: { publishGroup: { eq: \"BlogPosts\" } }) {\n\t\t\tpublishGroup\n\t\t\tfrontmatter {\n\t\t\t\tmyPublishDate\n\t\t\t\ttitle\n\t\t\t}\n\t\t}\n\n\t\totherContent: allPublished(filter: { publishGroup: { eq: \"OtherContent\" } }) {\n\t\t\tpublishGroup\n\t\t\tstartDate\n\t\t\tcontent\n\t\t}\n\t}\n`;\n```\n\n## How to contribute\n\nOpen an issue for bug reports, feature requests, etc.\n\nPull requests are appreciated, but it should be discussed in an issue first.\n\n## How to run tests\n\n```shell\nyarn test\n```\n\n## How to develop locally\n\nUse the following command to build and watch for changes:\n\n```shell\nyarn start\n```\n\nTo test the plugin inside a Gatsby project, you can use `yarn link`.\n\nFirst run this command inside the plugin repo:\n\n```shell\nyarn link\n```\n\nThen run this command inside your gatsby project:\n\n```shell\nyarn link gatsby-plugin-scheduled-publishing\n```\n\n## Project Links\n\n- [NPM](https://www.npmjs.com/package/gatsby-plugin-scheduled-publishing)\n- [GitHub](https://github.com/traviswimer/gatsby-plugin-scheduled-publishing)\n\n## Author\n\n#### Travis Wimer\n\n- \u003ca href=\"https://traviswimer.com/developer-portfolio\" title=\"React Native, React, NodeJS, UI/UX Developer\" target=\"_blank\"\u003eDeveloper Portfolio\u003c/a\u003e\n- \u003ca href=\"https://traviswimer.com/blog\" title=\"React Native, React, NodeJS, UI/UX Blog\" target=\"_blank\"\u003eBlog\u003c/a\u003e\n- \u003ca href=\"https://www.linkedin.com/in/traviswimer/\" title=\"Developer Resume\" target=\"_blank\"\u003eLinkedIn\u003c/a\u003e\n- \u003ca href=\"https://twitter.com/Travis_Wimer\" title=\"Travis Wimer | Software Developer\" target=\"_blank\"\u003eTwitter\u003c/a\u003e\n- \u003ca href=\"https://traviswimer.com/developer-portfolio/gatsby-plugin-scheduled-publishing\" title=\"gatsby-plugin-scheduled-publishing | Travis Wimer\" target=\"_blank\"\u003egatsby-plugin-scheduled-publishing Portfolio Page\u003c/a\u003e\n\n## License\n\nMIT. Copyright © 2022 Travis Wimer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraviswimer%2Fgatsby-plugin-scheduled-publishing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftraviswimer%2Fgatsby-plugin-scheduled-publishing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraviswimer%2Fgatsby-plugin-scheduled-publishing/lists"}