Skip to content

Commit

Permalink
fix: #16 handle empty slug parts
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloamgomes committed Apr 4, 2024
1 parent e58069f commit 37a5249
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Install the App using by doing the below steps:

1. Create a new Contentful custom App and define the Application Name (e.g. Better Slugs)

2. Download [dist.zip](https://github.com/pauloamgomes/contentful-better-slugs-app/releases/download/V1.0.3/dist.zip), unzip and add the resulting folder into the Bundles upload zone:
2. Download [dist.zip](https://github.com/pauloamgomes/contentful-better-slugs-app/releases/latest/download/dist.zip), unzip and add the resulting folder into the Bundles upload zone:
(or download/clone this repo and use the dist folder):

![App Bundles Upload](./docs/app-bundles.png)
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="module" crossorigin src="./assets/index.d728fac3.js"></script>
<script type="module" crossorigin src="./assets/index.44f5a9dd.js"></script>
</head>

<body>
Expand Down
5 changes: 3 additions & 2 deletions src/locations/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const Field = () => {
raw = sdk.entry.fields[fieldParts[1]].getValue(defaultLocale);
}
}
slug = slugify(raw, slugOptions);
slug = raw?.length ? slugify(raw, slugOptions) : '';
} else {
raw =
(await getReferenceFieldValue(
Expand Down Expand Up @@ -266,7 +266,8 @@ const Field = () => {
.replace(/\/\//g, "/")
.replace(/\/$/, "")
.replace(/\/-\//g, "-")
.replace(/\/:\//g, ":"),
.replace(/\/:\//g, ":")
.replace(/^\//, ""),
locale
);
};
Expand Down

0 comments on commit 37a5249

Please sign in to comment.