cecil/theme-netlify

Cecil 组件主题 Netlify

资助包维护!
ArnaudLigny
Open Collective

安装次数: 19,718

依赖项: 4

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放性问题: 0

语言:Twig

类型:cecil-theme

2.0.1 2024-03-25 10:42 UTC

This package is auto-updated.

Last update: 2024-08-25 11:43:41 UTC


README

Cecil 提供支持 Netlify 的 _redirects_header 组件主题。

安装后无需任何配置,此组件主题将生成

  1. 一个 _redirects 文件,包含由 Cecil(自动创建或通过 redirect 前端变量手动创建的 HTML 重定向
  2. 一个 _header 文件,包含关于安全和资产缓存控制的最佳实践

安装

composer require cecil/theme-netlify

或者 下载最新存档 并将其内容解压缩到 themes/netlify

用法

在您的 config.ymltheme 部分中添加 netlify

theme:
  - netlify

添加重定向

netlify:
  redirects:
    - from: https://xxxxxx/*
      to: https://xxxxxx/:splat
      status: 301 # optional
      force: true # optional

有关详细信息,请参阅 Netlify 文档

将主页重定向到用户语言版本

netlify:
  redirect_by_language: true # false by default

为每种可用的语言(除默认语言外)生成以下重定向

/  /<language-code>/    302!    Language=<language-code>

示例

/  /fr/    302!    Language=fr

语言可以指定在 cookie nf_lang 中,因此您可以使用 JavaScript 覆盖默认行为(例如,如果有一个语言下拉选择器)。