Skip to content

Commit

Permalink
last updated at time and reading time
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Oct 27, 2023
1 parent c71e630 commit bd4b9f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/nextra-theme/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ export default function NextraLayout({ children, pageOpts, pageProps }: NextraTh
const { locale, defaultLocale } = useI18n<any>()
const fsPath = useFSRoute()

const gitDate = new Date(pageOpts.timestamp!)
const lastUpdatedAt = gitDate.toLocaleDateString(locale, {
day: 'numeric',
month: 'long',
year: 'numeric',
})
const dateEl = <time dateTime={gitDate.toISOString()}>{lastUpdatedAt}</time>

console.log('timestamp', lastUpdatedAt)
console.log('reading time', pageOpts.readingTime!.minutes > 0 && pageOpts.readingTime!.text)

const args = useMemo(() => {
const result = normalizePages({
list: pageMap,
Expand Down
1 change: 1 addition & 0 deletions website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const withNextra = nextra({
flexsearch: false,
codeHighlight: false,
defaultShowCopyCode: false,
readingTime: true,
transform(result, { route }) {
if (route && !result.includes('getStaticProps')) {
const banner = `
Expand Down

0 comments on commit bd4b9f4

Please sign in to comment.