Faust.js™ - The Headless WordPress Framework
OTHER License
Bot releases are visible (Hide)
Published by github-actions[bot] over 2 years ago
applyRequestContext
Published by github-actions[bot] over 2 years ago
Published by blakewilson over 2 years ago
https://github.com/wpengine/faustjs/commit/6a7559376a15bab06e3fc1b0f537199810ea19e3: Fixes a PHP 8 warning that occured on post types not registered with WP GraphQL https://github.com/wpengine/faustjs/pull/812
Published by josephfusco over 2 years ago
Published by github-actions[bot] over 2 years ago
732623e: Added the robotsTxt
config option in handleSitemapRequests
that allows you to specify the content of your /robots.txt
route. You can use the following snippet to create a /robots.txt
route:
handleSitemapRequests(req, {
wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
sitemapIndexPath: '/wp-sitemap.xml',
async robotsTxt(sitemapUrl) {
return `
User-agent: *
Allow: /
Sitemap: ${sitemapUrl}
`;
},
});
Notice robotsTxt
is an async function that takes sitemapUrl
as an argument. sitemapUrl
can then be used to specify the URL to your sitemap in your robots.txt content.
7e98ca6: Added support for sitemaps! Sitemaps in Faust.js work with Next.js middleware. You can create a piece of middleware at src/pages/_middleware.ts
with the following content:
import { handleSitemapRequests } from '@faustjs/next/middleware';
import { NextRequest, NextResponse } from 'next/server';
export default async function middleware(req: NextRequest) {
const sitemapRequest = await handleSitemapRequests(req, {
wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
sitemapIndexPath: '/wp-sitemap.xml',
});
if (sitemapRequest) {
return sitemapRequest;
}
return NextResponse.next();
}
The handleSitemapRequests
API requires wpUrl
and sitemapIndexPath
to be defined. There is optional properties you can define to suit your needs. The config is as follows:
import { handleSitemapRequests } from '@faustjs/next';
handleSitemapRequests(middlewareReq, {
// REQUIRED: Your WordPress URL
wpUrl: process.env.NEXT_PUBLIC_WORDPRESS_URL,
// REQUIRED: The path to your sitemap index file on WordPress
sitemapIndexPath: '/wp-sitemap.xml',
/**
* OPTIONAL: Sitemap paths to ignore. Useful if you don't want to include sitemaps for users, categories, etc.
*/
sitemapPathsToIgnore: [
'/wp-sitemap-posts-page-1.xml',
'/wp-sitemap-posts-post-*', // Specify a wildcard a tthe end to avoid multiple indices if necessary
],
/**
* OPTIONAL: List of Next.js pages to include in your sitemap.
*/
pages: [
{
path: '/about', // required
priority: 0.75, // optional
changefreq: 'monthly', // optional
lastmod: new Date().toISOString(), // optional
},
],
/**
* OPTIONAL: Replace WP urls with the headless frontend. `true` by default.
*/
replaceUrls: true,
});
Published by apmatthews over 2 years ago
Published by github-actions[bot] over 2 years ago
Published by github-actions[bot] over 2 years ago
Published by apmatthews over 2 years ago
is_events_enabled()
function has also been removed.Published by github-actions[bot] over 2 years ago
Published by josephfusco over 2 years ago
Published by github-actions[bot] almost 3 years ago
Published by github-actions[bot] almost 3 years ago
schema.generated.ts
to support contentNode
for usePreviewNode
usage.Published by github-actions[bot] almost 3 years ago
c74ce4f: Introduced the usePreviewNode
hook to get preview data from any post type. You can use it like so:
import type { Page, Post } from 'client';
import { client } from 'client';
export default function Preview() {
const isLoading = client.useIsLoading();
const { typeName, node } = client.auth.usePreviewNode();
if (isLoading || node === undefined) {
return <p>Loading...</p>;
}
if (node === null) {
return <p>Post not found</p>;
}
switch (typeName) {
case 'Page': {
const page = node as Page;
return (
<>
<h1>{page.title()}</h1>
<div dangerouslySetInnerHTML={{ __html: page.content() }} />
</>
);
}
case 'Post': {
const post = node as Post;
return (
<>
<h1>{post.title()}</h1>
<div dangerouslySetInnerHTML={{ __html: post.content() }} />
</>
);
}
// Add custom post types here as needed
default: {
throw new Error(`Unknown post type: ${typeName}`);
}
}
}
With usePreviewNode
, we have deprecated the usePreview
hook. It is still available, but it is recommended to use usePreviewNode
instead.
Updated dependencies [3c1280b]
Updated dependencies [3c1280b]
Published by github-actions[bot] almost 3 years ago
contentNode
for usePreviewNode
usage.Published by github-actions[bot] almost 3 years ago
Published by github-actions[bot] almost 3 years ago
Published by github-actions[bot] almost 3 years ago
Published by blakewilson almost 3 years ago
Published by github-actions[bot] almost 3 years ago
Internal Server Error
when fetching access/refresh tokens when permalinks are not set