📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
get rid of old blog api calls & forward to new blog page
Blue Mouse54894de3cfbb
diff --git a/.env.example b/.env.exampleindex f1912e6ec..d56fecfc8 100644--- a/.env.example+++ b/.env.example@@ -1,6 +1,5 @@API_URL=https://api.swetrix.com/API_STAGING_URL=http://localhost:5005/CDN_URL=https://cdn.swetrix.com/-BLOG_URL=https://blog.swetrix.com/AIAPI_URL=https://aiapi.swetrix.com/REDIS_URL=redis://default:[email protected]diff --git a/app/api/blog.ts b/app/api/blog.tsdeleted file mode 100644index 93976111c..000000000--- a/app/api/blog.ts+++ /dev/null@@ -1,25 +0,0 @@-/* eslint-disable implicit-arrow-linebreak */-import axios from 'axios'-import Debug from 'debug'-import _isEmpty from 'lodash/isEmpty'-import { BLOG_URL } from 'redux/constants'--const debug = Debug('swetrix:blog')--const api = axios.create({- baseURL: BLOG_URL,-})--export const getLastPost = () =>- api- .get('last-post?format=json')- .then((response): {- title: string- url_path: string- } => response.data)- .catch((error) => {- debug('%s', error)- throw _isEmpty(error.response.data?.message)- ? error.response.data- : error.response.data.message- })diff --git a/app/api/index.ts b/app/api/index.tsindex 6c3fafc1d..21975c830 100644--- a/app/api/index.ts+++ b/app/api/index.ts@@ -1180,3 +1180,18 @@ export const getBlogPostWithCategory = (category: string, slug: string) =>debug('%s', error)throw error})++export const getLastPost = () =>+ api+ .get('v1/blog/last-post')+ .then((response): {+ title: string+ handle: string+ } => response.data)+ .catch((error) => {+ debug('%s', error)+ throw _isEmpty(error.response.data?.message)+ ? error.response.data+ : error.response.data.message+ })+\ No newline at end of filediff --git a/app/components/Footer/index.tsx b/app/components/Footer/index.tsxindex 6053fd4ef..f1561f241 100644--- a/app/components/Footer/index.tsx+++ b/app/components/Footer/index.tsx@@ -8,7 +8,7 @@ import PropTypes from 'prop-types'import {isSelfhosted, DONATE_URL, FIREFOX_ADDON_URL, CHROME_EXTENSION_URL, GITHUB_URL,- LINKEDIN_URL, STATUSPAGE_URL, TWITTER_URL, BLOG_URL, UTM_GENERATOR_URL, SWETRIX_VS_GOOGLE,+ LINKEDIN_URL, STATUSPAGE_URL, TWITTER_URL, UTM_GENERATOR_URL, SWETRIX_VS_GOOGLE,SWETRIX_VS_CLOUDFLARE, DOCS_URL, SWETRIX_VS_SIMPLE_ANALYTICS, DISCORD_URL, CAPTCHA_URL,} from 'redux/constants'import routesPath from 'routesPath'@@ -21,7 +21,7 @@ const navigation = {{ key: 'press', href: routesPath.press, internal: true },{ key: 'status', href: STATUSPAGE_URL },{ key: 'donate', href: DONATE_URL },- { key: 'blog', href: BLOG_URL },+ { key: 'blog', href: routesPath.blog, internal: true },],legal: [(authenticated: boolean | undefined): {diff --git a/app/components/Header/index.tsx b/app/components/Header/index.tsxindex 969e8fb88..1584ac317 100644--- a/app/components/Header/index.tsx+++ b/app/components/Header/index.tsx@@ -27,8 +27,7 @@ import { authActions } from 'redux/reducers/auth'import sagaActions from 'redux/sagas/actions'import UIActions from 'redux/reducers/ui'import {- whitelist, languages, languageFlag, isSelfhosted, BLOG_URL,- DOCS_URL, SUPPORTED_THEMES, isBrowser,+ whitelist, languages, languageFlag, isSelfhosted, DOCS_URL, SUPPORTED_THEMES, isBrowser,} from 'redux/constants'import Dropdown from 'ui/Dropdown'import { IUser } from 'redux/models/IUser'@@ -336,14 +335,12 @@ const AuthedHeader = ({{t('billing.inactive')}</Link>)}- <a- href={BLOG_URL}+ <Link+ to={routesPath.blog}className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'- target='_blank'- rel='noreferrer noopener'>{t('footer.blog')}- </a>+ </Link><ahref={DOCS_URL}className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'@@ -394,14 +391,12 @@ const AuthedHeader = ({</div></div><div className='py-4 flex gap-4 flex-wrap justify-center space-x-2 lg:hidden'>- <a- href={BLOG_URL}+ <Link+ to={routesPath.blog}className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'- target='_blank'- rel='noreferrer noopener'>{t('footer.blog')}- </a>+ </Link><ahref={DOCS_URL}className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'@@ -465,22 +460,21 @@ const NotAuthedHeader = ({{!refPage && (<div className='hidden ml-10 space-x-1 lg:flex gap-4 items-center'>- <a- href={BLOG_URL}++ <Link+ to={routesPath.blog}className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'- target='_blank'- rel='noreferrer noopener'>{t('footer.blog')}- </a>+ </Link>{!isSelfhosted && (- <Link- to={`${routesPath.main}#pricing`}- className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'- key='Pricing'- >- {t('common.pricing')}- </Link>+ <Link+ to={`${routesPath.main}#pricing`}+ className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'+ key='Pricing'+ >+ {t('common.pricing')}+ </Link>)}<a href={DOCS_URL} className='font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white' target='_blank' rel='noreferrer noopener'>{/* <DocumentTextIcon className='w-5 h-5 mr-1' /> */}@@ -549,14 +543,12 @@ const NotAuthedHeader = ({</div>{!refPage && (<div className='py-4 flex gap-4 flex-wrap justify-center space-x-2 lg:hidden'>- <a- href={BLOG_URL}+ <Link+ to={routesPath.blog}className='flex items-center font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'- target='_blank'- rel='noreferrer noopener'>{t('footer.blog')}- </a>+ </Link><Linkto={`${routesPath.main}#pricing`}className='flex items-center font-semibold leading-6 text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsxindex 71f6be6ca..b34c1d363 100644--- a/app/pages/MainPage/index.tsx+++ b/app/pages/MainPage/index.tsx@@ -19,7 +19,7 @@ import routesPath from 'routesPath'import { getAccessToken } from 'utils/accessToken'import { nFormatterSeparated } from 'utils/generic'import {- GITHUB_URL, MARKETPLACE_URL, LIVE_DEMO_URL, isBrowser, BLOG_URL,+ GITHUB_URL, MARKETPLACE_URL, LIVE_DEMO_URL, isBrowser,} from 'redux/constants'import { StateType } from 'redux/store/index'import BackgroundSvg from 'ui/icons/BackgroundSvg'@@ -246,17 +246,15 @@ const Main: React.FC<IMain> = ({ ssrTheme, ssrAuthenticated }): JSX.Element => {) : (<ClientOnly fallback={<div className='h-6 ml-1 bg-slate-300 dark:bg-slate-700 w-full max-w-xs rounded-md animate-pulse' />}>{() => (- <a+ <LinkclassName='inline-flex ml-1 items-center space-x-1 text-sm font-semibold leading-6 text-slate-700 dark:text-slate-300 hover:underline'- href={`${BLOG_URL}post/${lastBlogPost.url_path}`}- target='_blank'- rel='noopener noreferrer'+ to={`blog/${lastBlogPost.handle}`}><span>{lastBlogPost.title}</span><ChevronRightIcon className='h-4 w-4 text-slate-500' aria-hidden='true' />- </a>+ </Link>)}</ClientOnly>)}diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.tsindex 512343d0a..37f2b8e96 100644--- a/app/redux/constants/index.ts+++ b/app/redux/constants/index.ts@@ -257,7 +257,6 @@ const STAGING_API_URL = isBrowser ? window.REMIX_ENV?.API_STAGING_URL : process.const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV?.API_URL : process.env.API_URLexport const API_URL = isStaging ? STAGING_API_URL : PRODUCTION_API_URL-export const BLOG_URL = isBrowser ? window.REMIX_ENV?.BLOG_URL : process.env.BLOG_URLexport const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URLexport const CDN_URL = isBrowser ? window.REMIX_ENV?.CDN_URL : process.env.CDN_URLexport const NODE_ENV = isBrowser ? window.REMIX_ENV?.NODE_ENV : process.env.NODE_ENVdiff --git a/app/redux/sagas/ui/initialise.ts b/app/redux/sagas/ui/initialise.tsindex 3337f88cf..fb297e59e 100644--- a/app/redux/sagas/ui/initialise.ts+++ b/app/redux/sagas/ui/initialise.ts@@ -6,7 +6,7 @@ import { getRefreshToken } from 'utils/refreshToken'import UIActions from 'redux/reducers/ui'import { isSelfhosted } from 'redux/constants'import sagaActions from '../actions'-const { getLastPost } = require('api/blog')+const { getLastPost } = require('api')const debug = Debug('swetrix:rx:s:initialise')@@ -28,7 +28,7 @@ export default function* initialise() {const lastBlogPost: {title: string,- url_path: string,+ handle: string,} = yield call(getLastPost)yield put(UIActions.setLastBlogPost(lastBlogPost))}diff --git a/app/root.tsx b/app/root.tsxindex ce45dc148..b6b8084b9 100644--- a/app/root.tsx+++ b/app/root.tsx@@ -191,7 +191,6 @@ export async function loader({ request }: LoaderArgs) {API_URL: process.env.API_URL,API_STAGING_URL: process.env.API_STAGING_URL,CDN_URL: process.env.CDN_URL,- BLOG_URL: process.env.BLOG_URL,SELFHOSTED: process.env.SELFHOSTED,STAGING: process.env.STAGING,}diff --git a/app/routesPath/index.ts b/app/routesPath/index.tsindex 7498b2d88..545715d0d 100644--- a/app/routesPath/index.ts+++ b/app/routesPath/index.ts@@ -32,6 +32,7 @@ const routes = Object.freeze({project_protected_password: '/projects/:id/password',open: '/open',ref: '/ref/:id',+ blog: '/blog',})export default routes