Skip to content

Commit f5e7118

Browse files
authored
Getting correct current year (#1081)
Getting current year as Math.max(2023, Number(__BUILD_YEAR__), new Date().getFullYear());
1 parent d4cc0e2 commit f5e7118

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/components/Footer/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import TranslationContext from "Layout/TranslationContext";
44

55
const Footer = () => {
66
const getTranslation = useContext(TranslationContext);
7+
const currentYear = new Date().getFullYear();
78

89
return (
910
<div className="lingvodoc-page__footer lingvodoc-footer">
1011
<div className="lingvodoc-footer__inner">
11-
Copyright © 2012-2022 &nbsp;
12+
Copyright © 2012-{Math.max(2023, Number(__BUILD_YEAR__), currentYear)} &nbsp;
1213
<a href="https://iling-ran.ru" target="_blank" rel="noreferrer">
1314
{getTranslation("Institute of Linguistics Russian Academy of Sciences")}
1415
</a>

webpack/utils.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ if ("LINGVODOC_BUILD_TYPE" in process.env) {
6363
versionString += process.env.LINGVODOC_BUILD_TYPE;
6464
}
6565

66+
/* Constructing current year. */
67+
68+
var buildYear = "";
69+
70+
try {
71+
buildYear = new Date().getFullYear().toString();
72+
} catch (error) {}
73+
6674
module.exports = {
6775
cwd(file) {
6876
return path.join(process.cwd(), file || "");
@@ -80,5 +88,6 @@ module.exports = {
8088
}
8189
};
8290
},
83-
versionString
91+
versionString,
92+
buildYear
8493
};

webpack/webpack.dev.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ base.plugins.push(
5454
}),
5555
new webpack.DefinePlugin({
5656
"process.env.NODE_ENV": JSON.stringify("development"),
57-
__VERSION__: JSON.stringify(_.versionString)
57+
__VERSION__: JSON.stringify(_.versionString),
58+
__BUILD_YEAR__: JSON.stringify(_.buildYear)
5859
}),
5960
new webpack.HotModuleReplacementPlugin(),
6061
new ReactRefreshWebpackPlugin(),

webpack/webpack.prod.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ base.plugins.push(
6464
new MiniCssExtractPlugin({ filename: "[name].[contenthash:8].css", chunkFilename: "[id].[contenthash:8].css" }),
6565
new webpack.DefinePlugin({
6666
"process.env.NODE_ENV": JSON.stringify("production"),
67-
__VERSION__: JSON.stringify(_.versionString)
67+
__VERSION__: JSON.stringify(_.versionString),
68+
__BUILD_YEAR__: JSON.stringify(_.buildYear)
6869
})
6970
);
7071

0 commit comments

Comments
 (0)