├── .nvmrc ├── .gitignore ├── robots.txt ├── .eleventyignore ├── logo.png ├── urls ├── example.md ├── nho.md └── urls.json ├── favicon.ico ├── netlify.toml ├── redirects.njk ├── 404.md ├── .eleventy.js ├── .github ├── .kodiak.toml └── workflows │ └── upgrade-dependencies.yml ├── _includes ├── html-redirect.njk └── default.njk ├── index.md ├── htaccess.njk ├── package.json ├── LICENSE.md ├── safari-pinned-tab.svg └── README.md /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | _site/ -------------------------------------------------------------------------------- /robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /.eleventyignore: -------------------------------------------------------------------------------- 1 | README.md 2 | LICENSE.md 3 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nhoizey/1y/master/logo.png -------------------------------------------------------------------------------- /urls/example.md: -------------------------------------------------------------------------------- 1 | --- 2 | url: https://www.example.com/ 3 | --- 4 | -------------------------------------------------------------------------------- /urls/nho.md: -------------------------------------------------------------------------------- 1 | --- 2 | url: https://nicolas-hoizey.com/ 3 | --- 4 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nhoizey/1y/master/favicon.ico -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "npm run build" 3 | publish = "_site" 4 | -------------------------------------------------------------------------------- /urls/urls.json: -------------------------------------------------------------------------------- 1 | { 2 | "permalink": "/{{ page.fileSlug }}/", 3 | "layout": "html-redirect.njk", 4 | "tags": "urls" 5 | } -------------------------------------------------------------------------------- /redirects.njk: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: _redirects 3 | --- 4 | 5 | {%- for url in collections.urls -%} 6 | /{{ url.fileSlug }} {{ url.data.url }} 301! 7 | {% endfor %} -------------------------------------------------------------------------------- /404.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Link not found 3 | layout: default.njk 4 | permalink: 404.html 5 | --- 6 | 7 | This link doesn't exist (yet, or anymore), sorry. 8 | 9 | Go [back home](/)… -------------------------------------------------------------------------------- /.eleventy.js: -------------------------------------------------------------------------------- 1 | module.exports = function (eleventyConfig) { 2 | eleventyConfig.addPassthroughCopy("logo.png"); 3 | eleventyConfig.addPassthroughCopy("favicon.ico"); 4 | eleventyConfig.addPassthroughCopy("safari-pinned-tab.svg"); 5 | eleventyConfig.addPassthroughCopy("robots.txt"); 6 | }; -------------------------------------------------------------------------------- /.github/.kodiak.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [merge] 4 | automerge_label = 'automerge 🤞' 5 | 6 | # https://kodiakhq.com/docs/recipes#better-merge-messages 7 | [merge.message] 8 | title = "pull_request_title" 9 | body = "pull_request_body" 10 | include_pr_number = true 11 | body_type = "markdown" 12 | strip_html_comments = true 13 | -------------------------------------------------------------------------------- /_includes/html-redirect.njk: -------------------------------------------------------------------------------- 1 | 2 | Redirecting to {{ url }} 3 | 4 | 7 |

You should have been redirected to this URL:

8 |

{{ url }}

9 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-dependencies.yml: -------------------------------------------------------------------------------- 1 | name: Upgrade dependencies 2 | 3 | on: 4 | schedule: 5 | # https://crontab.guru/#0_8_*_*_1 6 | - cron: '0 8 * * 1' 7 | workflow_dispatch: 8 | 9 | concurrency: 10 | group: upgrade-dependencies 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | upgrade-dependencies: 15 | uses: nhoizey/upgrade-dependencies/.github/workflows/upgrade-dependencies.yml@main 16 | secrets: inherit 17 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default.njk 3 | --- 4 | 5 | **1y** is a short URL manager built with [Eleventy](https://www.11ty.dev/) (a.k.a. 11ty), the great JavaScript/Node.js based Static Site Generator. 6 | 7 | This is not a URL "shortener", as it doesn't process anything. Short and long versions of URLs are managed manually, so that short URLs can be "beautiful". 8 | 9 | It should be really easy to [create your own](https://github.com/nhoizey/1y) now. 10 | -------------------------------------------------------------------------------- /htaccess.njk: -------------------------------------------------------------------------------- 1 | --- 2 | permalink: .htaccess 3 | --- 4 | 5 | # Using Apache's mod_alias if available 6 | 7 | {%- for url in collections.urls %} 8 | Redirect 301 "/{{ url.fileSlug }}" "{{ url.data.url | safe }}" 9 | {%- endfor %} 10 | 11 | 12 | # Else, using Apache's mod_rewrite if available 13 | 14 | 15 | {%- for url in collections.urls %} 16 | RewriteRule ^{{ url.fileSlug }}$ {{ url.data.url | safe }} [QSA,L,R=301] 17 | {%- endfor %} 18 | 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "1y", 3 | "description": "A short URL manager", 4 | "version": "1.0.0", 5 | "author": { 6 | "name": "Nicolas Hoizey", 7 | "email": "nicolas@hoizey.com", 8 | "url": "https://nicolas-hoizey.com/", 9 | "twitter": "nhoizey", 10 | "github": "nhoizey" 11 | }, 12 | "license": "MIT", 13 | "scripts": { 14 | "start": "rimraf _site && eleventy --serve", 15 | "build": "rimraf _site && eleventy" 16 | }, 17 | "devDependencies": { 18 | "@11ty/eleventy": "^2.0.1", 19 | "rimraf": "^4.4.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Nicolas Hoizey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /_includes/default.njk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ title or pkg.name }} 8 | 9 | 10 | 11 | 12 | 57 | 58 | 59 | 60 |
61 |

{{ title or pkg.name }}

62 | {{ content | safe }} 63 |
64 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # **1y**: taking the 1t out of 11ty 😅 2 | 3 | 1y logo 4 | 5 | [![GitHub stars](https://img.shields.io/github/stars/nhoizey/1y.svg?style=for-the-badge&logo=github)](https://github.com/nhoizey/1y/stargazers) 6 | [![Follow @nhoizey@mamot.fr](https://img.shields.io/mastodon/follow/000262395?domain=https%3A%2F%2Fmamot.fr&style=for-the-badge&logo=mastodon&logoColor=white&color=6364FF)](https://mamot.fr/@nhoizey) 7 | 8 | ## What is this? 9 | 10 | **1y** is a short URL manager built with [Eleventy](https://www.11ty.dev/) (a.k.a. **1**1t**y**), the great JavaScript/Node based Static Site Generator. 11 | 12 | This is not a URL "shortener", as it doesn't process anything. Short and long versions of URLs are managed manually, so that short URLs can be "beautiful". 13 | 14 | ## How does it work? 15 | 16 | **1y** generates redirection rules from your set of data, each URL being stored in a Markdown file: 17 | 18 | - the `fileSlug` of the Markdown file (the filename without the extension [in 11ty language](https://www.11ty.dev/docs/data/#page-variable-contents)) is the short URL. For example, the Markdown file `nho.md` you'll find in this template repository is used to create the [https://\/**nho**](https:///nho) short URL. 19 | - the long URL is stored in the file's [Front Matter](https://www.11ty.dev/docs/data-frontmatter/), for example here the `nho.md` file only contains these 3 lines: 20 | ```markdown 21 | --- 22 | url: https://nicolas-hoizey.com/ 23 | --- 24 | ``` 25 | 26 | So for this example, when you go to [https://\/**nho**](https:///nho), it redirects you to . 27 | 28 | _If you don't want to manage many Markdown files for your short URLs, you can try [Suri](https://github.com/jstayton/suri), another Eleventy based short URL manager, which uses one single JSON file._ 29 | 30 | Redirection rules are generated in 4 formats to ease usage on different environments: 31 | 32 | - Apache HTTP server with [Alias module](https://httpd.apache.org/docs/current/en/mod/mod_alias.html) in a `.htaccess` file 33 | - Apache HTTP server with [Rewrite module](https://httpd.apache.org/docs/current/en/mod/mod_rewrite.html) (less efficient) in the same `.htaccess` file 34 | - [Netlify](https://netlify.com/) hosting with [redirects](https://docs.netlify.com/routing/redirects/) in a `_redirects` file 35 | - HTML pages with both [HTML redirect](https://css-tricks.com/redirect-web-page/#article-header-id-1) (`` tag) and [JavaScript Redirect](https://css-tricks.com/redirect-web-page/#article-header-id-2). This is only meant as a last resort, only there if previous formats don't work. Your HTTP server needs to be able to respond to [https://\/**nho**](https:///nho) with this actual ressource: [https://\/**nho/index.html**](https:///nho/index.html) 36 | 37 | You don't have to deal with any settings to chose which one to use, all 4 formats are generated at once. 38 | 39 | ## What do I have to do to use it? 40 | 41 | This repository is intended to be used as a template for creating your own repository. 42 | 43 | ### The easiest: use Netlify Deploy Button 44 | 45 | [![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/nhoizey/1y&stack=cms) 46 | 47 | Clicking the button above will: 48 | 49 | - create a new repository in your own GitHub account with **1y** code 50 | - and deploy a copy of this new repository to your Netlify account (you can create an account during this process if you don't have one). 51 | 52 | Each time you push changes to your Github repository (or add files directly with Github's Web interface), Netlify will build the new redirection files. 53 | 54 | ### If you want to use another hosting service: use the Github template 55 | 56 | 1. Click the Use this template green button in Github interface to create your own **1y** repository in your Github account 57 | 1. Clone or download the new repository to your local computer 58 | 1. (optional) If you don't have `npm` yet, [install npm](https://www.npmjs.com/get-npm) 59 | 1. Install **1y** dependencies with `npm install` 60 | 1. Add new short URLs as Markdown files in the `urls/` folder 61 | 1. Generate the redirection files with this command: `npm run build` 62 | 63 | Generated files to deploy are in the `_site` folder. 64 | 65 | ## Contribution 66 | 67 | You are welcome and encouraged to make changes to this website by submitting pull requests! 68 | 69 | ## License 70 | 71 | [MIT](http://opensource.org/licenses/MIT) 72 | 73 | Copyright (c) 2020-present, Nicolas Hoizey 74 | --------------------------------------------------------------------------------