-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: convert special html symbols in page titles to understandable characters (resolves #387) #388
fix: convert special html symbols in page titles to understandable characters (resolves #387) #388
Conversation
eleventy.config.js
Outdated
@@ -10,6 +10,7 @@ const dataFetcherAirtable = require("./src/utils/data-fetcher-airtable.js"); | |||
const htmlMinifyTransform = require("./src/transforms/html-minify.js"); | |||
const parseTransform = require("./src/transforms/parse.js"); | |||
const dateFilter = require("./src/filters/date.js"); | |||
const metaTitleFilter = require("./src/filters/meta-title.js"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
titleFilter
might be a better name than metaTitleFilter
.
src/js/utils.js
Outdated
@@ -2,6 +2,17 @@ | |||
|
|||
/* global convertDate, stripHtmlTags, htmlDecode, chunkArray, escapeSpecialChars */ | |||
|
|||
/* | |||
* Remove soft hyphens and replace ’ with apostrophe. | |||
* @param {String} webpageString - A string with one or more soft hyphens or ’. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to rename webpageString
to inputStr
. In this case, try to pick a name that suits the function itself rather than the context you wanted to use this function.
src/js/utils.js
Outdated
*/ | ||
// eslint-disable-next-line | ||
metaTitle = function (webpageString) { | ||
webpageString = webpageString.replace(/’/g, "’"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use a logic like:
const toReplace = {
"’": "’",
"­": ""
};
// Iterate thru toReplace object to replace every match.
When a new replacement needs to be added, extending the data in toReplace
will be enough rather than copying the .replace()
code over and over.
npm run lint
without errorsnpm run start
and reviewing affected routesnpm run build
without errorsDescription
Remove
­
from title tags on webpages with soft hyphens in title.Steps to test
<title>
tag in the<head>
tagExpected behavior:
­
should not appearAdditional information
This PR also replaces
’
with an apostrophe in title tags.Related issues
resolves #387