Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Commit

Permalink
feat(core): the base url cannot contain a sub-path
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Deployments under a subpath (e.g. `https://example.com/status/`) are no longer supported
  • Loading branch information
giovagnoli committed Mar 20, 2019
1 parent 801a2e9 commit e7ce6bc
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/@statusfy/common/index.js
Expand Up @@ -11,6 +11,7 @@ exports.postcss = require('./lib/postcss')
exports.esm = esm
exports.Dates = esm(path.join(__dirname, './lib/dates.js')).default

exports.url = require('url')
exports.toml = require('toml')
exports.tomlify = require('tomlify-j0.4')
exports.yaml = require('yaml')
Expand Down
2 changes: 1 addition & 1 deletion packages/@statusfy/core/lib/config/generate.js
Expand Up @@ -18,7 +18,7 @@ module.exports = function generateConfig(sourceDir, cliOptions) {
try {
if (siteConfigErrors && siteConfigErrors.length > 0) {
logger.fatal(
`Your site configuration is invalid\n${siteConfigErrors.join("\n")}`
`Your site configuration is invalid:\n${siteConfigErrors.join("\n")}`
);
process.exit(1);
}
Expand Down
12 changes: 11 additions & 1 deletion packages/@statusfy/core/lib/config/validate.js
@@ -1,4 +1,4 @@
const { chalk, validator } = require("@statusfy/common");
const { chalk, validator, url } = require("@statusfy/common");

const validFrontMatterFormats = ["yaml", "yml", "toml", "json"];

Expand Down Expand Up @@ -29,6 +29,16 @@ module.exports = function validateConfig(config) {
config.baseUrl
}.\nValid Example: ${chalk.cyan("https://status.yourbaseurl.com")}.`
);
} else {
const { pathname } = url.parse(config.baseUrl);

if (pathname && pathname !== "/") {
errors.push(
`Statusfy doesn't support deployments under a subpath (${chalk.cyan(
pathname
)}).`
);
}
}

// Make sure a trailing slash (at the end of the URL) is not defined
Expand Down
5 changes: 5 additions & 0 deletions packages/docs/src/config/README.md
Expand Up @@ -53,9 +53,14 @@ The Description for the site. This will be rendered as a `<meta>` tag in the pag
The base URL the site will be deployed at. It can be just a slash or a valid URL that shouldn't end with a slash.

::: warning
Since version `v0.3.0`, deployments under a subpath (e.g. `https://example.com/status/`) are no longer supported.
:::

::: tip
You should set the `baseUrl` field to your **production domain** in order to make [Alternate URLs fully-qualified](../guide/i18n.md#seo).
:::


## theme

- Type: `Object`
Expand Down
5 changes: 4 additions & 1 deletion packages/docs/src/es/config/README.md
Expand Up @@ -53,8 +53,11 @@ La Descripción para el sitio. Esto se representará como una etiqueta `<meta>`
La URL base en la que se desplegará el sitio. Puede ser solo una barra o una URL válida que no debe terminar con una barra.

::: warning ADVERTENCIA
Desde la versión `v0.3.0`, los despliegues bajo una sub-ruta (p.e. `https://ejemplo.com/status/`) ya no son soportados.
:::

Debe establecer el campo `baseUrl` como su **dominio de producción** para que las [URL alternativas sean completamente válidas](../guide/i18n.md#seo).
::: tip
Debes establecer el campo `baseUrl` como su **dominio de producción** para que las [URL alternativas sean completamente válidas](../guide/i18n.md#seo).

:::

Expand Down
15 changes: 12 additions & 3 deletions packages/docs/src/es/guide/deploy.md
Expand Up @@ -49,7 +49,12 @@ Las siguientes guías se basan en algunas suposiciones compartidas:

## GitHub Pages

1. Si no tiene ningún dominio personalizado, configura el `baseUrl` correcto en `config.js`. Por ejemplo, si estás desplegando a `https://<username>.github.io/<repo>/`, (por ejemplo, tu repositorio está en `https://github.com/<username>/<username>`), puedes establecer `baseUrl` como `"/<repo>/"` o `"https://<username>.github.io/<repo>/"` (recomendado).
1. Establece el dominio personalizado en `baseUrl` de tu `config.js`

::: warning ADVERTENCIA
Desde la versión `v0.3.0`, los despliegues bajo una sub-ruta (p.e. `https://<username>.github.io/<repo>/`) ya no son soportados. Necesitas establecer un [dominio personalizado](https://help.github.com/en/articles/quick-start-setting-up-a-custom-domain).
:::


2. Agrega un script de implementación a `package.json`:

Expand Down Expand Up @@ -87,9 +92,13 @@ Visita las [Páginas de GitHub](https://help.github.com/articles/using-a-custom-

## GitLab Pages y GitLab CI

1. Si no tiene ningún dominio personalizado, configura el `baseUrl` correcto en `config.js`. Por ejemplo, si estás desplegando a `https://<username or group>.gitlab.io/<repo>/`, (por ejemplo, tu repositorio está en `https://gitlab.com/<username or group>/<username or group>`), puedes establecer `baseUrl` como `"/<repo>/"` o `"https://<username or group>.gitlab.io/<repo>/"` (recomendado).
1. Establece el dominio personalizado en `baseUrl` de tu `config.js`

::: warning ADVERTENCIA
Desde la versión `v0.3.0`, los despliegues bajo una sub-ruta (p.e. `https://<username o group>.gitlab.io/<repo>/`) ya no son soportados. Necesitas establecer un [dominio personalizado](https://gitlab.com/help/user/project/pages/getting_started_part_three.md).
:::

2. Cree un archivo llamado `.gitlab-ci.yml` en la raíz de tu proyecto con el contenido a continuación. Esto construirá e implementará tu sitio cada vez que realices cambios en su contenido.
2. Crea un archivo llamado `.gitlab-ci.yml` en la raíz de tu proyecto con el contenido a continuación. Esto construirá e implementará tu sitio cada vez que realices cambios en su contenido.

```yaml
image: node:latest
Expand Down
21 changes: 15 additions & 6 deletions packages/docs/src/guide/deploy.md
Expand Up @@ -41,7 +41,11 @@ The following guides are based on a few shared assumptions:

## GitHub Pages

1. If you don't have any custom domain, set the correct `baseUrl` in `config.js`. For example, if you are deploying to `https://<username>.github.io/<repo>/`, (i.e. your repository is at `https://github.com/<username>/<username>`), you can set `baseUrl` to `"/<repo>/"` or `"https://<username>.github.io/<repo>/"` (recommended).
1. Set the custom domain in `baseUrl` from your `config.js`

::: warning
Since version `v0.3.0`, deployments under a subpath (e.g. `https://<username>.github.io/<repo>/`) are no longer supported. You need to set up a [custom domain](https://help.github.com/en/articles/quick-start-setting-up-a-custom-domain).
:::

2. Add a deploy script to `package.json`:

Expand All @@ -68,7 +72,7 @@ npm run generate # or yarn run generate
npm run deploy # or yarn run deploy
```

Visit the [GitHub Pages](https://help.github.com/articles/using-a-custom-domain-with-github-pages/) to learn how to setup custom domains and find out about advanced configurations.
Visit the [GitHub Pages](https://help.github.com/articles/using-a-custom-domain-with-github-pages/) to find out about advanced configurations.

### References

Expand All @@ -79,7 +83,12 @@ Visit the [GitHub Pages](https://help.github.com/articles/using-a-custom-domain-

## GitLab Pages and GitLab CI

1. If you don't have any custom domain, set the correct `baseUrl` in `config.js`. For example, if you are deploying to `https://<username or group>.gitlab.io/<repo>/`, (i.e. your repository is at `https://gitlab.com/<username or group>/<username or group>`), you can set `baseUrl` to `"/<repo>/"` or `"https://<username or group>.gitlab.io/<repo>/"` (recommended).
1. Set the custom domain in `baseUrl` from your `config.js`

::: warning
Since version `v0.3.0`, deployments under a subpath (e.g. `https://<username or group>.gitlab.io/<repo>/`) are no longer supported. You need to set up a [custom domain](https://gitlab.com/help/user/project/pages/getting_started_part_three.md).
:::


2. Create a file called `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content.

Expand All @@ -103,7 +112,7 @@ pages:
- master
```

Visit the [GitLab Pages](https://gitlab.com/help/user/project/pages/getting_started_part_one.md) to learn how to setup custom domains and find out about advanced configurations.
Visit the [GitLab Pages](https://gitlab.com/help/user/project/pages/getting_started_part_one.md) to find out about advanced configurations.

### References

Expand Down Expand Up @@ -169,9 +178,9 @@ firebase deploy

- [VuePress: Deploying to Firebase](https://vuepress.vuejs.org/guide/deploy.html#google-firebase)

### Server Rendered
<!-- ### Server Rendered
**TODO**
**TODO** -->

## Surge

Expand Down

0 comments on commit e7ce6bc

Please sign in to comment.