Skip to content

Commit

Permalink
Rename config import name to avoid collisions with page exported conf…
Browse files Browse the repository at this point in the history
…ig constant
  • Loading branch information
seth2810 committed Sep 16, 2022
1 parent f3d34c8 commit d8f5396
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions next-app/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { serialize } from 'next-mdx-remote/serialize';
import findLastIndex from 'lodash.findlastindex';
import capitalize from 'lodash.capitalize';

import config from '../data/config.js';
import cfg from '../data/config.js';

const formatNameToHeader = (name) => {
return name
Expand All @@ -22,7 +22,7 @@ const readPost = async (filePath, basePath) => {
const { data, content } = matter(fileContent);
const { name } = path.parse(filePath);
const { title = null, header = title, description = null, summary = description, ...props } = data;
const sourceUrl = `${config.repositoryUrl}/tree/main/${filePath}`;
const sourceUrl = `${cfg.repositoryUrl}/tree/main/${filePath}`;
const shortName = name.slice(11); // remove DD_MM_YYYY prefix from post file name

return {
Expand Down
12 changes: 6 additions & 6 deletions next-app/components/DefaultLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@ import Head from 'next/head';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';

import config from '../data/config.js';
import cfg from '../data/config.js';

import Navbar from '../components/Navbar.jsx';
import Footer from '../components/Footer.jsx';

const DefaultLayout = ({ title, description, author, image, type = 'website', children }) => {
const { t } = useTranslation('common');
const { asPath, locale } = useRouter();
const fullTitle = title ? `${title} | ${config.title}` : config.title;
const fullTitle = title ? `${title} | ${cfg.title}` : cfg.title;
const metaDescription = description || t('description');
const metaAuthor = author || t('author');
const [path] = asPath.split('?');
const prefix = locale === 'ru' ? `/${locale}` : '';
const url = `${config.siteUrl}${prefix}${path}`;
const imageUrl = `${config.siteUrl}${image}`;
const url = `${cfg.siteUrl}${prefix}${path}`;
const imageUrl = `${cfg.siteUrl}${image}`;

return (
<>
<Head>
<title>{fullTitle}</title>
<link rel="icon" href={config.favicon} />
<link rel="icon" href={cfg.favicon} />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="author" content={metaAuthor} />
<meta name="description" content={metaDescription} />
Expand All @@ -32,7 +32,7 @@ const DefaultLayout = ({ title, description, author, image, type = 'website', ch
<meta property="og:locale" content={t('locale')} />
<meta property="og:description" content={metaDescription} />
<meta property="og:url" content={url} />
<meta property="og:site_name" content={config.title} />
<meta property="og:site_name" content={cfg.title} />
<meta property="og:type" content={type} />
{image && <meta property="og:image" content={imageUrl} />}
<meta property="twitter:title" content={title} />
Expand Down
6 changes: 3 additions & 3 deletions next-app/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';

import config from '../data/config.js';
import cfg from '../data/config.js';

const Navbar = () => {
const { t } = useTranslation('common');
Expand All @@ -26,12 +26,12 @@ const Navbar = () => {
<div className="d-flex flex-wrap justify-content-center py-3">
<Link href="/">
<a className="navbar-brand me-auto">
<Image width="30" height="30" alt="Hexlet logo" src={config.logo} />
<Image width="30" height="30" alt="Hexlet logo" src={cfg.logo} />
</a>
</Link>
<ul className="nav nav-pills">
<li className="nav-item">
<Link href={config.repositoryUrl}>
<Link href={cfg.repositoryUrl}>
<a className="nav-link" target="_blank">
{t('navbar.source_code.title')}
</a>
Expand Down
4 changes: 2 additions & 2 deletions next-app/pages/[name].js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

import config from '../data/config.js';
import cfg from '../data/config.js';
import { i18n } from '../next-i18next.config.js';
import { findPost, getPublishedPosts } from '../api/index.js';
import DefaultLayout from '../components/DefaultLayout.jsx';
Expand All @@ -15,7 +15,7 @@ const Post = ({ post }) => {
}

const disqus = {
short_name: config.disqus[locale],
short_name: cfg.disqus[locale],
config: {
language: locale,
title: post.header,
Expand Down

0 comments on commit d8f5396

Please sign in to comment.