Skip to content

Instantly share code, notes, and snippets.

Avatar

Lax Mariappan laxmariappan

View GitHub Profile
@laxmariappan
laxmariappan / index.jsx
Last active May 23, 2022
data fetching example - Remix
View index.jsx
// import loader hook
import { useLoaderData, Link } from "@remix-run/react";
export let loader = async () => {
const result = await fetch("https://wordpress.org/news/wp-json/wp/v2/posts");
const posts = await result.json();
return posts;
};
@laxmariappan
laxmariappan / root.jsx
Created May 23, 2022
ErrorBoundary for Remix app
View root.jsx
export function ErrorBoundary({ error }) {
console.log(error);
return (
<Document>
<Layout>
<section className="p-6">
<div className="relative items-center w-full px-5 py-12 mx-auto md:px-12 lg:px-24 max-w-7xl">
<h1>There was an Error</h1>
<p>{error.message}</p>
@laxmariappan
laxmariappan / root.jsx
Created May 23, 2022
Layout for Remix Tailwind app
View root.jsx
export function Layout({ children }) {
return (
<>
<Header />
{children}
<Footer />
</>
);
}
@laxmariappan
laxmariappan / root.jsx
Created May 23, 2022
Document for Remix Tailwind app
View root.jsx
function Document({ children }) {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body className="bg-gray-100">
@laxmariappan
laxmariappan / root.jsx
Last active May 23, 2022
Remix App component
View root.jsx
export default function App() {
return (
<Document>
<Layout>
<Outlet />
</Layout>
</Document>
);
}
@laxmariappan
laxmariappan / root.jsx
Created May 23, 2022
Remix Tailwind importing styles
View root.jsx
import styles from "./tailwind.css";
//Link the stylesheet
export const links = () => [
{ rel: "stylesheet", href: styles },
];
View installation.js
npx create-remix@latest
//Hit enter to confirm the installation
? Where would you like to create your app? (./my-remix-app) `remix-wp`
//The default name is my-remix-app, you name your app here. I’ve named it remix-wp
//The next step would be choosing the app server.
@laxmariappan
laxmariappan / ultimate-member-profile-menu.php
Created Jul 19, 2020
WordPress Ultimate Member - Edit account and profile link on profile menu tabs
View ultimate-member-profile-menu.php
<?php
// taken from https://gist.github.com/ultimatemember/8cdaf61e7bd9de35512c#gistcomment-3034086
// tested - it works
// Filter
function um_add_custom_tabs( $tabs ) {
$tabs['account'] = array(
'name' => 'Edit Account',
'icon' => 'um-faicon-pencil',
'custom' => TRUE
);
@laxmariappan
laxmariappan / Wordpress_text_for_empty_content.php
Created Feb 15, 2019
Wordpress: Check if the_content is empty / return custom text only when the_content is empty
View Wordpress_text_for_empty_content.php
// Check if the content is empty and show a custom message //
add_filter('the_content', 'text_for_empty_content', 20, 1);
function text_for_empty_content($content){
if(empty($content)) // Check if the content is empty
return '<p>Under Construction</p>'; // Add your custom text or other HTML
else
return $content; // if content is there, just leave it as it is
}
/*