From dcc603ed240c2422fa4c512bd263a5961269cbe3 Mon Sep 17 00:00:00 2001 From: Liam Bigelow <40188355+bglw@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:41:10 +1300 Subject: [PATCH 1/2] Add Rosey tag to ignore rewriting hrefs --- docs/content/docs/urls.md | 19 +++++++++++--- .../features/build/rosey-build-links.feature | 26 +++++++++++++++++++ rosey/src/runners/builder/html.rs | 3 +++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/docs/content/docs/urls.md b/docs/content/docs/urls.md index 596c4e5..2417b80 100644 --- a/docs/content/docs/urls.md +++ b/docs/content/docs/urls.md @@ -1,15 +1,28 @@ --- -title: "Translated URLs" -nav_title: "Translated URLs" +title: "Managing URLs" +nav_title: "Managing URLs" nav_section: Workflow weight: 6 --- -Rosey URL locale files can contain translated URLs for your website in a given language. +Rosey provides some options for managing URLs. +Rosey can ignore some URLs altogether, and Rosey URL locale files can contain translated URLs for your website in a given language. If you just want to move one language to the root of the site, e.g. serve `/en/index.html` at `index.html` instead, see the [Default language at root](/docs/build/#default-language-at-root) option for Rosey's build step. +## Telling Rosey to ignore URLs + +If you have a URL on a page that you do not want Rosey to rewrite, you can add the `data-rosey-ignore` attribute to it. + +```html + Posts + + Contact +``` + +When built to a page in an `fr` locale, the first tag would link to `/fr/posts/`, while the tag with `data-rosey-ignore` would remain pointing at `/contact/`. + ## Creating translated URL locale files Creating URL locale files is not a step performed by Rosey. This part of the translation workflow is left open ended, usually integrating into an existing translation workflow for a company, or being programmatically created by transforming the input URLs. diff --git a/rosey/features/build/rosey-build-links.feature b/rosey/features/build/rosey-build-links.feature index a08e6b9..873c6ff 100644 --- a/rosey/features/build/rosey-build-links.feature +++ b/rosey/features/build/rosey-build-links.feature @@ -74,3 +74,29 @@ Feature: Rosey Links Then I should see a selector 'h2>a' in "dist/translated_site/blank/index.html" with the attributes: | href | /blank/hello | | innerText | Hello | + + + Scenario: Rosey can ignore links + Given I have a "dist/site/index.html" file with the content: + """ + +
+