Skip to content

Commit

Permalink
Getting current year as Math.max(2023, Number(__BUILD_YEAR__), new Da…
Browse files Browse the repository at this point in the history
…te().getFullYear());
  • Loading branch information
vmonakhov committed Nov 28, 2023
1 parent d4cc0e2 commit 9ddd850
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/Footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import TranslationContext from "Layout/TranslationContext";

const Footer = () => {
const getTranslation = useContext(TranslationContext);
const currentYear = new Date().getFullYear();

return (
<div className="lingvodoc-page__footer lingvodoc-footer">
<div className="lingvodoc-footer__inner">
Copyright © 2012-2022 &nbsp;
Copyright © 2012-{Math.max(2023, Number(__BUILD_YEAR__), currentYear)} &nbsp;
<a href="https://iling-ran.ru" target="_blank" rel="noreferrer">
{getTranslation("Institute of Linguistics Russian Academy of Sciences")}
</a>
Expand Down
11 changes: 10 additions & 1 deletion webpack/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ if ("LINGVODOC_BUILD_TYPE" in process.env) {
versionString += process.env.LINGVODOC_BUILD_TYPE;
}

/* Constructing current year. */

var buildYear = "";

try {
buildYear = new Date().getFullYear().toString();
} catch (error) {}

module.exports = {
cwd(file) {
return path.join(process.cwd(), file || "");
Expand All @@ -80,5 +88,6 @@ module.exports = {
}
};
},
versionString
versionString,
buildYear
};
3 changes: 2 additions & 1 deletion webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ base.plugins.push(
}),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("development"),
__VERSION__: JSON.stringify(_.versionString)
__VERSION__: JSON.stringify(_.versionString),
__BUILD_YEAR__: JSON.stringify(_.buildYear)
}),
new webpack.HotModuleReplacementPlugin(),
new ReactRefreshWebpackPlugin(),
Expand Down
3 changes: 2 additions & 1 deletion webpack/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ base.plugins.push(
new MiniCssExtractPlugin({ filename: "[name].[contenthash:8].css", chunkFilename: "[id].[contenthash:8].css" }),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production"),
__VERSION__: JSON.stringify(_.versionString)
__VERSION__: JSON.stringify(_.versionString),
__BUILD_YEAR__: JSON.stringify(_.buildYear)
})
);

Expand Down

0 comments on commit 9ddd850

Please sign in to comment.